Block skin?
#1

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!
Reply
#2

You could simply use a global variable like:

pawn Код:
new mygvar = 0;
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
Reply
#3

That would work, but if your server saves skins on logout then I suggest you use this
PHP код:
CMD:publicworks(playeridparams[])
{
        new 
skinvar 0;//creates a variable that will see how many players have the skin
        
for(new i=0i<MAX_PLAYERSi++)//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(playeridskinid);//it gives the player the skin
        
}
        return 
1;

untested but it should work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)