SA-MP Forums Archive
How to check if team is full and disable the player from spawning. - 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: How to check if team is full and disable the player from spawning. (/showthread.php?tid=519942)



How to check if team is full and disable the player from spawning. - DemME - 16.06.2014

I just wanna do if one of the teams at the character selection is full ( and please tell me how to do a limit to them ) so it will not let the player to spawn and will send him a message that he couldn't to respawn due "Reason".


Re: How to check if team is full and disable the player from spawning. - RajatPawar - 16.06.2014

Keep a counter, ( an array of size MAX_TEAMS ) check it when a player spawns and if it's MORE than "X" number of players, then disallow him, else increment it. Simple!


Re: How to check if team is full and disable the player from spawning. - DemME - 16.06.2014

Quote:
Originally Posted by RajatPawar
Посмотреть сообщение
Keep a counter, ( an array of size MAX_TEAMS ) check it when a player spawns and if it's MORE than "X" number of players, then disallow him, else increment it. Simple!
I'm kinda new developer at pawn, just wanted someone to explain me with examples, he'll be rep'ed.


Re: How to check if team is full and disable the player from spawning. - Sandiel - 16.06.2014

I'm gonna go ahead and guess you're working under the OnPlayerRequestClass callback.
As the previous comment said, keep a counter in which's value changes depending on the players in this team, for example if someone enters the team, it'll be +1 for the count, when someone leaves/changes teams, it'll be -1 for the count.
Then, if the team is full and he pressed "Spawn" simply make an if statement in which you change the value of "return" to 0 or 1, 0 being unable to spawn and 1 being able to spawn

pawn Код:
if(COUNTER_VARIABLE == 10) // with 10 being max number of people you want in the team
{
       SendClientMessage(playerid, COLOR_WHITE, "This team is full, you cannot spawn, change your team please bla bla bla");
       return 0; // doesn't spawn
}
else
{
       return 1;
}