Author Topic: This is annoying me, serverCmd Error?  (Read 1206 times)

Every time I run this:

serverCmdSave(%client){
   %varg = %client.brickGroup.vargroup;
   for(%vars=0;%vars < $numvars;%vars++){
   %name = $saveload[%vars];
   %varg.saveVariable("Client", %name, %client);
   }
   commandtoclient(%client,'centerPrint',"\c6Your progress has been saved!",3);
   }

The console gives me this:

Syntax Errors with ## On both sides of error halt.

serverCmdSave(%client){#
#

   %varg = %client.brickGroup.vargroup;
   for(%vars=0;%vars < $numvars;%vars++){
   %name = $saveload[%vars];
   %varg.saveVariable("Client", %name, %client);
   }
   commandtoclient(%client,'centerPrint',"\c6Your progress has been saved!",3);
   }

I see no syntax errors, and the lines above have none either. Please help.

Every time I run this:

serverCmdSave(%client){
   %varg = %client.brickGroup.vargroup;
   for(%vars=0;%vars < $numvars;%vars++){
   %name = $saveload[%vars];
   %varg.saveVariable("Client", %name, %client);
   }
   commandtoclient(%client,'centerPrint',"\c6Your progress has been saved!",3);
   }

The console gives me this:

Syntax Errors with ## On both sides of error halt.

serverCmdSave(%client){#
#

   %varg = %client.brickGroup.vargroup;
   for(%vars=0;%vars < $numvars;%vars++){
   %name = $saveload[%vars];
   %varg.saveVariable("Client", %name, %client);
   }
   commandtoclient(%client,'centerPrint',"\c6Your progress has been saved!",3);
   }

I see no syntax errors, and the lines above have none either. Please help.

you are missing a function functionname()

you just have functionName()

and in the future, can we make our code a bit more neat?

Code: [Select]
function serverCmdSave(%client)
{
   %varg = %client.brickGroup.vargroup;
   
   for(%vars=0;%vars < $numvars;%vars++)
   {
%name = $saveload[%vars];
%varg.saveVariable("Client", %name, %client);
   }
   
   commandtoclient(%client,'centerPrint',"\c6Your progress has been saved!",3);
}

Good hell I'm tired.

Thanks for quick reply! :D!

Oh stuff I need sleep :C

Lol, dont worry, ive done that too, lol

Lol, dont worry, ive done that too, lol

Hehe, your name is syntax.... :P

New problem:

When I say /addvar Varname
Nothing happens.

Code: [Select]
function serverCmdAddVar(%client, %word1, %word2, %word3){
if(!%client.isSuperAdmin){
commandtoclient(%client,'centerPrint',"\c6You must be a \c3Super Admin\c6 to use this command.",3);
return;
}
if(%word1 $= ""){
commandtoclient(%client,'centerPrint',"\c6You must supply a variable name with up to 2 spaces.",3);
return;
}
for(%vars=0;%vars < $numvars;%vars++){
if($saveload[%vars] == %word1){
commandtoclient(%client,'centerPrint',"\c6Var already added!",3);
return;
}
if(!%word2 $= ""){
if($saveload[%vars] == %word1 SPC %word2){
commandtoclient(%client,'centerPrint',"\c6Var already added!",3);
return;
}
}
if(!%word3 $= ""){
if($saveload[%vars] == %word1 SPC %word2 SPC %word3){
commandtoclient(%client,'centerPrint',"\c6Var already added!",3);
return;
}
}

}
}

$numvars isn't defined before your "for" statement.

Also, clean up your code as much as possible to make it easier for others to help understand and fix your code. Get your indentations right, and sometimes noting what your doing helps also.

Hm. If the function is stated before the variable, it messes up?

$numvars is a global variable, it can be declared anywhere in the script, as long as the function using it is called after the variable is defined.



in the future, can we make our code a bit more neat?

Sorry, I suck at cleaning things. Especially my room.