SA-MP Forums Archive
expected token: ";", but found ")" - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: expected token: ";", but found ")" (/showthread.php?tid=598547)



expected token: ";", but found ")" - E7mad - 14.01.2016

What's wrong in this?

PHP код:
CMD:giveweaponall(playeridparams[])
{
    if(
pInfo[playerid][Admin] < 4) return NotAdminMSG(playerid);
    new 
string[128], weapidammo;
    if(
sscanf(params"ii"weapidammo)) return SCM(playeridCOLOR_WHITE""WORD_ERROR"/giveweaponall [WEAPON_ID] [AMMO]");
    if(
ammo <= 0) return SCM(playeridCOLOR_WHITE""WORD_ERROR"Minimum ammo is 1.");
    if(
weapid <= || weapid == 19 || weapid == 20 || weapid == 21 || weapid 46) return SCM(playeridCOLOR_WHITE""WORD_ERROR"Invalid weapon ID.");
    if(
weapid == 35 || weapid == 36 || weapid == 37 || weapid == 38 || weapid == 39 || weapid == 40) return SCM(playeridCOLOR_WHITE""WORD_ERROR"You are not allowed to give this weapons.");
    
/*line 127*/ format(stringsizeof(string), ""WORD_ADMIN"Everyone has been given a %s by %s(%d)."WeapName(weapid), PlayerName(playerid), playerid); //line 127
    
SCMToAll(COLOR_WHITEstring);
    for(new 
0MAX_PLAYERSi++)
    {
        
GivePlayerWeapon(playeridweapidammo);
    }
    return 
1;

Код:
C:\Program Files\MyServer\pawno\include\required/admin_commands.inc(127) : error 012: invalid function call, not a valid address
C:\Program Files\MyServer\pawno\include\required/admin_commands.inc(127) : warning 215: expression has no effect
C:\Program Files\MyServer\pawno\include\required/admin_commands.inc(127) : error 001: expected token: ";", but found ")"
C:\Program Files\MyServer\pawno\include\required/admin_commands.inc(127) : error 029: invalid expression, assumed zero
C:\Program Files\MyServer\pawno\include\required/admin_commands.inc(127) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.



Re: expected token: ";", but found ")" - thefirestate - 14.01.2016

Try to compile without WORD_ADMIN

Also, the loop will basically give MAX_PLAYERS' loop to the one who executed the command. So this will give him the gun MAX_PLAYERS' define times instead of the actual players, you should change it to GivePlayerWeapon(i, blahblah);

Another note, use foreach or at least a loop like

for(new i = 0; i <= GetPlayerPoolSize(); i++) both would be better than MAX_PLAYERS.


Re: expected token: ";", but found ")" - -CaRRoT - 14.01.2016

Show us your WORD_ADMIN code as the rest of your command uses WORD_ERROR and it compiles fine because I see nothing wrong with the rest of the code.

Also as the post above me said, replace
Код:
playerid
with
Код:
i
Like this:
Код:
GivePlayerWeapon(i, weapid, ammo);



Re: expected token: ";", but found ")" - radiobizza - 14.01.2016

try to change this:
PHP код:
if(ammo <= 0) return SCM(playeridCOLOR_WHITE""WORD_ERROR"Minimum ammo is 1."); 
to this:
PHP код:
if(ammo <= || ammo your_value) return SCM(playeridCOLOR_WHITE""WORD_ERROR"Minimum ammo is 1."); 



Re: expected token: ";", but found ")" - E7mad - 14.01.2016

Okay, the problem is in WeapName(weapid).
here's it:
Код:
new WeapName[47][20] =
{
	"Fist","Brass Knuckles","Golf Club","Nightstick","Knife","Basebal Bat","Shovel","Pool Cue","Katana","Chainsaw","Double-ended Dildo","Dildo","Vibrator",
	"Silver Vibrator","Flowers","Cane","Grenade","Tear Gas","Molotv Cocktail","?","?","?","9mm","Silenced 9mm","Desert Eagle","Shotgun","Sawnoff-Shotgun",
	"Combat Shotgun","Micro-SMG","MP5","Ak-47","M4","Tec9","Country Rifle","Sniper Rifle","RPG","HS-RPG","Flame-Thrower","Minigun","Satchel Charge","Detonator",
	"Spray Can","Fire Extinguisher","Camera","Night Goggles","Thermal Goggles","Parachute"
};



Re: expected token: ";", but found ")" - Eth - 14.01.2016

try this:

pawn Код:
new WeapName[] =
{
    "Fist","Brass Knuckles","Golf Club","Nightstick","Knife","Basebal Bat","Shovel","Pool Cue","Katana","Chainsaw","Double-ended Dildo","Dildo","Vibrator",
    "Silver Vibrator","Flowers","Cane","Grenade","Tear Gas","Molotv Cocktail","?","?","?","9mm","Silenced 9mm","Desert Eagle","Shotgun","Sawnoff-Shotgun",
    "Combat Shotgun","Micro-SMG","MP5","Ak-47","M4","Tec9","Country Rifle","Sniper Rifle","RPG","HS-RPG","Flame-Thrower","Minigun","Satchel Charge","Detonator",
    "Spray Can","Fire Extinguisher","Camera","Night Goggles","Thermal Goggles","Parachute"
};



Re: expected token: ";", but found ")" - LetsOWN[PL] - 14.01.2016

Quote:
Originally Posted by Eth
Посмотреть сообщение
try this:

pawn Код:
new WeapName[] =
{
    "Fist","Brass Knuckles","Golf Club","Nightstick","Knife","Basebal Bat","Shovel","Pool Cue","Katana","Chainsaw","Double-ended Dildo","Dildo","Vibrator",
    "Silver Vibrator","Flowers","Cane","Grenade","Tear Gas","Molotv Cocktail","?","?","?","9mm","Silenced 9mm","Desert Eagle","Shotgun","Sawnoff-Shotgun",
    "Combat Shotgun","Micro-SMG","MP5","Ak-47","M4","Tec9","Country Rifle","Sniper Rifle","RPG","HS-RPG","Flame-Thrower","Minigun","Satchel Charge","Detonator",
    "Spray Can","Fire Extinguisher","Camera","Night Goggles","Thermal Goggles","Parachute"
};
What?
You see no difference between 2d and 1d array?
It must be
pawn Код:
WeapName[][]
otherwise
pawn Код:
printf("%s", WeapName[2]);
will print out s instead of Golf Club.. Guess why.

On topic: Yeah, try to compile w/o "WORD_ADMIN"