error 001: expected token: ";", but found ")"
#1

hello im getting an error in my /givegun command.

i try to make so that no one is allowed to give some weapons like Knife and Minigun, (maybe more)

this is my command:

Код:
CMD:givegun(playerid, params[])
{
    new giveplayerid, wepID, ammo, weapon[50], string[128];
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "You are not authorized to use that command!");
    if(sscanf(params, "ud", giveplayerid, wepID, ammo)) SendClientMessage(playerid, COLOR_RED, "[USAGE]: /givegun [name/id] [weapon id] [ammo]");
    if(PlayerInfo[playerid][pGuns] = 4 && PlayerInfo[playerid][pGuns] = 38)<<< Line2234
	{
		SendClientMessageEx(playerid, COLOR_RED, "You are not allowed to give a knife,minigun!");
		return 1;
	}
    if(wepID < 1 || wepID > 46) SendClientMessage(playerid, COLOR_RED, "Invalid weapon id.");
    if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_RED, "Player not found.");
    if(giveplayerid == playerid)
    {
        GetWeaponName(wepID, (weapon), sizeof(weapon));
        GivePlayerWeapon(playerid, wepID, ammo);
        format(string, sizeof(string), "You have given yourself a %s with %d ammo.", weapon, ammo);
        SendClientMessage(playerid, COLOR_YELLOW, string);
    }
    else
    {
        GetWeaponName(wepID, (weapon), sizeof(weapon));
        format(string, sizeof(string), "You have given %s [%d] a %s with %d ammo.", pName(giveplayerid), giveplayerid, weapon, ammo);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        format(string, sizeof(string), "Admin %s [%d] has given you a %s with %d ammo.", pName(playerid), playerid, weapon, ammo);
        SendClientMessage(giveplayerid, COLOR_LIGHTGREEN, string);
        GivePlayerWeapon(giveplayerid, wepID, ammo);
        new astring[100];
        format(astring, sizeof(astring), "Admin %s [%d] has given %s [%d] a %s with %d ammo.", pName(playerid), playerid, pName(giveplayerid), giveplayerid, weapon, ammo);
        SendAdminMessage(COLOR_GREY, astring);
    }
    return 1;
}
Errors:
Код:
(2234) : warning 211: possibly unintended assignment
(2234) : warning 211: possibly unintended assignment
(2234) : error 022: must be lvalue (non-constant)
(2234) : warning 215: expression has no effect
(2234) : error 001: expected token: ";", but found ")"
(2234) : error 029: invalid expression, assumed zero
(2234) : fatal error 107: too many error messages on one line

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


4 Errors.
Reply
#2

Hello!

PHP код:
if(PlayerInfo[playerid][pGuns] = && PlayerInfo[playerid][pGuns] = 38
to
PHP код:
if(PlayerInfo[playerid][pGuns] == && PlayerInfo[playerid][pGuns] == 38
Reply
#3

Thanks for the help m8
Reply
#4

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hello!

PHP код:
if(PlayerInfo[playerid][pGuns] = && PlayerInfo[playerid][pGuns] = 38
to
PHP код:
if(PlayerInfo[playerid][pGuns] == && PlayerInfo[playerid][pGuns] == 38
I think you mean:
PHP код:
if(PlayerInfo[playerid][pGuns] == && PlayerInfo[playerid][pGuns] == 38); 
Reply
#5

Quote:
Originally Posted by Ahmad45123
Посмотреть сообщение
I think you mean:
PHP код:
if(PlayerInfo[playerid][pGuns] == && PlayerInfo[playerid][pGuns] == 38); 
That would give error 036: empty statement. Mencent's code is just fine.
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
That would give error 036: empty statement. Mencent's code is just fine.
Ooooo.. Just noticed its an IF statement...
Sorry, was multitasking at that moment.
Reply
#7

And why are we using '&&' here? A single variable can't have two values...
Not to mention the sscanf line is incorrect.

EDIT:
To me, the correct code is:
pawn Код:
CMD:givegun(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "You are not authorized to use that command!");
    new giveplayerid, wepID, ammo;
    if(sscanf(params, "uii", giveplayerid, wepID, ammo)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /givegun [name/id] [weapon id] [ammo]");
    if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_RED, "Player not found.");
    if(wepID == 4 || wepID == 38) return SendClientMessageEx(playerid, COLOR_RED, "You are not allowed to give a knife or minigun!");
    if(!(1 <= wepID <= 18 || 22 <= wepID <= 46)) return SendClientMessage(playerid, COLOR_RED, "Invalid weapon id.");
    new string[128], weapon[25];
    GetWeaponName(wepID, weapon, sizeof(weapon));
    if(giveplayerid == playerid)
    {
        format(string, sizeof(string), "You have given yourself a %s with %d ammo.", weapon, ammo);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        format(string, sizeof(string), "Admin %s [%d] has given themselves a %s with %d ammo.", pName(playerid), playerid, weapon, ammo);
        SendAdminMessage(COLOR_GREY, string);
    }
    else
    {
        format(string, sizeof(string), "You have given %s [%d] a %s with %d ammo.", pName(giveplayerid), giveplayerid, weapon, ammo);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        format(string, sizeof(string), "Admin %s [%d] has given you a %s with %d ammo.", pName(playerid), playerid, weapon, ammo);
        SendClientMessage(giveplayerid, COLOR_LIGHTGREEN, string);
        format(string, sizeof(string), "Admin %s [%d] has given %s [%d] a %s with %d ammo.", pName(playerid), playerid, pName(giveplayerid), giveplayerid, weapon, ammo);
        SendAdminMessage(COLOR_GREY, string);
    }
    GivePlayerWeapon(playerid, wepID, ammo);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)