Randomize a few players [+REP]
#4

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.

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];
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...

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...
}
Now we need to spawn player responsibly in OnPlayerSpawn:

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(arenaPlayers[playerid][isInArena]) {
        // Spawn player in arena...
    }
    else {
        // Spawn player normally...
    }
}
And don't forget to do this when forcing players to leave the arena, like in OnPlayerDisconnect:

pawn Код:
if(arenaPlayers[playerid][isInArena]) {
    arenaPlayers[playerid][isInArena] = false;
   
    if(arenaPlayers[playerid][arenaType] == A_TYPE_HUMAN)
        arenaHumans--;
    else
        arenaZombies--;
}
Reply


Messages In This Thread
Randomize a few players [+REP] - by Lirbo - 23.07.2016, 22:26
Re: Randomize a few players [+REP] - by Threshold - 24.07.2016, 02:14
Re: Randomize a few players [+REP] - by WhiteGhost - 24.07.2016, 02:35
Re: Randomize a few players [+REP] - by Crayder - 24.07.2016, 02:43
Re: Randomize a few players [+REP] - by Threshold - 24.07.2016, 03:25
Re: Randomize a few players [+REP] - by SickAttack - 24.07.2016, 05:46
Re: Randomize a few players [+REP] - by Crayder - 24.07.2016, 06:17
Re: Randomize a few players [+REP] - by SickAttack - 24.07.2016, 07:01
Re: Randomize a few players [+REP] - by Crayder - 24.07.2016, 15:04
Re: Randomize a few players [+REP] - by SickAttack - 24.07.2016, 22:09

Forum Jump:


Users browsing this thread: 1 Guest(s)