Author Topic: Chat Bots.  (Read 2511 times)

Chatbot's can do some amazing thing's. but they are very limited.
(also the reason i'm making this is because I am tired of seeing Dexx's chatbot posts.)

1st, if a server has a mod that a client can access, or needed to be admin with, and also involves chatbots, they can use it.
But, like I said before, your limited.

2nd, don't forget around with chatbots alot because if its annoying enough then it will piss people off.

Anyways, basic code for chatbots and whatever.

Code: [Select]
function clientcmdchatmessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
          parent::clientcmdchatmessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);
          if(getWord(%msg,0)$="!test")
          {
                    commandtoserver('messagesent',"Test!");
          }
}

That's your basic code.
All it does is reads the first line and makes sure its !test.
The bad thing about this: its vulnerable for any user to use. To make it for you to use and only you, do this:

Code: [Select]
function clientcmdchatmessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
          parent::clientcmdchatmessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);
          if(%name $="NAMEHERE")
          {
                    if(getWord(%msg,0)$="!test")
                    {
                              commandtoserver('messagesent',"Test.");
                    }
          }
}

There's your basic stuff for chat bots. Now for a simple get random which uses something different from clientcmdchatmessage.
Code: [Select]
function nmh_type::send(%this)
{
          %msg=%this.getvalue();
          parent::send(%this);
          if(getWord(%msg,0)$="!getrandom")
          {
                    %min = getword(%msg,1);
                    %max = getword(%msg, 2);
                    %result = getrandom(%min, %max);
                    commandtoserver('messagesent',%result);
          }
}

As for letting other people being able to use your chatbot, tell me if i'm wrong and correct me, but i'm pretty sure this is how you do it
for specific players to use your chatbot (by name)

Code: [Select]
function clientcmdchatmessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
          parent::clientcmdchatmessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);
          if(%name $="Frostwind" || %name $="Whomever")
          {
                    if(getWord(%msg,0)$="!test")
                    {
                              commandtoserver('messagesent',"It was a success!");
                    }
          }
}
Correct me if i'm wrong.

Chat bot calculator stuff.
Ok, you need to use nmh_type::send for this but if your getting good with chatbots you should know.
Hint: It has to do with variables like %var1 = getWord(%msg,1);
%var2 = getWord(%msg,2);
%var3 = getWord(%msg,3);
while var2 is being the sign of: + - / *

I expect you to be able to script that. It's simple. Really.
(if you cant then go away.)
You're on your own.

IF YOU HAVE ANY SUGGESTION'S ON CHAT BOT'S, YOUR WELCOME TO POST AND I MIGHT PUT IT UP HERE IF USEFUL.
« Last Edit: January 06, 2013, 10:03:43 PM by Frostwind »

[size=100pt]WILL EDIT LATER TODAY.[/size]
Please do not attempt to make ridiculously large, colored, and bolded text. Anyway; this information was already readily available with the aid of . In my opinion, we should just redirect people to the search feature when they ask questions like "how do you make a chat bot?"

Code: [Select]
function clientcmdmessagesent(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
          if(%name $="NAMEHERE")
          {
                    parent::clientcmdmessagesent(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);
                    if(getWord(%msg,0)$="!test")
                    {
                              commandtoserver('messagesent',"Test.");
                    }
          }
}
Umm. No. Not unless you want to only see your chat messages. Take the parent and take it out of the if(%name $= "NAMEHERE") statement.

Also. It would be better to do if(%name $= $Pref::Player::NetName) because than it you don't need to change the code when you change your name.

You just broke the whole chat function.


The whole. loving. Chat function.


Are you MARBLE MAN? Edit no you are not

You just broke the whole chat function.
The whole. loving. Chat function.
Actually no he didn't cuz the function he packaged doesn't even exist

Actually no he didn't cuz the function he packaged doesn't even exist
Yes it doesIt doesn't
« Last Edit: January 02, 2013, 02:47:16 PM by Zeblote »

Yes it does

Nah


There's a serverCmdMessageSent
And there's a clientCmdChatMessage
But there is no clientCmdMessageSent

« Last Edit: January 02, 2013, 02:47:26 PM by Zeblote »

Then why am I getting an "Unable to find function" error on a clean installation?
Oh right, because there isn't

Quote
Date Registered:    December 30, 2012, 01:12:35 PM
Who the forget are you
« Last Edit: January 02, 2013, 11:40:26 AM by Headcrab Zombie »

Headcrab is right, you're handicapped. Please go away if you're just going to troll in Coding Help, this isn't the proper board to forget with people.

Headcrab is right, you're handicapped. Please go away if you're just going to troll in Coding Help, this isn't the proper board to forget with people.
Wait, what.
I'm pretty sure I used that function in some mods

Edit: WOOPS, I must have confused that with something else.
You're right, no such function.
Sorry.
« Last Edit: January 02, 2013, 02:46:54 PM by Zeblote »

If you wanted a function like clientCmdMessageSent you'd have to use NMH_Type::send(%this), but it's fine if you just made a mistake.

Ok ok, guys I forgeted up the code, I was tired and wasent thinking, god, im fixing it now you fixomaniacs.
« Last Edit: January 05, 2013, 07:11:25 PM by Frostwind »

Please do not attempt to make ridiculously large, colored, and bolded text. Anyway; this information was already readily available with the aid of . In my opinion, we should just redirect people to the search feature when they ask questions like "how do you make a chat bot?"
Some people dont learn how to click search though.

To make it for you to use and only you, do this:

Code: [Select]
function clientcmdchatmessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
          parent::clientcmdchatmessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);
          if(%name $="NAMEHERE")
          {
                    if(getWord(%msg,0)$="!test")
                    {
                              commandtoserver('messagesent',"Test.");
                    }
          }
}

Er, not quite. The server could easily make mask a message as coming from you. Use NMH_Type::send instead.