Poll

Who is the best scripter that can teach me?

Danny Boy
Truce
Xalos
jes00

Author Topic: My chatbot is not working  (Read 8211 times)


New code, that I fixed, yet its not working

Code:

Code: [Select]
// Made by ThinkInvisible, BLID 14511, helped and edited by Deoxys & One Noob, BLID 30436

package GunGame {
     $rouletteBarrel = getrandomnum(1,7);
     $rouletteScoreCombo = 0;
     $rouletteLastShoot = NaN;
     function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg) {
          parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
          if (striPos(%msg,"Roulette") > 0) {
               if (striPos(%msg,"Dare the odds") > 0) {
               if ($rouletteLastShoot != %name) {
                    commandToServer('messageSent',%name@" spins the barrel and pulls the trigger...");
                    %tempval = getrandomnum(1,7);
                    if (%tempval = $rouletteBarrel) {
                         $rouletteScore[%name] ++;
                         export("$rouletteScore*","add-ons/client_roulette/scores.cs");
                         $rouletteLastShoot = NaN;
                         $rouletteBarrel = getRandomNum(1,7);
                         commandToServer('messageSent',"NoobBot: *BLAM*... "@%name@" got hit! "@%name@" has been hit "@$rouletteScore[%name]@" times.");
} else {
commandToServer('messageSent',"NoobBot: *Chk*... "@%name@" missed the bullet! Nice one there, winner...");
$rouletteLastShoot = %name;
}
} else {
commandToServer('messageSent',"NoobBot: What? "@%name@", you can't dare your odds twice in a row! Let somebody else have a turn, please, for the sake of fun.");
}
}
}
}
};
activatePackage(GunGame);

There, please tell me whats wrong

the function is getRandom, not getRandomNum


And the tutorial you are using is pretty bad

you should indent it decently to make it easier to read

you should indent it decently to make it easier to read
He just copied think invisible's stuff straight from the tut

you should indent it decently to make it easier to read
Much better :P
Code: [Select]
// Made by ThinkInvisible, BLID 14511, helped and edited by Deoxys & One Noob, BLID 30436

package GunGame
{
$rouletteBarrel = getRandom(1, 7);
$rouletteScoreCombo = 0;
$rouletteLastShoot = Nan;

function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
{
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);

if(strPos(%msg,"Roulette") > 0 && (strPos(%msg,"Dare the odds") > 0))
{
if($rouletteLastShoot != %name)
{
commandToServer('messageSent', %name SPC "spins the barrel and pulls the trigger...");

%tempVal = getRandom(1, 7);

if(%tempVal = $rouletteBarrel)
{
$rouletteScore[%name] ++;

export("$rouletteScore*","config/Roulette/scores.cs");
$rouletteLastShoot = Nan;
$rouletteBarrel = getRandom(1, 7);

commandToServer('messageSent',"NoobBot: *BLAM*..." SPC %name SPC "got hit!" SPC %name SPC "has been hit" SPC $rouletteScore[%name] SPC "times.");
}
else
{
commandToServer('messageSent',"NoobBot: *Chk*..." SPC %name SPC "missed the bullet! Nice one there, winner...");

$rouletteLastShoot = %name;
}
}
else
{
commandToServer('messageSent',"NoobBot: What?" SPC %name @ ", you can't dare your odds twice in a row! Let somebody else have a turn please, for the sake of fun.");
}
}
}
};
activatePackage(GunGame);

And the tutorial you are using is pretty bad

I know that now, why, oh WHY did I use that one.

I want one from Truce!

Hes much better

I know that now, why, oh WHY did I use that one.

I want one from Truce!

Hes much better
he'd probably make one if he knew you wanted one, he seems to do that sort of thing

but he probably doesn't know you want one

Much better :P
Code: [Select]
// Made by ThinkInvisible, BLID 14511, helped and edited by Deoxys & One Noob, BLID 30436

package GunGame
{
$rouletteBarrel = getRandom(1, 7);
$rouletteScoreCombo = 0;
$rouletteLastShoot = Nan;

function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
{
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);

if(strPos(%msg,"Roulette") > 0 && (strPos(%msg,"Dare the odds") > 0))
{
if($rouletteLastShoot != %name)
{
commandToServer('messageSent', %name SPC "spins the barrel and pulls the trigger...");

%tempVal = getRandom(1, 7);

if(%tempVal = $rouletteBarrel)
{
$rouletteScore[%name] ++;

export("$rouletteScore*","config/Roulette/scores.cs");
$rouletteLastShoot = Nan;
$rouletteBarrel = getRandom(1, 7);

commandToServer('messageSent',"NoobBot: *BLAM*..." SPC %name SPC "got hit!" SPC %name SPC "has been hit" SPC $rouletteScore[%name] SPC "times.");
}
else
{
commandToServer('messageSent',"NoobBot: *Chk*..." SPC %name SPC "missed the bullet! Nice one there, winner...");

$rouletteLastShoot = %name;
}
}
else
{
commandToServer('messageSent',"NoobBot: What?" SPC %name @ ", you can't dare your odds twice in a row! Let somebody else have a turn please, for the sake of fun.");
}
}
}
};
activatePackage(GunGame);

Whats the SPC for?

I still have syntax errors

Whats the SPC for?

I still have syntax errors
@ = connector.
SPC = connector with a space.
TAB = connector with a tab.

I did not check it for errors.

EDIT: Found an error,
Code: [Select]
if(%tempVal = $rouletteBarrel) must be
Code: [Select]
if(%tempVal == $rouletteBarrel)
« Last Edit: April 05, 2012, 05:18:56 PM by jes00 »

connector
The proper term is concatenator

EDIT: Found an error,
Code: [Select]
if(%tempVal = $rouletteBarrel) must be
Code: [Select]
if(%tempVal == $rouletteBarrel)
While it is an error, it's a logic error, not a syntax error.




Deoxys, just look in the console, it tells you (almost) exactly where the error is, look at that and see if you can practice fixing it yourself, if you can't figure it out that copy and paste it here, instead of making everyone either look through the entire code for it, or run it and look at the console themself.
« Last Edit: April 05, 2012, 06:26:34 PM by Headcrab Zombie »

OK, I'm making a chatbot from scratch...

Is there such thing as %server?

Like this, "NoobBot: Welcome to (servernamehere), (namegoeshere)!"

OK, I'm making a chatbot from scratch...

Is there such thing as %server?

Like this, "NoobBot: Welcome to (servernamehere), (namegoeshere)!"
Use $ServerInfo::Name to get the server name and I'm not helping you to make an auto greeter.