Restrict a player skin
#1

Hi.
I got this code, and this line doesn't seem to be working:
if(!IsACopSkin && !IsPlayerFED(playerid)) return 0;
Pawno says it has an invalid syntax / function.
Can someone help me with this please? Thanks.
Код:
	{
		new iSkin;
		if(sscanf(params, "d", iSkin)) return SCP(playerid, "[skin id]");
		if(!IsValidSkin(iSkin)) return SCP(playerid, "[skin id]");
		if(!IsACopSkin && !IsPlayerFED(playerid)) return 0;
		else
		{
        GivePlayerMoneyEx(playerid, -350);
		SetPlayerSkin(playerid, iSkin);
		dUserSetINT(PlayerName(playerid)).("skin",iSkin);
		PlayerInfo[playerid][Skin] = iSkin;
		return 1;
		}
		return 1;
	}
Reply
#2

Isacopskin is:
Код:
stock IsACopSkin(skinid)
{
if(skinid >= 280 && skinid <=289) return 1;
else return 0;
}
IsPlayerFED:
Код:
stock IsPlayerFED(playerid)
{
	new
	    isFED = 0;
	switch(PlayerInfo[playerid][playerteam])
	{
	    case COPS,EMS,POLITIC,SASF,FBI: isFED = 1;
	    default: isFED = 0;
	}
	return isFED;
}
Reply
#3

Try this.

pawn Код:
if(!IsACopSkin && !IsPlayerFED(playerid)) return 0;
GivePlayerMoneyEx(playerid, -350);
SetPlayerSkin(playerid, iSkin);
dUserSetINT(PlayerName(playerid)).("skin",iSkin);
PlayerInfo[playerid][Skin] = iSkin;
return 1;
Reply
#4

Quote:
Originally Posted by Skimmer
Посмотреть сообщение
Try this.

pawn Код:
if(!IsACopSkin && !IsPlayerFED(playerid)) return 0;
GivePlayerMoneyEx(playerid, -350);
SetPlayerSkin(playerid, iSkin);
dUserSetINT(PlayerName(playerid)).("skin",iSkin);
PlayerInfo[playerid][Skin] = iSkin;
return 1;
Nope, doesn't work sadly
Reply
#5

Have you tried to add brackets between switch cases?

Like this
Код:
case bla: { }
Reply
#6

You're not specifying the skinid on line
if(!IsACopSkin && !IsPlayerFED(playerid)) return 0;

!IsACopSkin > !IsACopSkin(skinid)
Reply
#7

Hi!

PHP код:
new iSkin;
if(
sscanf(params"d"iSkin)) return SCP(playerid"[skin id]");
if(!
IsValidSkin(iSkin)) return SCP(playerid"[skin id]");
if(!
IsACopSkin(iSkin) || !IsPlayerFED(playerid)) return 0
It should help you.

=> EDIT:
I edited something.
PHP код:
if(!IsACopSkin(iSkin) || !IsPlayerFED(playerid)) return 0
Reply
#8

Quote:
Originally Posted by Mencent
Посмотреть сообщение
PHP код:
if(skinid >= 280 || skinid <=289
The skin ID should be in range of 280-289 so AND must be used.

Like Golden96 said, you don't use a parameter for IsACopSkin in the statement and both can be written a little better:
pawn Код:
IsACopSkin(skinid)
{
    return (280 <= skinid <= 289);
}

IsPlayerFED(playerid)
{
    switch (PlayerInfo[playerid][playerteam])
    {
        case COPS, EMS, POLITIC, SASF, FBI: return 1;
    }
    return 0;
}
Reply
#9

Oh well. Thank you. I have not worked for a long time with PAWN.
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The skin ID should be in range of 280-289 so AND must be used.

Like Golden96 said, you don't use a parameter for IsACopSkin in the statement and both can be written a little better:
pawn Код:
IsACopSkin(skinid)
{
    return (280 <= skinid <= 289);
}

IsPlayerFED(playerid)
{
    switch (PlayerInfo[playerid][playerteam])
    {
        case COPS, EMS, POLITIC, SASF, FBI: return 1;
    }
    return 0;
}
This fixed it, THANKS!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)