Author Topic: Rock Paper Scissors Bot won't work  (Read 942 times)



I made a short little bot in a second, and when I try to execute it, it fails to work. I went over it and looked at it but it still won't work.


Code: [Select]
package Chatbot
{
        $wins = 0;
        $losses = 0;
function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);
if(%name !$= $Pref::Player::NetName)
return;
}
if(%msg $= "RPSBot" && getWordCount(%msg) == 2)
{
%attack[1] = "rock";
%attack[2] = "scissors";
%attack[3] = "paper";
$fattack = random($attack)
$word = getWord(%msg,2);
switch$(%word)
{
case "rock"
{
if($fattack $= "rock"
{
commandToServer('messageSent',"We both chose rock.. I guess it's a tie. You have "@$wins@" wins and "@$losses@" losses.");

}
if($fattack $= "scissors";
{
commandToServer('messageSent',"Man, I lost. I chose scissors. You have "@$wins@" wins and "@$losses@" losses.");
$wins += 1;
}
if($fattack $= "paper";
{
commandToServer('messageSent',"Yay! I chose paper! You have "@$wins@" wins and "@$losses@" losses");
$losses += 1;
}
case "scissors"
{
if($fattack $= "rock"
{
commandToServer('messageSent',"Yay! I chose rock! You have "@$wins@" wins and "@$losses@" losses.");
$losses += 1;
}
if($fattack $= "scissors";
{
commandToServer('messageSent',"We both chose scissors.. I guess it's a tie. You have "@$wins@" wins and "@$losses@" losses.");
}
if($fattack $= "paper";
{
commandToServer('messageSent',"Man, I lost. I chose paper. You have "@$wins@" wins and "@$losses@" losses");
$wins += 1;
}
case "paper"
{
if($fattack $= "rock"
{
commandToServer('messageSent',"Man, I lost. I chose rock. You have "@$wins@" wins and "@$losses@" losses.");
$wins += 1;
}
if($fattack $= "scissors";
{
commandToServer('messageSent',"Yay! I chose scissors! You have "@$wins@" wins and "@$losses@" losses.");
$losses += 1;
}
if($fattack $= "paper";
{
commandToServer('messageSent',"We both chose paper.. I guess it's a tie. You have "@$wins@" wins and "@$losses@" losses");
}
}
}
}
« Last Edit: September 21, 2012, 09:04:40 PM by PurpleMetro »

Do not define variable inside the package that's not inside a function and restart bl.


nothing happened..?
It said the p was missing, that's why that happened, but check the post again.

Do not define variable inside the package that's not inside a function and restart bl.

weird, it has the P in there when I am looking in the script. I don't know whats going on
« Last Edit: September 21, 2012, 09:15:11 PM by PurpleMetro »

I like how you quoted the part where he told you exactly what you were doing wrong and you didn't fix it

I like how you quoted the part where he told you exactly what you were doing wrong and you didn't fix it
dude it's like that i'm not kidding
in the script file

but in the console
it doesn't have a p

You quoted exactly what I said to do then you just showed us that you did absolutely nothing about it.
Do what I said to do and it will work.

dude it's like that i'm not kidding
in the script file
-snip-
but in the console
it doesn't have a p
are you dumb or something?
TAKE THE VARIABLE DECLARATIONS OUT OF THE PACKAGE AND TRY AGAIN

are you dumb or something?
TAKE THE VARIABLE DECLARATIONS OUT OF THE PACKAGE AND TRY AGAIN
He doesn't know how to script. He's closing if statements with semicolons.

I'll have to take a look through this tommorow to get out all the errors.

He doesn't know how to script. He's closing if statements with semicolons.

I'll have to take a look through this tommorow to get out all the errors.
Oh my. Well, we've experienced this before with purplemetro, I have no idea why he still tries to script if he can't get through the most basic snippets of code

I'm trying to fix it, can somebody tell me how I can fix this


Code: [Select]
$wins = 0;
$losses = 0;
package Chatbot
{
function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);
if(%name !$= $Pref::Player::NetName)
return;
if(%msg $= "RPSBot" && getWordCount(%msg) == 1)
{
%attack[1] = "rock";
%attack[2] = "scissors";
%attack[3] = "paper";
$fattack = random($attack)
$word $= getWord(%msg,2);
switch$($word)
{
case "rock"
{
if($fattack $= "rock")
{
commandToServer('messageSent',"We both chose rock.. I guess it's a tie. You have "@$wins@" wins and "@$losses@" losses.");

}
if($fattack $= "scissors")
{
commandToServer('messageSent',"Man, I lost. I chose scissors. You have "@$wins@" wins and "@$losses@" losses.");
$wins += 1;
}
if($fattack $= "paper")
{
commandToServer('messageSent',"Yay! I chose paper! You have "@$wins@" wins and "@$losses@" losses");
$losses += 1;
}
case "scissors"
{
if($fattack $= "rock")
{
commandToServer('messageSent',"Yay! I chose rock! You have "@$wins@" wins and "@$losses@" losses.");
$losses += 1;
}
if($fattack $= "scissors")
{
commandToServer('messageSent',"We both chose scissors.. I guess it's a tie. You have "@$wins@" wins and "@$losses@" losses.");
}
if($fattack $= "paper")
{
commandToServer('messageSent',"Man, I lost. I chose paper. You have "@$wins@" wins and "@$losses@" losses");
$wins += 1;
}
case "paper"
{
if($fattack $= "rock")
{
commandToServer('messageSent',"Man, I lost. I chose rock. You have "@$wins@" wins and "@$losses@" losses.");
$wins += 1;
}
if($fattack $= "scissors")
{
commandToServer('messageSent',"Yay! I chose scissors! You have "@$wins@" wins and "@$losses@" losses.");
$losses += 1;
}
if($fattack $= "paper")
{
commandToServer('messageSent',"We both chose paper.. I guess it's a tie. You have "@$wins@" wins and "@$losses@" losses");
}
}
}
}
« Last Edit: September 21, 2012, 09:35:29 PM by PurpleMetro »

Go read this, you have absolutely no idea what you're doing

Go read this, you have absolutely no idea what you're doing
That didn't help me solve the problem at all.
I need help with line 16.

as it says in the console.
But I do not know a way to fix it so somebody help

That didn't help me solve the problem at all.
I need help with line 16.

as it says in the console.
But I do not know a way to fix it so somebody help
word = not word $=.