SA-MP Forums Archive
Skin problem. - 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: Skin problem. (/showthread.php?tid=585768)



Skin problem. - TheLegend1 - 16.08.2015

Hello guys.
Well i was trying to make RestrictedSkins for families but its not working.
Players can select skins at clothes from that i did already at Cases.
Here is my script.

Код HTML:
 stock RestrictedSkin(id)
{
	switch(id)
		{
			case 124,129:
			{
			new playerid;
			if(PlayerInfo[playerid][playerteam]<CORLE)return SendClientError(playerid,"This skin is reserved for faction");
			return 1;
			}
			case 113,127:
			{
			new playerid;
			if(PlayerInfo[playerid][playerteam]<WARLOCK)return SendClientError(playerid,"This skin is reserved for faction");
			return 1;
			}
			}
  return 1;
}


Clothes command Where skins that i've reserved wouldnt be available here.
/clothes cmd is onlies way to set player skins.

PHP код:
COMMAND:clothes(playeridparams[])
{
    new 
tmpid=IsPlayerInBiz(playerid);
    if(
tmpid!=-&& biz[tmpid][biztype]==&& GetPlayerVirtualWorld(playerid)==biz[tmpid][vbiz])
    {
    new 
iSkin;
        if(
sscanf(params"d"iSkin)) return SCP(playerid"[skin id]");
        if(!
IsValidSkin(iSkin)) return SCP(playerid"[skin id]");
        if(!
RestrictedSkin(iSkin)) return SCP(playerid,"This skin is reserved for faction");
        new 
query[250], pname[25];
        
GetPlayerName(playeridpname24);
        
format(querysizeof(query), "UPDATE PlayerInfo SET Skin=%d WHERE user='%s'"iSkinpname);
        
mysql_query(query);
        
SetPlayerSkin(playeridiSkin);
        
PlayerInfo[playerid][Skin] = iSkin;
        return 
1;
    } 



Re: Skin problem. - Beckett - 16.08.2015

Because you are stating it wrong, you are saying that if the skin is NOT a restricted skin, then you don't allow him to.

To fix it, change this line:
pawn Код:
if(!RestrictedSkin(iSkin)) return SCP(playerid,"This skin is reserved for faction");
To this one:
pawn Код:
if(RestrictedSkin(iSkin)) return SCP(playerid,"This skin is reserved for faction");



Re: Skin problem. - X337 - 16.08.2015

You can't check every players using that function.
Use this code for "RestrictedSkin" stock
Код:
stock RestrictedSkin(playerid, id)
{
	switch(id)
	{
		case 124,129:
		{
			if(PlayerInfo[playerid][playerteam]<CORLE)
				return 0;
		}
		case 113,127:
		{
			if(PlayerInfo[playerid][playerteam]<WARLOCK)
				return 0;
		}
	}
  return 1;
}
And use this code to check :
Код:
if(!RestrictedSkin(playerid,iSkin)) return SCP(playerid,"This skin is reserved for faction");



Re: Skin problem. - Beckett - 16.08.2015

Quote:
Originally Posted by X337
Посмотреть сообщение
You can't check every players using that function.
Use this code for "RestrictedSkin" stock
Код:
stock RestrictedSkin(playerid, id)
{
	switch(id)
	{
		case 124,129:
		{
			if(PlayerInfo[playerid][playerteam]<CORLE)
				return 0;
		}
		case 113,127:
		{
			if(PlayerInfo[playerid][playerteam]<WARLOCK)
				return 0;
		}
	}
  return 1;
}
And use this code to check :
Код:
if(!RestrictedSkin(playerid,iSkin)) return SCP(playerid,"This skin is reserved for faction");
You don't need to specify a playerid in my opinion as you already have it in the command.

pawn Код:
stock RestrictedSkin(id)
{
    switch(id)
    {
        case 124,129,113,127: return 1;
        default: return 0;
    }
        return 0;
}

COMMAND:clothes(playerid, params[])
{
    new tmpid=IsPlayerInBiz(playerid);
    if(tmpid!=-1 && biz[tmpid][biztype]==9 && GetPlayerVirtualWorld(playerid)==biz[tmpid][vbiz])
    {
        new iSkin;
        if(sscanf(params, "d", iSkin)) return SCP(playerid, "[skin id]");
        if(!IsValidSkin(iSkin)) return SCP(playerid, "[skin id]");
        if(RestrictedSkin(iSkin)) return SCP(playerid,"This skin is reserved for faction");
        new query[250], pname[25];
        GetPlayerName(playerid, pname, 24);
        format(query, sizeof(query), "UPDATE PlayerInfo SET Skin=%d WHERE user='%s'", iSkin, pname);
        mysql_query(query);
        SetPlayerSkin(playerid, iSkin);
        PlayerInfo[playerid][Skin] = iSkin;
        return 1;
    }
}



Re: Skin problem. - TheLegend1 - 16.08.2015

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
Because you are stating it wrong, you are saying that if the skin is NOT a restricted skin, then you don't allow him to.

To fix it, change this line:
pawn Код:
if(!RestrictedSkin(iSkin)) return SCP(playerid,"This skin is reserved for faction");
To this one:
pawn Код:
if(RestrictedSkin(iSkin)) return SCP(playerid,"This skin is reserved for faction");
it keeps saying This skin is reserved even for an skin that isnt reserved


Re: Skin problem. - Beckett - 16.08.2015

Did you follow my last post?

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
pawn Код:
stock RestrictedSkin(id)
{
    switch(id)
    {
        case 124,129,113,127: return 1;
        default: return 0;
    }
        return 0;
}

COMMAND:clothes(playerid, params[])
{
    new tmpid=IsPlayerInBiz(playerid);
    if(tmpid!=-1 && biz[tmpid][biztype]==9 && GetPlayerVirtualWorld(playerid)==biz[tmpid][vbiz])
    {
        new iSkin;
        if(sscanf(params, "d", iSkin)) return SCP(playerid, "[skin id]");
        if(!IsValidSkin(iSkin)) return SCP(playerid, "[skin id]");
        if(RestrictedSkin(iSkin)) return SCP(playerid,"This skin is reserved for faction");
        new query[250], pname[25];
        GetPlayerName(playerid, pname, 24);
        format(query, sizeof(query), "UPDATE PlayerInfo SET Skin=%d WHERE user='%s'", iSkin, pname);
        mysql_query(query);
        SetPlayerSkin(playerid, iSkin);
        PlayerInfo[playerid][Skin] = iSkin;
        return 1;
    }
}



Re: Skin problem. - TheLegend1 - 16.08.2015

Quote:
Originally Posted by X337
Посмотреть сообщение
You can't check every players using that function.
Use this code for "RestrictedSkin" stock
Код:
stock RestrictedSkin(playerid, id)
{
	switch(id)
	{
		case 124,129:
		{
			if(PlayerInfo[playerid][playerteam]<CORLE)
				return 0;
		}
		case 113,127:
		{
			if(PlayerInfo[playerid][playerteam]<WARLOCK)
				return 0;
		}
	}
  return 1;
}
And use this code to check :
Код:
if(!RestrictedSkin(playerid,iSkin)) return SCP(playerid,"This skin is reserved for faction");
Thanks to you it helped me out


Repped both for helping