Author Topic: Chatbot fail. [Fixed]  (Read 726 times)

« Last Edit: April 11, 2009, 03:41:36 PM by gamefandan »

getSubStr("hi",0,1) = "h"

oh it's only the first letter?

Use it like GetSubStr(%message, %startletter, %length);
Your only getting a length of one, you want a length of two.

Also, it'd end up as:
Gamerbot: Hey there.
Person: Hi
« Last Edit: April 11, 2009, 03:35:42 PM by laremere »

I just decided to whip this up for no particularly important reason. But when I typed hi into the chat, nothing happened, does anyone know what I did wrong? Any help would be highly appreciated.

Code: [Select]
package woot
{
function servercmdmessagesent(%client,%message)
{
                parent::serverCmdMessageSent(%client,%message);
if(strlwr(getSubStr(%message,0,2)) $= "hi")
{
messageall('',"\c3Gamerbot\c6: Hey there.");
}
//moved
}
};
activatepackage(woot);
getsubstr(%text,start,end); I believe, so 0,2 will grab the first 2 letters.

It didn't even react when I tried, I just changed it, but I do get an error in the console so the server DID react sort of. :D

Code: [Select]
package woot
{
function servercmdmessagesent(%client,%message)
{
if(getSubStr("hi",0,1) = "h")
{
messageall('',"<color:FFFF00>Gamerbot<color:FFFFFF>: Hey there.");
}
parent::serverCmdMessageSent(%client,%message);
}
};
activatepackage(woot);

Also lare after I fix the problem of actually getting Gamerbot to say Hey there how do I make it so he says it after the client?
[/s]
« Last Edit: April 11, 2009, 03:40:25 PM by gamefandan »

Look two posts up from this one.