Author Topic: Any tutorials for a server-sided chatbot?  (Read 834 times)

Specifically, I need:
The standard response
A way to turn responses on and off
A way to check if something someone typed would give more than one response, so that if it did this chatbot would only give the first response in the list of responses, so people couldn't spam his responses.
A way to kill the player with a custom CI deathmessage, akin to forcekilling but with any damage type.
A way to kick the player with a reason
A way to slap the player as in Munk's Server Pack, but only when the future victim said something specific

Does anyone have a tutorial or something to help me with this?
I'm trying to make a chatbot called Ted.
Among his features, if someone said "Ted" ("is my" or "'s my" or "s my") "bitch", they would be slapped with the message Ted has slapped (playername)!

It really depends on how advanced you want it. A very, very basic chatbot can be done with something simple like this:

Code: [Select]
function parseChat(%cl, %message)
{
%name = %cl.name;
switch$(getWord(%message,0))
{
case "Hello":
return "Hello, " @ %name @ ".";
case "Say":
return getWords(%message,1);
case "Bye":
return "Bye, " @ %name @ ".";
}
}
Then just feed it through a package like this:
Code: [Select]
package chatBot {
function serverCmdMessageSent(%client, %msg)
{
parent::serverCmdMessageSent(%client, %msg);
if(getWord(%msg,0) $= "Bot")
botSay(parseChat(%client, %msg));
}
};
function botSay(%msg)
{
announce("Bot\c6:" SPC %msg);
}

It really depends on how advanced you want it. A very, very basic chatbot can be done with something simple like this:

-snip
A bit more advanced, really. I want it to have toggleable responses, responses could be turned on or off if it was one specific BL_ID that was trying to toggle it. I believe I stated all that in the OP...

A bit more advanced, really. I want it to have toggleable responses, responses could be turned on or off if it was one specific BL_ID that was trying to toggle it. I believe I stated all that in the OP...
With the code he provided you can do all that
We're not going to spoon feed you all the code you know.

With the code he provided you can do all that
We're not going to spoon feed you all the code you know.
I just need to figure out how to toggle it, I'll go tear up other people's mods for the specifics of most of it.
I'm relatively new to scripting, mind you, I can generally only manage simple edits.
Of course, I might be able to piece even the toggling together by using some simple variable thing, but...

Long story short, don't assume I'll magically know all the basics.

I just need to figure out how to toggle it, I'll go tear up other people's mods for the specifics of most of it.
I'm relatively new to scripting, mind you, I can generally only manage simple edits.
Of course, I might be able to piece even the toggling together by using some simple variable thing, but...

Long story short, don't assume I'll magically know all the basics.
Code: [Select]
function serverCmdToggleChatbot(%client)
{
if(%client.isAdmin || (%client.isSuperAdmin))
{
if($Pref::Server::ChatBot::IsOn)
{
$Pref::Server::ChatBot::IsOn = false;

announce("\c6The chatbot is now \c3OFF");
}

else
{
$Pref::Server::ChatBot::IsOn = true;

announce("\c6The chatbot is now \c3ON");
}
}

else
{
messageClient(%client, '', "You must be an admin to use this command.");
}
}

I'm trying to make a chatbot called Ted.
Among his features, if someone said "Ted" ("is my" or "'s my" or "s my") "bitch", they would be slapped with the message Ted has slapped (playername)!
Easy thinking, you could do sonething like this

Code: [Select]
case "Teds my bitch"
    announce("\c6Ted has slapped \c4" @ %client @ " \c6in the face!");
    findclientbyname(%client).player.addvelocity("5 5 20");
    return;   

Idk how you get %client
Idk how to hurt the player

Easy thinking, you could do sonething like this

Code: [Select]
case "Teds my bitch"
    announce("\c6Ted has slapped \c4" @ %client @ " \c6in the face!");
    findclientbyname(%client).player.addvelocity("5 5 20");
    return;  

Idk how you get %client
Idk how to hurt the player
Code: [Select]
%Client.player.addvelocity("5 5 20");
%Client.player.addhealth(-10);