Skin resets on spawn
#1

I got an code from ladmin4v2. I edited it, and put on my other FS :
Код:
stock IsValidSkin(SkinID)
{
	if((SkinID == 0)||(SkinID == 7)||(SkinID >= 9 && SkinID <= 41)||(SkinID >= 43 && SkinID <= 64)||(SkinID >= 66 && SkinID <= 73)||(SkinID >= 75 && SkinID <= 85)||(SkinID >= 87 && SkinID <= 118)||(SkinID >= 120 && SkinID <= 148)||(SkinID >= 150 && SkinID <= 207)||(SkinID >= 209 && SkinID <= 264)||(SkinID >= 274 && SkinID <= 288)||(SkinID >= 290 && SkinID <= 299)) return true;
	else return false;
}

dcmd_skin(playerid,params[])
	 {
	    new tmp2[256], Index; tmp2 = strtok(params,Index);
		new skin = strval(tmp2);
		if(!strlen(tmp2)) return SendClientMessage(playerid, COLOR_WHITE, "USO: /skin [skin id]");
		if(!IsValidSkin(skin)) return SendClientMessage(playerid, COLOR_WHITE, "Skin Invalido");
        return SetPlayerSkin(playerid, skin);

}
It works normally, but when I die, the skin resets for the one which I chose on OnPlayerRequestClass.Does someone know how to avoid it?
Reply
#2

are you saving it to the players account file.
Reply
#3

Nope, just wants that once you change /skin ID, and after the respawn, this skin I chose keeps, not the chose one from class selection.
Reply
#4

onplayerrequestclass set the players skin to the one he chose when he did /skin id
Reply
#5

Use SetSpawnInfo or under OnPlayerSpawn callback set new player's skin (but watch out, it will crash player if you don't use SetPlayerPos before).

And here is optimized IsValidSkin function:
Код:
IsValidSkin(skinid)
{
	if(0 < skinid < 300)
	{
		switch(skinid)
		{
		    case 3, 4, 5, 6, 8, 42, 65, 74, 86,
	        119, 149, 208, 273, 289: return 0;
		}
		return 1;
	}
	return 0;
}
Reply
#6

At the skin command

pawn Код:
SetPVarInt(playerid, "Skin", string);
add at OnPlayerSpawn

pawn Код:
SetPlayerSkin(playerid, GetPVarInt(playerid, "Skin"));
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)