How to set a random team for a player? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to set a random team for a player? (
/showthread.php?tid=658153)
How to set a random team for a player? -
Score - 25.08.2018
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?
Re: How to set a random team for a player? -
UFF - 25.08.2018
Код:
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++;
}
Re: How to set a random team for a player? -
Beckett - 25.08.2018
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
}
Re: How to set a random team for a player? -
UFF - 25.08.2018
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.