SA-MP Forums Archive
Loops - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Loops (/showthread.php?tid=246216)



Loops - xir - 03.04.2011

Hello.

I need to create something like A/D

Can anyone show me a code, when a player /join a war.

They get automaticly choosed to a team

Example the Attackers got 4 players

and Defenders got 2 players, so the next player who joins gets teleported to the defenders spawn.
Like a balance code

And also, when a player type /join, it makes a straight line with some coords i got?


Re: Loops - xir - 03.04.2011

Okay, I got this for now.

pawn Код:
new Float:RandomSpawn[][4] =
{
    {2193.1692,-1143.9407,1029.7969,180.0461},
    {2221.2100,-1148.9974,1025.7969,3.0111}
};
pawn Код:
COMMAND:joinbase(playerid, params[])
{
    new rand = random(sizeof(RandomSpawn));
    SetPlayerInterior(playerid, 15);
    SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
    SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
    return 1;
}
Now it is random, but does anyone has a code like, it will balance the team, by that I mean it will join the team with lowest amount of players?


Re: Loops - admantis - 03.04.2011

pawn Код:
stock GetLowestCountTeam()
{
    new c0, c1;
    for (new i = 0; i < MAX_PLAYERS; i ++)
    {
           if (Team[i] == Team0) { c0 += 1; }
           else if (Team[i] == Team1) { c1 += 1; }
     }
     if (c0 < c1) return Team0;
     else if (c0 > c1) return Team1;
}
^ You mean this?