Author Topic: ChatBot help  (Read 3160 times)

I need some help with my chatbot scripts,
Code: [Select]
package Gravbot {
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%fmsg) {
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%fmsg)
  if (%msg $= "Rofl") {
  if (%name $= "xXGravity DogXx") {
commandToServer('messageSent',"Don't roll on the floor, it's not healthy.");
     }
}

}
};
activatePackage(Gravbot);
and yes, xXGravity BotXx is my new name, i have no idea how to change my name on the forums, any help please (this is my first post)


OMG i meant xXGravity DogXx No second post for you either xD  :cookie:

Belongs in "Coding Help" Board.

Belongs in Coding Help.
Code: [Select]
package Gravbot {

function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);

if(%name $= "xXGravity DogXx")
{
if (%msg $= "Rofl")
{
commandToServer('messageSent', "Don't roll on the floor, it's not healthy.");
}
}

}

}; activatePackage(Gravbot);

-snip-
Tell him what you fixed, instead of simply fixing it for him



Anyways, %msg is undefined, change the second %fmsg in the function argument list and parent call to %msg
Also, learn proper indentation, it will make reading your code a lot easier

Optionally, the two ifs can also be combined into one:
Code: [Select]
if (%msg $= "Rofl" && %name $= "xXGravity DogXx")
{
commandToServer('messageSent',"Don't roll on the floor, it's not healthy.");
}




Also, the usual disclaimer about chatbots: Test them on your own server, or the server of someone who you know doesn't mind, then once you've gotten the practice, turn them off; they're annoying and many people will ban you for using them

well thats all fine and dandy, but i cant seem to put it on to the actual game idk if its someting with V20 of blockland or what

well thats all fine and dandy, but i cant seem to put it on to the actual game idk if its someting with V20 of blockland or what
1. Make sure it is packaged correctly.
2. Make sure the folder is in My Documents/Blockland/Add-Ons(or for Mac /Users/yourUsername/Documents/Blockland/Add-Ons).

does it have to be zipped?
it is supposed to be Client_ correct?

never mind, it works now, thanks jes! but one more thing id like to know, how do you add multiple phrases?

You needed to have a ; on the parent() line.
Code: [Select]
//Fixed
parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);
//Not Fixed
parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)

never mind, it works now, thanks jes! but one more thing id like to know, how do you add multiple phrases?


Noedit: Use case: or use switch$ or use else if()

uhh FFSO im fairly new to scripting i have no idea what you mean

Noedit: Use case: or use switch$ or use else if()
switch and case are part of the same structure


uhh FFSO im fairly new to scripting i have no idea what you mean


Code: [Select]
package Gravbot
{
function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
Parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);
if(%name $= "xXGravity DogXx")
{
switch$(%msg)
{
case "Rofl":
%reply = "Don't roll on the floor, it's not healthy.";
case "Hi":
%reply = "Hello.";
case "Bye":
%reply = "Good bye.";
default:
return;
}
commandtoserver('messagesent',%reply);
}
}
};
activatePackage(Gravbot);


I wish this forum had a sort of ranking system, I would nominate you for the most patient and helpful person on this forum, especially in Coding Help. Every time I ever browse that forum, I see your accurate and helpful responses. I think I speak for all the beginning scripters and all the more advanced scripters when I say thank you for making all of our lives easier.