How to check if team is full and disable the player from spawning.
#1

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".
Reply
#2

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

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.
Reply
#4

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;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)