How to set a random team for a player?
#1

Hello, recently i was trying to create an event system everything else works except one thing, i can't set a random team for each player.

For example when player 1 joins the event, he gets into team A, player 2 Team B, player 3 Team A, player 4 Team B like this.

Can someone give me a code example how to do that?
Reply
#2

Код:
new PlayersTeam1=0;
new PlayersTeam2=0;

    if(PlayersTeam1 <= PlayersTeam2)
    {
          SetPlayerTeamA(playerid);
    }
   else if(PlayersTeam2 <= PlayersTeam1)
   {
           SetPlayerTeamB(playerid);
    }

SetPlayerTeamA(playerid)
{

// codes for Team A

PlayersTeam1++;
}

SetPlayerTeamB(playerid)
{
// codes for Team B
PlayersTeam2++;
}
Reply
#3

pawn Код:
#define MAX_TEAMS 4
new rteam = random(MAX_TEAMS);
switch(rteam)
{
    case 0: // Team 1
    case 1: // Team 2
    case 2: // Team 3
    case 3: // Team 4
}
Reply
#4

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
pawn Код:
#define MAX_TEAMS 4
new rteam = random(MAX_TEAMS);
switch(rteam)
{
    case 0: // Team 1
    case 1: // Team 2
    case 2: // Team 3
    case 3: // Team 4
}
Well bro,
He meant, 2 random teams for a event system.
Quote:

when player 1 joins the event, he gets into team A, player 2 Team B, player 3 Team A, player 4 Team B like this.

and the code which you provided will not work for perfect balance for teams.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)