Author Topic: A chatbot  (Read 2633 times)

YES! Its working now! Now i know how to make a simple chatbot command and stuff. Thanks for the help! I will not lock it though because i might need help later.

You got it, but you don't need a package just to declare a function.

It will work, but it's not needed.



function servercmdHelp(%client)
{
    messageClient(%client, '', "\c3MattBot\c6: Hey");
}

« Last Edit: August 09, 2014, 06:07:32 PM by Zeblote »

What about multiple functions?

Right, i am making a simple help command for my bot but it kinda covers the whole screen with words. How would i make it so it looks a bit better?
Quote
package chatbot {
function ServerCmdHelp(%client)
{
   messageClient(%client,'',"\c5MBot\c6: Hello! Here is a list of handy commands you might need: 1. /dup: gives you the duplicator tool to duplicate builds 2. /clearbricks: Clears all of your bricks! Please type /help2 for page 2 ");
}


};
activatePackage(chatbot);

What about multiple functions?
You can use multiple functions just fine. Packages are made for extending the behavior of existing functions, there should be a tutorial around somewhere.

Right, i am making a simple help command for my bot but it kinda covers the whole screen with words. How would i make it so it looks a bit better?
You can split the text to multiple lines.

Either do it like this with line breaks:

function servercmdHelp(%client)
{
    messageClient(%client, '', "\c5MBot\c6: Hello! Here is a list of handy commands you might need:\n1. /dup: gives you the duplicator tool to duplicate builds\n2. /clearbricks: Clears all of your bricks!\nPlease type /help2 for page 2 ");
}


You can also make that bit more readable:

function servercmdHelp(%client)
{
    messageClient(%client, '', "\c5MBot\c6: Hello! Here is a list of handy commands you might need:"
        NL "1. /dup: gives you the duplicator tool to duplicate builds"
        NL "2. /clearbricks: Clears all of your bricks!"
        NL "Please type /help2 for page 2");
}


Or do it like this, sending multiple messages:

function servercmdHelp(%client)
{
    messageClient(%client, '', "\c5MBot\c6: Hello! Here is a list of handy commands you might need:");
    messageClient(%client, '', "\c61. /dup: gives you the duplicator tool to duplicate builds");
    messageClient(%client, '', "\c62. /clearbricks: Clears all of your bricks!");
    messageClient(%client, '', "\c6Please type /help2 for page 2");
}


Thank you for that. It now looks alot nicer now. Btw i prefer having it packaged so i can turn it off and on easily
« Last Edit: August 09, 2014, 06:40:53 PM by matthew »

How would i make it tell the time?

How would i make it tell the time?
getDateTime() will return the current time of the server. Note that clients live in different timezones and you can't know how late it is for them.

« Last Edit: August 09, 2014, 07:00:09 PM by matthew »

How would i make a superadmin only command?

How would i make a superadmin only command?
Use conditional statements (if, then, else, etc.), like so:

function serverCmdBlah(%client)
{
    if(!%client.isSuperAdmin)
        return;
    messageClient(%client, '', "\c3MattBot\c6: Hello!");
}

You can sometimes read code as if it's as simple as basic English.
if(!%client.isSuperAdmin) - if the client is NOT (!) super admin, return - go back and don't continue.

Ah. How would i make it so i could talk through the bot like this /bottalk Hello!

Ah. How would i make it so i could talk through the bot like this /bottalk Hello!
Well, when using functions, they can pass up to 20 arguments. In this case, you are using a serverCmd (a /command), and the first argument is the client that typed the command. When you want to do something like "/bottalk Hello this is MattBot", or something like that, each word is taken as an argument. For example:

function serverCmdbotTalk(%client, %a0, %a1, %a2, %a3)
{
    %args = %a0 SPC %a1 SPC %a2 SPC %a3; // SPC means "space" - so here, it's %a0 %a1 %a2 %a3
    messageAll('', %args); //message everyone in the server what you typed
}

That was just an example, and as stated above, you can have way more arguments.

Like this? :
Quote
function serverCmdbottalk(%client, %a0, %a1, %a2, %a3)
{
    if(!%client.isSuperAdmin)
        return;
   
   %args = %a0 SPC %a1 SPC %a2 SPC %a3;   
    messageAll(%client, '', "\c5MBot\c6:%args");
}
Does not seem to work for me
« Last Edit: August 09, 2014, 07:39:29 PM by matthew »

Like this? :  Does not seem to work for me
When using quotes and then variables ($ or %) - you have to separate the text in the quotes from the variable using SPC, TAB, or @. Using the @ character will put the characters next to the ones in the quotes, while SPC puts a space between it, and TAB puts a tab between the two (obviously). For example:

%args = %a0 SPC %a1 SPC %a2 SPC %a3;
messageAll('', "\c2MattBot\c6:" SPC %args); //puts a space between %args and "MattBot"