1. Welcome to Smogon Forums! Please take a minute to read the rules.
  2. Click here to assure that you never miss a new SmogonU video upload!
  3. Ever find yourself missing out on the latest Smogon articles? We've now got a subscription service, so the newest articles (of your choice) are delivered right to your inbox! Check it out here.

Other Scripting Tutorial

Discussion in 'Technical Projects' started by XCookie, Sep 30, 2011.

  1. XCookie


    Sep 30, 2011
    Scripting Lesson!:

    (Made by supertrunks);


    Source = src
    Target = tar
    stopEvent(); = stops the Message/Event. Like log in or beforeChatMessage this can be used. Some Functions will ignore stopEvent and let them post it. (Only for the one's that un-stopable event).

    Note: Each function has to start with 'sys.' or a error will appear, unless var and/or print.
    xxxx: Also use "); at the end of each function.


    /Eval sys.sendAll(" Test. ");

    *** Or in a Command or Eval JavaScript Code.

    It will send 'Test' in Main Chat to everyone with out the '.


    sendAll("message"); - sends a message to everyone that is in main channel.
    sendMessage(src, "message"); - sends a message to the Source (src).
    sendHtmlAll("message"); - sends a message to everyone that is in main channel, but with HTML.
    sendHtmlMessage(src, "message"); - sends a message to the Source (src), but with HTML.
    print("var1, var2"); - to send a message to the Server Window.

    Player Events:

    changeAuth(tar, authlevel); - to change someone's Server Auth Level. (Use the Auth Chat Below to know the Auth Levels.)
    ip(src) - to get the players current IP Address.
    ban(playerId); - prevents that playerId from entering the Server.
    unban(playerId); - lets the playerId to enter the Server.
    kick(playerId); - disconnects the playerId from the Server.
    eval(eval); - to enter a eval code. * Please use with caution. *

    Info Events:

    dbRegistered(playerId) - to see if that person is registered.
    getColor(playerId); - to get someone's name color. (If any.)
    avatar(avatarnumber) - to change your avatar, until you leave. (If not 1-263, it will be invisible.)

    Command Events:

    if(command == "COMMAND NAME HERE") {
    // Add function(s) here.//
    // Also add any messages, ect.//
    //If ban or kick add sys.kick(tar); or sys.ban(tar); here.//
    Note: When i said "COMMAND NAME HERE" it won't allow you to type in CAPS or spaces. Please use no spaces and NO CAPS. ~ Thanks.

    Chat Events:


    <timestamp/> - to add the time, if using sendHtmlAll or sendHtmlMessage.
    x: If you are not using HTML, it already has a timestamp sent.

    <ping/> - to make that players Pokemon Online client flash.
    x: Good if they are AFK with a tourney or something important.


    "+sys.name(src)+" = The Source or the shorter way 'src'.

    "+sys.name(tar)+" = The Target or the shorter way 'tar'.

    "+commandData+" = The data. (If any.) For reasons like /me, "+commandData+" is what they said.

    "+message+" = the playerId's message, useful when you use sys.print();

    Note: You can space out "+ to " + it will still work. Doesn't matter which way you do it. I choose no space because it's quicker.

    Other Events:

    serverStartUp() - this should be in your script, when the server starts..
    serverShutDown() - this should be in your script, when the server shuts down.
    afterLogIn() - after the src logs in the server.
    beforeLogOut() - before the src logs out the server.
    beforeChatMessage() - before the src talks, useful when they are muted.

    Auth Only:

    if (sys.auth(src) < 1) {
    If you put that before the command, it only lets Moderators and +up use it.

    Note: You can change 1 to 1,2,3, or 4.


    Current PO Auth Chat:

    0; User

    1; Moderator

    2; Administrator

    3; Owner

    4-6; Invisible


    Log Events:

    LogIn(src) - when the source logs in the server.
    LogOut(src) - when the source logs out the server.

    [Var] Lesson:

    You can use a var if you.. for ex. like a boarder:

    You would put this before your commands:

    var b"»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»";
    And you can just use:

    sys.sendMessage(src, " "+b+" ");

    And it would show: »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»

    That is how var works in JavaScripts.

    Big Note: I hope to add on a lot more Java Functions soon.

    Note: Credit to Sephira for helping with Var. (Thanks bro.)

    Remember, feel free to comment!

Users Viewing Thread (Users: 0, Guests: 0)