SA-MP Forums Archive
Restrict a player skin - 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: Restrict a player skin (/showthread.php?tid=603948)



Restrict a player skin - justjamie - 29.03.2016

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;
	}



Re: Restrict a player skin - justjamie - 29.03.2016

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;
}



Re: Restrict a player skin - Skimmer - 29.03.2016

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;



Re: Restrict a player skin - justjamie - 29.03.2016

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


Re: Restrict a player skin - Skimmer - 29.03.2016

Have you tried to add brackets between switch cases?

Like this
Код:
case bla: { }



Re: Restrict a player skin - Golden96 - 29.03.2016

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

!IsACopSkin > !IsACopSkin(skinid)


Re: Restrict a player skin - Mencent - 29.03.2016

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



Re: Restrict a player skin - Konstantinos - 29.03.2016

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;
}



Re: Restrict a player skin - Mencent - 29.03.2016

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


Re: Restrict a player skin - justjamie - 29.03.2016

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!