Randomize a few players [+REP]
#6

This will help you out:
pawn Код:
// ** INCLUDES

#include <a_samp>

// ** DEFINES

// *** TEAMS

#define TEAM_HUMAN 0
#define TEAM_ZOMBIE 1

// ** VARIABLES

// *** GLOBAL VARIABLES

// **** GENERAL

new gPlayerCount,
gPlayerIDs[MAX_PLAYERS];

// *** PER-PLAYER VARIABLES

// **** GENERAL

new pTeam[MAX_PLAYERS];

// ** MAIN

main()
{
    print("Loaded \"make_players_humans_and_zombies.amx\".");

    gPlayerCount = 8;

    new human_count, zombie_count, count, selected;
    GetHumanAndZombieCount(human_count, zombie_count);

    printf("%d human(s), %d zombie(s)", human_count, zombie_count);

    for(new i = 0, j = GetPlayerPoolSize(); i <= j; i ++)
    {
        if(!IsPlayerConnected(i))
        {
            continue;
        }

        gPlayerIDs[count ++] = i;

        pTeam[playerid] = TEAM_HUMAN;
    }

    for(new i = 0; i < zombie_count; i ++)
    {
        selected = random(count);

        pTeam[gPlayerIDs[selected]] = TEAM_ZOMBIE;

        gPlayerIDs[selected] = gPlayerIDs[count - 1];

        count --;
    }
}

// ** CALLBACKS

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

// ** FUNCTIONS

stock GetHumanAndZombieCount(&human_count, &zombie_count)
{
    zombie_count = floatround((gPlayerCount / 2), floatround_floor);
    human_count = (gPlayerCount - zombie_count);
    return 1;
}
Don't just copy/paste.
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: 2 Guest(s)