error 029: invalid expression, assumed zero
#1

I have this error:
pawn Код:
(4198) : error 029: invalid expression, assumed zero
This is line 4198
pawn Код:
else
This is the script its in
pawn Код:
if(pickupid == copdutypoint)
    if(GetPlayerTeam(playerid) == 100)  GivePlayerWeapon(playerid, 3, 1); GivePlayerWeapon(playerid, 22, 99); GivePlayerWeapon(playerid, 27, 50);
    else
    SendClientMessage(playerid, 0xAA3333AA, "You can't go on duty! You're not a cop");
Its in OnPlayerPickupPickup I have two others, its fine.. I think its the multiple functions im trying to give this one?
Reply
#2

try this one

pawn Код:
if(pickupid == copdutypoint)
    if(GetPlayerTeam(playerid) == 100) //get the player team if cop
    {
    GivePlayerWeapon(playerid, 3, 1);//weapon 1 you set
   GivePlayerWeapon(playerid, 22, 99); //weapon 2 you set
   GivePlayerWeapon(playerid, 27, 50);//weapon 2 you set
    }
    SendClientMessage(playerid, 0xAA3333AA, "You can't go on duty! You're not a cop");// message if they are not cop
    return 1;
}
Reply
#3

pawn Код:
if(pickupid == copdutypoint)
{
    if(GetPlayerTeam(playerid) == 100)
    {//you need opening and closing braces if more than one statement follows the if
        GivePlayerWeapon(playerid, 3, 1);
        GivePlayerWeapon(playerid, 22, 99);
        GivePlayerWeapon(playerid, 27, 50);
    }
    else//only one statement following the else, so braces can be omitted.
        SendClientMessage(playerid, 0xAA3333AA, "You can't go on duty! You're not a cop");
}
You could also use comma's without braces but it looks ugly IMO.

EDIT:
Quote:
Originally Posted by pds2012
pawn Код:
if(pickupid == copdutypoint)
    if(GetPlayerTeam(playerid) == 100) //get the player team if cop
    {
    GivePlayerWeapon(playerid, 3, 1);//weapon 1 you set
   GivePlayerWeapon(playerid, 22, 99); //weapon 2 you set
   GivePlayerWeapon(playerid, 27, 50);//weapon 2 you set
    {
    SendClientMessage(playerid, 0xAA3333AA, "You can't go on duty! You're not a cop");// message if they are not cop
    return 1;
}//wheres the opening brace?
Your missing braces again.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)