24.07.2016, 02:43
(
Последний раз редактировалось Crayder; 24.07.2016 в 04:07.
)
Well, definitely not what WhiteGhost said...
You're going to need to keep track of the zombie and human counts, and adjust as players are added.
Now with that we can keep track of how many players are in which group and which players are in at all.
Say for example you have "arenajoin" and "arenaleave" commands...
Now we need to spawn player responsibly in OnPlayerSpawn:
And don't forget to do this when forcing players to leave the arena, like in OnPlayerDisconnect:
You're going to need to keep track of the zombie and human counts, and adjust as players are added.
pawn Код:
#define A_TYPE_HUMAN 0
#define A_TYPE_ZOMBIE 1
enum E_ARENA_PLAYER_STUFF {
bool:isInArena,
arenaType
}
new arenaHumans,
arenaZombies,
arenaPlayers[MAX_PLAYERS][E_ARENA_PLAYER_STUFF];
Say for example you have "arenajoin" and "arenaleave" commands...
pawn Код:
CMD:arenajoin(playerid, params[]) {
if(arenaPlayers[playerid][isInArena])
return SendClientMessage(playerid, -1, "You are already in the arena");
arenaPlayers[playerid][isInArena] = true;
if((float(arenaHumans) / float(arenaZombies)) < (2.0 / 1.0)) // 2:1 ratio is 33% zombies
{ // Too many zombies, add human
arenaPlayers[playerid][arenaType] = A_TYPE_HUMAN;
arenaHumans++;
}
else
{ // Too many humans, add zombie
arenaPlayers[playerid][arenaType] = A_TYPE_ZOMBIE;
arenaZombies++;
}
// Now spawn player into arena...
}
CMD:arenaleave(playerid, params[]) {
if(!arenaPlayers[playerid][isInArena])
return SendClientMessage(playerid, -1, "You aren't in the arena");
arenaPlayers[playerid][isInArena] = false;
if(arenaPlayers[playerid][arenaType] == A_TYPE_HUMAN)
arenaHumans--;
else
arenaZombies--;
// Now spawn player into real world...
}
pawn Код:
public OnPlayerSpawn(playerid)
{
if(arenaPlayers[playerid][isInArena]) {
// Spawn player in arena...
}
else {
// Spawn player normally...
}
}
pawn Код:
if(arenaPlayers[playerid][isInArena]) {
arenaPlayers[playerid][isInArena] = false;
if(arenaPlayers[playerid][arenaType] == A_TYPE_HUMAN)
arenaHumans--;
else
arenaZombies--;
}