This should work. Let me know if you don't understand something and i'll explain.
To play with it, you or someone would type RSBot choiceofrockpaperorscissorshe re.
$RPSBot::wins = 0;
$RPSBot::losses = 0;
$RPSBot::ties = 0;
package RPSbot
{
function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);
%msg = stripMlControlChars(%msg);
if(getWord(%msg,0) $= "RPSBot")
{
%playerChoice = getWord(%msg,1);
if(%playerChoice $= "rock" || %playerChoice $= "paper" || %playerChoice $= "scissors")
{
%c[0] = "rock";
%c[1] = "paper";
%c[2] = "scissors";
%botChoice = %c[getRandom(0,2)];
%winner = RPSBot_getWinner(%botChoice,%playerChoice);
if(%winner $= "1")
{
$RPSBot::wins++;
commandToServer('messageSent',"I win, "@%botChoice@" beats "@%playerChoice@"!");
}
else
if(%winner $= "2")
{
$RPSBot::losses++;
commandToServer('messageSent',"You win, "@%playerChoice@" beats "@%botChoice@"!");
}
else
if(%winner $= "0")
{
$RPSBot::ties++;
commandToServer('messageSent',"Tie!");
}
else
echo("ERROR");
}
}
}
};
activatePackage(RPSBot);
function RPSBot_GetWinner(%this,%that)
{
if(%this $= "" || %that $= "")
return -1;
if(%this $= %that)
return 0;
if(%this $= "rock" && %that $= "scissors")
return 1;
if(%this $= "scissors" && %that $= "paper")
return 1;
if(%this $= "paper" && %that $= "rock")
return 1;
return 2;
}