Detect if player changed 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Detect if player changed skin (
/showthread.php?tid=277864)
Detect if player changed skin -
lukas567 - 19.08.2011
Hello everyone!
I want to know how to Detect if player changed skin. Is there any Function of that?
Re: Detect if player changed skin -
Kyle_Olsen - 19.08.2011
You can always make a function yourself.
pawn Код:
new skin1, skin2, skincheck;
OnPlayerConnect(playerid)
{
SetTimerEx(SkinCheck, 1000, true, "d", playerid);
return 1;
}
forward OnPlayerSkinChange(playerid, newskin, oldskin);
forward SkinCheck(playerid);
public SkinCheck(playerid)
{
if(skincheck == 1)
{
skin1 = GetPlayerSkin(playerid);
skincheck = 0;
if(skin1 != skin2)
{
OnPlayerSkinChange(playerid, skin2, skin1);
}
}else{
skin2 = GetPlayerSkin(playerid);
skincheck = 1;
if(skin1 != skin2)
{
OnPlayerSkinChange(playerid, skin1, skin2);
}
}
return 1;
}
public OnPlayerSkinChange(playerid, newskin, oldskin)
{
//do whatever you want here
return 1;
}
The code is not tested, but it should work.
Re: Detect if player changed skin -
lukas567 - 19.08.2011
Jesus Christ! Thanks bro! Because i used onplayerupdate to write skin id to dini save but it was very laggy. Thanks bro! Now i will write info to save when player will change skin! It will reduce lag
Re: Detect if player changed skin -
iPLEOMAX - 19.08.2011
@Kyle: I think this code won't work for all players and it executes a timer per person, may create lag...
You need to make the skin var for max players.
Re: Detect if player changed skin -
Kyle_Olsen - 20.08.2011
Hmm, you may be right...
pawn Код:
new Skin1[MAX_PLAYERS], Skin2[MAX_PLAYERS], skincheck[MAX_PLAYERS];
OnPlayerConnect(playerid)
{
SetTimerEx(SkinCheck, 1000, true, "d", playerid);
return 1;
}
forward OnPlayerSkinChange(playerid, newskin, oldskin);
forward SkinCheck(playerid);
public SkinCheck(playerid)
{
if(skincheck[playerid] == 1)
{
Skin1[playerid] = GetPlayerSkin(playerid);
skincheck[playerid] = 0;
if(Skin1[playerid] != skin2[playerid])
{
OnPlayerSkinChange(playerid, Skin2[playerid], Skin1[playerid]);
}
}else{
Skin2[playerid] = GetPlayerSkin(playerid);
skincheck[playerid] = 1;
if(Skin1[playerid] != Skin2[playerid])
{
OnPlayerSkinChange(playerid, Skin1[playerid], Skin2[playerid]);
}
}
return 1;
}
public OnPlayerSkinChange(playerid, newskin, oldskin)
{
//do whatever you want here
return 1;
}
This won't reduce lag (because the timer is still there) but it'll make it more efficient and bugless.
Re: Detect if player changed skin -
linuxthefish - 20.08.2011
THERE IS NO WAY TO CHANGE YOUR SKIN WITH CHEATS, IT'S SERVERSIDE!!
Re: Detect if player changed skin -
wouter0100 - 20.08.2011
nevermind
Re: Detect if player changed skin -
AndreT - 20.08.2011
You can re-define your SetPlayerSkin and call the public from there!
https://sampwiki.blast.hk/wiki/Keywords:Initialisers#native