Block 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: Block skin? (
/showthread.php?tid=329197)
Block skin? -
Gooday - 27.03.2012
Hello i got a CMD /publicworks who gives a skin. How could i block it? Like if there are more that 5 players with that skin it can't be used
/PUBLICWORKS
*More that 5 players*
(INFO) tHRE are aleady 5 players with this skin, You can't use!
Re: Block skin? -
vyper - 27.03.2012
You could simply use a global variable like:
Then when someone uses that command you can increase that:
pawn Код:
CMD:publicworks(playerid, params[]) // ZCMD
{
if(mygvar == 5) return SendClientMessage(playerid, -1, "(INFO) tHRE are aleady 5 players with this skin, You can't use!");
// your code blah blah
SetPlayerSkin(playerid, skinid); // under this add:
mygvar++;
return 1;
}
This is just the idea of how to make it... the rest I hope you know
Re: Block skin? -
new121 - 27.03.2012
That would work, but if your server saves skins on logout then I suggest you use this
PHP код:
CMD:publicworks(playerid, params[])
{
new skinvar = 0;//creates a variable that will see how many players have the skin
for(new i=0; i<MAX_PLAYERS; i++)//loops through each player
{
new skin;//creates a variable to store the skinid
skin = GetPlayerSkin(i);//gets the players skin and stores it to the variable "skin"
if(skin == skinid))//checks if the skin the player has is the same as your desired skinid
{
skinvar +=1;// if it is it adds +1 to the skinvar
}
}
if(skinvar >= 5)// if the skinvar is greater then or = to 5
{
SendClientMessage(playerid, -1, " There are more then five players with this skin!");// no skin for them
}
else// else if it is less then 5
{
SetPlayerSkin(playerid, skinid);//it gives the player the skin
}
return 1;
}
untested but it should work