[Client Scripting] Guide - Coding Your Own Client Bot

Discussion in 'Server and Client Scripting' started by Nightfall Alicorn, Feb 17, 2014.

  1. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    WARNING: Before attempting to use auto respond bots. Please be aware not to have them enabled in Pokemon Online server's official channels, which could risk other users spamming them. Ignorance of the rules due to your use of the bots being used improperly by others isn’t an excuse, and you will be disciplined if necessary.

    Be aware that this guide and template is old, and isn't up to proper scripting standards. However, is a helpful training wheels for PO scripters.

    This guide is focused on providing a template to work from, explaining how the code works and giving notes to help low level coders.

    You all may have noticed that I've heavily edited this post. Hopefully it be much easily to learn scripting from my provided template with more in depth explanation without making it too complex.

    Updated: 10th March, 2014

    Requirements
    - Pokemon Online for PC/Mac
    Android currently doesn't support client scripts.
    - Notepad++ (Recommended if you don’t have a text editor which highlights JavaScript syntax. It can be downloaded here and is free to use: http://notepad-plus-plus.org/)

    Getting Started
    Okay, first, download and install Notepad++. You can use another text editor of your preference, if you wish, but as long as it can highlight JavaScript syntax. Note: This guide will assume you be using Notepad++.

    Next, in the Templates section of this guide. Open the newest Raw Code version link available and then copy and paste all the text into a new Notepad++ document.

    In Notepad++. Click on File and Save As. Then change Save as type: to JavaScript file (*.js). Give the file a suitable name and choose a location in your documents folder and save. I personally save them in the Pokemon Online/Scripts folder in My Documents so I know where everything is.

    The text colour should change and be more easier to read now.

    [​IMG]
    (Note: JavaScript syntax colouring may not be same on your screen. Don't worry if it isn't.)

    You now got your code here ready to edit and build upon it. It's a good idea to make a backup copy of each working version. That way, if you try to make something new and it fails, you can always recover your last working version.

    Now to be able to use the template. You need to paste the code in your Pokemon Online's Script Window in Client scripts tab. If you can't find it under Plugins, follow the steps in Setting Up Script Window Plugin section of this guide.

    Also, to avoid problems turn off Safe Scripts and turn on Show Warnings.

    When you click OK. A help message should display on how to view the original template commands.

    That's about it for getting started. To learn how the script works and how to make your own commands, read the Code Breakdown for v2.0 section of this guide.​

    Templates
    - Pokemon Online Client Script Template v2.1
    Download Link: http://pastebin.com/gdPG650s
    Info: The newest release with improved coding and more example functions.​

    - Pokemon Online Client Script Template v1.0
    Download Link: http://pastebin.com/raw.php?i=z1WqCtCj
    Info: The first template released with basic response messages. This version is no longer supported due to old coding methods.​

    Setting Up Script Window Plugin
    1. Click on Plugins on the toolbar.
    2. If Script Window is already listed in the menu, that means it’s already setup. Else, proceed with the next steps.
    3. Next, click on Plugin Manger and then a window should open.
    4. Now check the checkbox for Scripting Window and then click OK.
    5. Once again, click on Plugins and the added Script Window should be listed ready for later.​

    [​IMG]

    Code Breakdown for v2.0
    Here I will try to give a breakdown explanation of how the code works. Explaining everything all at once, how JavaScript works with Pokemon Online, would be quite difficult and beyond my ability. I've learnt a lot but I'm no pro.​

    Code Comments
    A line starting with // Some text. will be treated as non-code. This is handy for writing your notes down for later. You can also have some code first and the comment part after, on the same line.

    My template scripts has coded comments to help explain each section what it does, to help.​

    ~ Global Variables ~
    These are boxes that store and hold information when you start a program. Or in this case, when you first log on to a server on Pokemon Online. Unlike temporary variables, were information can only be remembered during one run per function, global variables can also be read or edited as long as you remain on the server.​

    Code (JavaScript):
    1. // GLOBAL VARIABLES
    2. // ******** ******** ********
    3. var vgCommandSymbol = "-";
    4. var vgBotName = "±Bot: ";
    5. var vgBotEnabled = true;
    6. var vgOfficialChannelArray = ["Blackjack","Hangman","Mafia","Tohjo Falls","Tournaments","Trivia"];
    A variable is created by the use of var at the start of a line followed by a space and name after. A value is given to it after by use of = with the value followed after. To end the line we use a ;.​

    You can just create an empty unformatted variable by not adding a = or value after. Example:
    var vEmptyVariable;
    Note: JavaScript is case sensitive. Meaning vgCommandSymbol can't be read as vgcommandsymbol, they are both different boxes with different values due to the caps difference. It's recommended not to use numbers or symbols, but letters when naming variables.

    There are different types of variables, main ones are:
    String
    var vStringExample = "Some text.";
    Can hold letters, numbers and symbols, and are enclosed in double-quotes.

    If for some reason you need to add a double-quote in the string, use: \" The backslash will ignore the next symbol after, like it's not part of the script's syntax but as a character in the string.

    You can combine a string together by var vResult = vStringOne + vStringTwo; for example. Note having an integer variable mixed in the string will result vResult being always a string.

    Integer
    var vIntegerExample = 12345;
    Numbers only. You can use math coding with integer. For example: var vResult = vDataOne + vDataTwo; If var vDataOne = 2; and var vDataTwo = 3; The variable vResult will be 5. It's just basic algebra in maths x = y + 3 and, x and y are just variables with numbers in.

    Boolean
    var vBooleanExample = true;
    Holds only true or false. Handy for simple on and off switches. Also they have to be lowercase values I believe, without the quotes.

    Array
    var vArrayExample = [12345, "Some text.", true, vData];
    Can hold multiple values of different formats separated by a comma, even the ones mentioned above. You can even put a variable in an array.

    You can print all contents of an array by just using the name vArrayExample. Which will print: 12345,Some text.,true, vData is holding a string for example

    Or you can put an integer entry enclosed in square brackets, right after the array name. vArrayExample[0] will get the first entry of the array on its own, from that example will be an integer of 12345. vArrayExample[1] will be a sting of "Some text." and so on.

    You can use an integer variable in the square brackets also. var vResult = vArrayExample[vArrayEntryInteger]; Depending what number vArrayEntryInteger holds at that time, the result will be different.

    Do not worry about arrays till much later though if it's confusing you.
    You probably thinking now: okay, vgCommandSymbol is a string holding the symbol that is used for commands. If you figured that out before reading this, your on the right track.

    But what is "vg"? Remember, you can name them what you want but it's important to make sure you give them a meaningful name or you be getting mixed up and most likely getting errors. “vg” is just a personal coding rule I've made that means “variable global”. It's just to avoid temporary variables with "v" changing a global variable by mistake with "vg". Also it's to avoid built-in JavaScript and Pokemon Online functions mixing up with your own variables.

    Example:
    var variableName = value;
    Explanation:
    var vgCommandSymbol = "-"; (string) this holds the symbol that is used for bot commands.
    var vgBotName = "±Bot: "; (string) the bot name that appears in messages, notice the space before the last quote.
    var vgBotEnabled = true; (boolean) having this true has bots on when you log on server, having it false would require the -bot on command needed first.
    var vgOfficialChannelArray = ["Blackjack","Hangman","Mafia","Tohjo Falls","Tournaments","Trivia"]; (array) an array with string values of all the official channel names on Pokemon Online's main server. This is used for checking if a bot is trying to be run in an official channel.
    Remember that global variables are for preparing and keeping data while you're logged on a server.

    ~ Bot Notification Message ~
    Possibly the most easiest thing here. print(“Example message here.”); is a Pokemon Online built-in client script function that allows messages to be displayed to the client owner only.​

    Code (JavaScript):
    1. // SCRIPT UPDATE NOTIFICATION
    2. // ******** ******** ********
    3. print(vgBotName + "Client script updated!");
    4. print(vgBotName + "Use -help / -commands for list of commands!");
    Notice vgBotName in the code sample above. Because it's been declared a global variable first, we can edit all the parts where it has a bot name all at once without needing to go through all the code.​

    Example 1:
    print(“Example message.”);
    This will print a simple message with “(00:00:00) Example message.” in a channel. But remember: only you will see it.
    Example 2:
    var vMessageOne = “Example”;
    print(vMessageOne + “ message.”);

    This will print the same message. I shown this as an example how you can print variable contents and a string together. You can have more, but always make sure you got a + separating the variables and values or you get an error.​

    ~ Pokemon Online Built-In Client Script Object ~
    Code (JavaScript):
    1. // PO SCRIPT
    2. // ******** ******** ********
    3. var objPoScript;
    4. objPoScript = ({
    5.     beforeChannelMessage: function (message, channel, html) {
    6.         // Code here.
    7.         } // END OF beforeChannelMessage
    8.     });
    You probably thinking that this is getting difficult. Relax. I just give a brief explanation about this part. It's already in the template and you don't need to modify or worry about it.​

    First off, this is a JavaScript object holding a Pokemon Online built-in function. These functions holds your respond bots and other codes. This object objPoScript has to be declared on a separate line above and then its contents assigned underneath or else the functions inside won't work. Objects are enclosed in circler brackets with pointy brackets inside them and work on multiple lines between them. Between them both are the functions inside.

    Functions are only enclosed with only pointy brackets though. While if conditions need circler and pointy brackets after, however more information about this later.

    Always make sure each bracket has a start and end or else you get errors. If you get an error on a line that looks correct and has a bracket, make sure they closed properly.

    Here's a coloured version to help break down the start and end of the object and function:

    var objPoScript;
    objPoScript = ({
    beforeChannelMessage: function (message, channel, html) {
    // Code here.
    } // END OF beforeChannelMessage
    });
    One important last note. Make sure the object that holds Pokemon Online built-in functions is the last thing of the script or else it won't work.

    ~ Events / Pokemon Online Built-In Client Script Functions ~
    Code (JavaScript):
    1. beforeChannelMessage: function (message, channel, html) {
    2. }
    This is one of the Pokemon Online's built-in functions. In a program, in order for it to trigger at certain conditions, we need a event/listener which basically what this does. This function will trigger the code between the circler brackets whenever before a channel message is printed on your screen which is either yours or somebody else’s.

    During the run of this function. It will provide 3 variables with given information

    message, for example, will contain “Nightfall Alicorn: Example message.” without the double-quotes. If someone else however sends a message, it will instead contain their name and message.

    channel will contain the unique channel id number. This is an example from my private channel id “57913”.

    I don't know how html is used but I'm guessing it returns a boolean depending if the message is html format or not.

    These provided variables during the run of the function will play an important part on the next later sections of this guide.​

    ~ Variable Preparation ~
    Code (JavaScript):
    1.  // VARIABLES
    2. // ******** ******** ********
    3. var vMyName = client.ownName();
    4. var vUserSentName = message.substring(0, message.indexOf(':'));
    5. var vUserSentMessage = message.substr(message.indexOf(':') + 2);
    6. var vUserSentId = client.id(message.substring(0, message.indexOf(':')));
    7. var vChannelName = client.channelName(channel);
    8. var vChannelId = channel;
    9. var vChannelCurrentlyViewingName = client.channelName(client.currentChannel());
    10. var vChannelCurrentlyViewingId = client.currentChannel();
    Here are some provided variables to help with low level coders. You find that you be using them a lot here. If you trying to make a make a certain command, you may find that one of these is a solution. Remember all you need is to write the variable name to get its information, of course if you put it between double-quotes it will only show the name of the variable, not its contents.

    Now your probably thinking that these aren't the same variables as before. They are indeed still variables and have the same format explained above. However, in the values of them, I've called some Pokemon Online built-in functions to return values. Also, others I've just manipulated of current values from others.

    I'm sure you can figure them out what they are but here's a detailed explanation just in case.

    var vMyName = client.ownName(); will always return a string of your current name. Even if you change your name, the newer alt will display instead of the new one till you change back.

    var vUserSentName = message.substring(0, message.indexOf(':')); will return a string of the user who's message that was sent. Little explanation how this works: remember message in the function above? The value of this variable uses a JavaScript built-in function to cut the name out the full message variable, while leaving the actual user's message part out, so you just have the user's name on its own. So if I sent the message it will have “Nightfall Alicorn”, if Pikachu sent the message, it will have “Pikachu” instead.

    var vUserSentMessage = message.substr(message.indexOf(':') + 2); returns just the string of the user's message, excluding the user's name.

    var vUserSentId = client.id(message.substring(0, message.indexOf(':'))); returns an integer of the user's id who sent the message. You probably wondering why you need this. An example would be sending a reply Private Message in return to the sender. Just a warning about that example, make sure you don't Private Message yourself by your own script or it will crash your Pokemon Online client.

    var vChannelName = client.channelName(channel); returns a string of the channel name. Ideal for making a bot respond saying what channel your currently in.

    var vChannelId = channel; returns an integer of the channel id. You can use channel if you want but I've added it so everything's there and to avoid being confused if it's the id or name.

    var vChannelCurrentlyViewingName = client.channelName(client.currentChannel()); returns a string of the channel name you're currently viewing. Just something extra. Don't get confused by the way, if someone triggers a command in another channel for example: vChannelName will return a string of the name of the channel were the command was triggered, while this returns a string of the channel you're currently viewing on the channel tab.

    var vChannelCurrentlyViewingId = client.currentChannel(); returns an integer of the channel your currently viewing.

    The variable names I've provided should be easy to understand what they are without difficulty. So you basically just have to call them by entering the their names. Keep a note of this section.​

    ~ Command and Command Data Setup ~
    Code (JavaScript):
    1. // COMMAND + COMMAND DATA SETUP
    2. // ******** ******** ********
    3. if (vgCommandSymbol == vUserSentMessage.charAt(0)) {
    4.     var vCommand, vCommandData;
    5.     var vSplit = vUserSentMessage.indexOf(' ');
    6.     if (vSplit !== -1) {
    7.         vCommand = vUserSentMessage.substring(1, vSplit).toLowerCase();
    8.         vCommandData = vUserSentMessage.substr(vSplit + 1);
    9.         }
    10.     else {
    11.         vCommand = vUserSentMessage.substr(1).toLowerCase();
    12.         }
    13.     }
    This code was extracted and edited from Crystal's Client Scripts. I edited it slightly to hopefully make it easier to understand what it does and how it works based from this template guide.​

    As you can see. This section of code is using those variables that was prepared on last section. You don't need to understand how it works if it's difficult but what it does is: It detects if the command symbol (vgCommandSymbol) was detected as the first letter in the user's message. If so, the second character till the space or end of message will be stored as vCommand in a variable. If there's more text after that first space, it will be stored as vCommandData. In short, this is what makes making commands easier to do.

    Confused? Here's an example command:
    -test in a message sent is vgCommandSymbol + vCommand.
    Another example but with command data:
    -attack Nightfall Alicorn in a message sent is vCommandSymbol + vCommand + [space] + vCommandData.
    Note: This is not how commands work in code, but instead how the script sees messages on Pokemon Online. It's just to help you picture how to make a command.

    All you need to know is that this code section simply uses those variables from earlier to make vCommand and vCommandData. Don't worry about the symbol, the script takes care of it automatically.

    ~ Conditions ~
    Before we start making your own commands. It maybe confusing and difficult at first. So you may wanna copy and paste “// EXAMPLE 2 – TEST” code example underneath, from v2.0 template, and play around with it. Ignore the caps from the last sentence by the way, it's just a rule I have while coding, having comments in caps to make it easier to read.

    Before I go into detail about the example commands, I need to explain about conditions in coding. Earlier, I explained about the use of brackets that every one of them has a start and an end. Well here there be 2 types required. First for conditions which are circler brackets. The second for code actions to perform, if the conditions are met.

    Here's an example:​

    Code (JavaScript):
    1. // EXAMPLE 2 - TEST
    2. if (vCommand == "test" || vUserSentMessage.toLowerCase() == "test") {
    3.     client.network().sendChanMessage(channel, vgBotName + "Connection successful, " + vUserSentName + "!");
    4.     return;
    5.     }
    An if condition is declared with if.​

    Next we put a condition between the circler brackets. The types of comparisons are listed below.

    Comparisons
    === Equal To Value and Typeof
    !== Not Equal To Value and Typeof
    == Equal To Value
    != Not Equal To
    > Greater Than
    < Lessor Than
    >= Greater Than And Equal To
    <= Lessor Than And Equal To
    Note the greater and lessor ones can't be used for comparison with strings unless it's checking for integer values of strings such as the length of the string (how many characters are in it) or character position (like the being the first letter in the command setup part).

    Example:
    if (12345 != “Hello”) {
    // This code will run since 12345 is indeed not equal to "Hello".
    }
    You may already know that -test from example 2, uses variables for the condition. That is correct.

    There are times were you need to check 2 or more things in a condition at once. In that example, we checking if the command is “-test” is used, or if the message is “test” being sent, which will run the code if either are true.

    From what I've been told, === and !== are better used than == and != since they work faster.

    Multi Conditions Comparison
    || Or (Meaning if either conditions are met.)
    && And (Meaning both conditions have to be met.)
    The .toLowerCase() makes the string non-caps for that time only, if used in a condition. However a variable can be saved in non-caps if the variable is being given a value though. For example: var vResult = vUserSentMessage.toLowerCase(); vResult will keep a non-caps version of the message now.

    Do not get = confused with ==. = is for assigning a value to a variable. == is for comparing 2 values if they are true in an if condition.

    Also the code only runs between the pointy circler brackets if the conditions are met, else the code between them is ignored.

    ~ Actions ~
    So far, we have learnt about: preparing variables, having a brief explanation about objects, brief explanation about events/functions and learnt conditions just now.​

    But in order for something to happen, we need to put some actions in your code.

    client.network().sendChanMessage(channel_id, “Example message."); this is one that you will be using a lot, which is sending a message in a channel. Don't worry, it's easy to understand.

    Here, we call a Pokemon Online built-in function. Which client.network().sendChanMessage

    Between the circler brackets (channel, “Example message.") are 2 values that are required, that are separated by a comma. The first being the channel's id were the message you want to send and the other being the actual message you wanna send.

    By default, you may wanna leave channel as channel, since the function provides the default id of the channel you want it to respond in. You can use that provided vChannelId which is just a copy of channel if you wish.

    To build a message. You have to use different methods of coding on how you want the message built.

    Here's an example:
    vgBotName + "Connection successful, " + vUserSentName + "!"
    With everything you learnt so far, you should be able to figure it out instantly. If not, let's break it down a bit. Remember to build a dynamic message, we have to separate the variables and strings with + between them. But be careful, you only need one between them or you may end of with errors on that line of code.

    Okay, vgBotName get it's value from global variables, which is var vgBotName = "±Bot: ";. So that variable will show “±Bot: ” in the message.

    Next, we separate it by + and write, between double-quotes, "Connection successful, ". Which will actually add that text in the message.

    Now we wanna get the name of the user who triggered the bot by separating that string and requesting a variable after with a +. Remember that I've made vUserSentName to get the name of the user who sent the message and we want it to reply back to them. So we add that.

    Now we want to complete the message with adding ! in it. Once again we separate it with a + and add “!”.

    Now if we make this message run, it will display:
    (00:00:00) Nightfall Alicorn: ±Bot: Connection successful, Nightfall Alicorn!

    We near done now, just last note. When you want the script to finish on a certain line, we use: return;

    Ready To Make A Command
    Best way to make your own command is to copy and paste an example one. Have a read through the code. These examples should already be in the code with comments on most lines:
    There's a bot owner only section for commands that only you can use. I hadn't made a method so that only you can see yourself entering the commands yet but I may or may not do in the future. This guide is focused on keeping it simple as possible for low level coders.

    I may add more example commands in the future to v2.1 if I get the feel for it. I've spent days writing this guide and gotten bored now. I just hope this update really helps.

    Also, be careful of going overactive because of the script. If you get disconnected and you try reconnecting, under a minute, and it asks you for a password. You most likely went overactive. Normally takes 5-15 minutes disconnected before it asks for password again. Going overactive 3-5 times, auto gets you server banned in a short period of time, but the counter cools down eventually. If you want, you can test your code on your own server.
    Code Structure Map
    [​IMG]

    This is a map of the 2.0 template. Hope it helps gives you a clear view of the overall script.

    Code References
    Pokemon Online’s script events and functions are all found here:

    Some addition new client events and functions are here also. Note some are server ones:

    Last Things
    Loop Warning
    When making bots, make sure you don’t have them respond with simple words that will cause others or yours to loop. For example:
    1. You say "one".
    2. Your bot picks up "one" and says "two" for ya.
    3. Your bot picks up "two" and says "one" for ya.

    Step 2 and 3 will now continuously loop, until some other code stops it. Or when the server kicks you for being overactive.

    Good Place To Study JavaScript
    Also, if your interested in making more advanced bots. You may wanna lookup JavaScript. A place I used was http://www.w3schools.com/js/ but you may wanna look up HTML first since this tutorial is browser based. But most of the code is the same.

    How To Find Errors Easily
    If there is something not working. Have Show Warnings checked in the Script Window. When you try to run the code by clicking OK or by trying to trigger a bot. It will mostly tell you what line the error was on to help you find what is wrong.​
     
    Last edited: Feb 20, 2016
    Zoroark, Yttrium, Jethalal and 2 others like this.
  2. Spriter

    Spriter Banned

    Joined:
    Jan 19, 2014
    Messages:
    70
    Likes Received:
    0
    Very nice guide, thanks!

    How would I add more trigger words with a different response? It gives me an error when I try.

    Eg: Hello
    I say Hello

    Bye
    I say Bye
     
    Last edited: Feb 17, 2014
  3. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    You wouldn't want to have a bot pick up "Hello" and make it respond with "Hello". This will cause the code to loop endless and make you go overactive on the server.

    This is the part you want to focus on. I've mostly explain what ya need to do in "Setting Up Messages - Respond With Random Message To Certain Words" section.
    I've just realised that I forgot to mention, when you change the words you want it to pick up. Make sure they are in lowercase letters, on this line.
     
    Last edited: Feb 17, 2014
  4. Spriter

    Spriter Banned

    Joined:
    Jan 19, 2014
    Messages:
    70
    Likes Received:
    0
    Ik, lol.

    What I mean is, how do I get more than one? Just copying that code block below doesn't work.
     
  5. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    It should work since it's the same as the bots I use. Try this template to see if it solves the problem. There is now a Pikachu and Charizard bot added now.
    Code (text):
    1.  
    2. // #### #### #### #### ####
    3. // MY ADD SCRIPT - AUTO RESPOND MESSAGE
    4. // #### #### #### #### ####
    5.     // VARIABLE
    6.     // ******** ******** ********
    7.     var vMessage = message;
    8.     var vChannel = client.channelName(channel);
    9.     var vMyName = client.ownName();
    10.     var vUserSent = vMessage.substring(0, vMessage.indexOf(':'));
    11.  
    12.     // EXTRACT MESSAGE BY TAKING OUT THE NAME
    13.     if (vMessage.indexOf(':') >= 0) {vMessage = vMessage.substr(vMessage.indexOf(':') + 2);}
    14.     // SET THE MESSAGE MESSAGE TEXT TO LOWERCASE
    15.     vMessage = vMessage.toLowerCase();
    16.  
    17.     // CHANNELS ALLOWED FOR BOTS
    18.     // ******** ******** ********
    19.     var vBotChannelAllow = ["Alicorn Sandbox"];
    20.    
    21.     // CHECK CHANNELS ALLOWED
    22.     if (vBotChannelAllow.indexOf(vChannel) !== -1){
    23.         // RESPOND: My Name
    24.         if (vMessage == vMyName.toLowerCase()){
    25.             client.network().sendChanMessage(channel, "Hello.");
    26.             }
    27.        
    28.         // RESPOND TO: Pichu / Pikachu / Raichu
    29.         if (["pichu", "pikachu", "raichu"].indexOf(vMessage) !== -1){
    30.             var vName = "±Pikachu: ";
    31.             var vMsg = [];
    32.             vMsg[0] = "Thunderbolt!";
    33.             vMsg[1] = "Volt Tackle!";
    34.             vMsg[2] = "Iron Tail!";
    35.             var vRNG = Math.floor((Math.random()*vMsg.length)+0);
    36.             client.network().sendChanMessage(channel, vName + vMsg[vRNG]);
    37.             }
    38.  
    39.         // RESPOND TO: Charmander / Charmeleon / Charizard
    40.         if (["charmander", "charmeleon", "charizard"].indexOf(vMessage) !== -1){
    41.             var vName = "±Charizard: ";
    42.             var vMsg = [];
    43.             vMsg[0] = "Flamethrower!";
    44.             vMsg[1] = "Fly!";
    45.             vMsg[2] = "Slash!";
    46.             var vRNG = Math.floor((Math.random()*vMsg.length)+0);
    47.             client.network().sendChanMessage(channel, vName + vMsg[vRNG]);
    48.             }
    49.  
    50.         }
    51. // #### #### #### #### ####
    52. // END OF ADD SCRIPT
    53. // #### #### #### #### ####
    54.  
    If the problem remains, have Show Warnings enabled in Script Window. When you click OK or try to use a bot, after closing that window, it should give ya warning of some sort such as error on line message to help find the cause of error. If you still don't have any luck fixing it, send a full pastebin of all the code and I have a quick look at it.
     
  6. Shadow Sneak

    Shadow Sneak came in like

    Joined:
    Nov 28, 2013
    Messages:
    301
    Likes Received:
    27
    PO Trainer Name:
    Shadow Sneak
    Beautiful, just amazing :]
     
  7. Silone

    Silone Kanade <3

    Joined:
    Jul 31, 2013
    Messages:
    265
    Likes Received:
    3
    PO Trainer Name:
    Silone
    Code (text):
    1.  
    2. ({
    3. beforeChannelMessage: function(message, channel, html) {
    4. // #### #### #### #### ####
    5. // MY ADD SCRIPT - AUTO RESPOND MESSAGE
    6. // #### #### #### #### ####
    7.     // VARIABLES
    8.     // ******** ******** ********
    9.     var vMessage = message;
    10.     var vChannel = client.channelName(channel);
    11.     var vMyName = client.ownName();
    12.     var vUserSent = vMessage.substring(0, vMessage.indexOf(':'));
    13.  
    14.     // EXTRACT MESSAGE BY TAKING OUT THE NAME
    15.     if (vMessage.indexOf(':') >= 0) {vMessage = vMessage.substr(vMessage.indexOf(':') + 2);}
    16.     // SET THE MESSAGE MESSAGE TEXT TO LOWERCASE
    17.     vMessage = vMessage.toLowerCase();
    18.  
    19.     // CHANNELS ALLOWED FOR BOTS
    20.     // ******** ******** ********
    21.     var vBotChannelAllow = ["Alicorn Sandbox"];
    22.    
    23.     // CHECK CHANNELS ALLOWED
    24.     if (vBotChannelAllow.indexOf(vChannel) !== -1){
    25.         // RESPOND: My Name
    26.         if (vMessage == vMyName.toLowerCase()){
    27.             client.network().sendChanMessage(channel, "Hello.");
    28.             }
    29.        
    30.         // RESPOND TO: Pichu / Pikachu / Raichu
    31.         if (["pichu", "pikachu", "raichu"].indexOf(vMessage) !== -1){
    32.             var vName = "±Pikachu: ";
    33.             var vMsg = [];
    34.             vMsg[0] = "Thunderbolt!";
    35.             vMsg[1] = "Volt Tackle!";
    36.             vMsg[2] = "Iron Tail!";
    37.             var vRNG = Math.floor((Math.random()*vMsg.length)+0);
    38.             client.network().sendChanMessage(channel, vName + vMsg[vRNG]);
    39.             }
    40.         }
    41. // #### #### #### #### ####
    42. // END OF ADD SCRIPT
    43. // #### #### #### #### ####
    44. }
    45. })
    46.  
    ^ I put that if you don't want to use it with Crystal Moogles' script. You never know lol
    You just put it in script window

    EDIT: there's a sys.rand function XD
     
    Last edited: Feb 18, 2014
  8. SongSing

    SongSing KILLL

    Joined:
    Jan 2, 2013
    Messages:
    641
    Likes Received:
    191
    PO Trainer Name:
    SongSing
  9. Ssj Pokemon Trainer/Mo

    Ssj Pokemon Trainer/Mo Portuguese Legend

    Joined:
    Jan 14, 2015
    Messages:
    18
    Likes Received:
    3
    PO Trainer Name:
    [Trainer]Mo
    Thx for the help nova :smile: