| Blockland Forums > Modification Help |
| This is annoying me, serverCmd Error? |
| << < (2/3) > >> |
| Pew446:
New problem: When I say /addvar Varname Nothing happens. --- Code: ---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; } } } } --- End code --- |
| lilboarder32:
$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. |
| Pew446:
Hm. If the function is stated before the variable, it messes up? |
| Headcrab Zombie:
$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. |
| Pew446:
Oh. Thanks. |
| Navigation |
| Message Index |
| Next page |
| Previous page |