[HELP]How to block a player becoming grove if groves full
#1

Hello,
I have a GangWar server
And most of the time the people are all ther same gang
so more than half are aztecs
and other ones ar other gangs
now i want to make a limit that not more than 4 guys can enter a gang
i am using gTeam[MAX_PLAYERS]
So if somebody can explain me how to do this Thanks
Reply
#2

Omg plzz people i know one of you knows and i really need this
Reply
#3

Код:
new Player;
new GroveMembers = 0;

for(Player = 0; Player < GetMaxPlayers(); Player++)
{
	if(IsPlayerConnected(Player) && gTeam[Player] == TEAM_GROVE)
	{
	  GroveMembers++;
	}
}

if(GroveMembers > 4)
{
  SendClientMessage(playerid, 0xFFFFFFFF, "Grove is full!");
  return 1;
}
Reply
#4

Код:
static gTeam[MAX_PLAYERS];

new GrovePeople;

#define GROVE 1

public OnPlayerRequestClass(playerid, classid)
{
	if(gTeam[playerid] == GROVE) GrovePeople--;
	if(classid == changethistoagrovestreetskin)
	{
	  if(GrovePeople > 3)
	  {
	    SendClientMessage(playerid, COLOR_RED, "You cannot join this team because it is too full.");
	    return 0;
	  }
	  else
	  {
	    GrovePeople++;
	    gTeam[playerid] = GROVE;
	    return 1;
	  }
	}
	return 1;
}
it's not the most efficient code, not even sure if it works
Reply
#5

why do people put gTeam as a global static? seems un-needed and bad if you actually are using multiple files (this doesn't mean includes, this means another .pwn that you tell the compiler to compile at the same time).
Reply
#6

Does this work?
Please get back to me :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)