SA-MP Forums Archive
Last Player Slot for Admins - 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: Last Player Slot for Admins (/showthread.php?tid=271423)



Last Player Slot for Admins - Rolyy - 24.07.2011

Title says it all, I am in search for an simple Script Code, Since I am releasing a very small script with about 17 player slots. I want the last player slot only remained for Administrators. I'm already experienced with Variables that can be used to count players for OnPlayerConnect and Disconnect. But I'm wondering if there is something more simple-r than that.

Example:
16 out of the 17 players are connected, the 17th player attempting to connect. Reject connection if AdminLevel is 0 or Accept connection if username has AdminLevel is 1 or higher. If one connected player leaves, (15/17 players connected) make all connections acceptable untill players connected is 16 again.

Meaning the last player slot is only available for Administrators.

Thanks in Adanced,
Rolyy.


Re: Last Player Slot for Admins - MoroDan - 24.07.2011

PHP код:
// Top of script
new countPlayers 0;
// OnPlayerConnect
if(countPlayers == 16)
{
    
ReadPlayerData(playerid);
    if(!
PData[playerid][pAdmin])
    {
        
SendClientMessage(playerid, -1"[SERVER]: Sorry, this slot is reserved for admin !");
        return 
Kick(playerid);
    }
}
countPlayers++;
// OnPlayerDisconnect
countPlayers--; 



Re: Last Player Slot for Admins - Vince - 24.07.2011

Newly connecting players always fill up the lowest player slots. So you could just do:

pawn Код:
if(playerid == GetMaxPlayers()-1) // -1 because if you have 17 slots, id 16 will be the highest playerid



Re: Last Player Slot for Admins - ReD_Boii - 14.10.2012

I have knowledge and I have money