Author Topic: Chat Bot Help  (Read 4306 times)

Seem to be having yet another problem:

A problem with this

Code: [Select]
package ChatBotRegister
{
function function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
Parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if(%name $= "¥ola")
{
switch$(%msg)
{

case "ChatBot On":
$ChatBot::On = true;

case "ChatBot Off":
$ChatBot::On = false;

}
}
}
};
activatepackage (ChatBotRegister);



Yikes.
SYNTAX ERROR INBOUND

Why won't this work?

Code: [Select]
package ChatBotGreet
{
function newChatHud_addLine(%text)
{

Parent::newChatHud_addLine(%text);
if(%text $="connected.")
{
if($ChatBot::On)
{
%num = getrandom(1,5);
commandtoserver('messagesent', "ChatBot: @ %num);
}
}
}
};
activatepackage (ChatBotGreet);





Full Script:

Code: [Select]
package ChatBot
{
function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
Parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if($ChatBot::On)
{
switch$(%msg)
{

case "Hey":
commandToServer('messagesent', "ChatBot: Hey");

}
}
}
};

package ChatBotRegister
{
function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
Parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if(%name $= "¥ola")
{
switch$(%msg)
{

case "ChatBot On":
$ChatBot::On = true;

case "ChatBot Off":
$ChatBot::On = false;

}
}
}
};
activatepackage (ChatBotRegister);

package ChatBotGreet
{
function newChatHud_addLine(%text)
{

Parent::newChatHud_addLine(%text);
if(%text $="connected.")
{
if($ChatBot::On)
{
%num = getrandom(1,5);
commandtoserver('messagesent', "ChatBot: @ %num);
}
}
}
};
activatepackage (ChatBotGreet);

if(%text.getword(%text.getwordcount()-1) $="connected." && stripos(%text.getword(0), :) == -1)

the second part is to keep people from triggering it randomly

it won't greet people with a : in their name though but that's derpy anyways

No I mean it won't work at all. Not one part of it

I thought it might be the connected stuff, so I deleted that and tried it but it still won't work

Exact code I'm using:

Code: [Select]
package ChatBot
{
function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
Parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if($ChatBot::On)
{
switch$(%msg)
{

case "Hey":
commandToServer('messagesent', "ChatBot: Hey");

}
}
}
};
activatepackage (ChatBot);

package ChatBotRegister
{
function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
Parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if(%name $= "¥ola")
{
switch$(%msg)
{

case "ChatBot On":
commandToServer('messagesent', "ChatBot: On"):
$ChatBot::On = true;

case "ChatBot Off":
commandToServer('messagesent', "ChatBot: On"):
$ChatBot::On = false;

}
}
}
};
activatepackage (ChatBotRegister);

No, use onServerMessage for any sort of auto greeter that should never ever be made.

No, use onServerMessage for any sort of auto greeter that should never ever be made.

... Explain how to use it, give me an example?


I still don't understand why it will not work

Yes, if you do %name $= "¥ola"
Noo, if(%name $= $Pref::Player::NetName) works way better.

...

I'm not asking for tips as to how to make this 'better'
I'm asking as to why it won't work


activatepackage shouldn't have a space between the actual function called and the (). pretty sure that's your problem.