SA-MP Forums Archive
team balancing? - 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: team balancing? (/showthread.php?tid=126217)



team balancing? - Rubennnnn - 07.02.2010

Hi,

I'm busy with my gamemode and I wonder if there's something that can check if the team is uneven and then it tells you when you want to spawn that the team is full. E.g:
Team 1 has 3 members playing
Team 2 has 4 members playing
You want to join team 2 but that is 'full'. How to make the client show you a message that team 2 is full when you want to spawn?


Re: team balancing? - deather - 07.02.2010

Use Search

But for now look at this TOPIC


Re: team balancing? - Rubennnnn - 07.02.2010

Quote:
Originally Posted by |)ЂΩ†{−}ЂR™ – Dare To Die
Use Search

But for now look at this TOPIC
If you look at the latest post is says that it isn't solved yet.


Re: team balancing? - Universal - 07.02.2010

You can simply add global arrays to the top of the script:

Код:
new Team1Players;
new Team2Players;
And if someone wants to join, you can:

Код:
...


if(!strcmp(cmdtext,"/team1",6,true)){
if(Team1Players==5)return SendClientMessage(playerid,WHITE,"Team 1 has enough players.");
if(Team1Players !=5){
Team1Players++;
SetPlayerColor(playerid,BLUE);
GivePlayerWeapon(playerid,24,500);
}
return 1;
}

...
You can try with the samples i gave you. I guess you cought my drift

If you want the textdraw to show how many players each team has, you can:

In the top of the script:

Код:
new Text:Teams;
forward TeamText;
On the callback, OnPlayerConnect:

Код:

new string[30]; format(string,sizeof(string),"Team1: %d ~n~Team2:%d",Team1Players,Team2Players);
Teams = TextDrawCreate(150,200,string);
TextDrawShowForPlayer(playerid,Teams);
SetTimer("TeamText",2000,true);
Now, at the end of the script:

Код:
public TeamText()
{
new string[30]; format(string,sizeof(string),"Team1: %d ~n~Team2:%d",Team1Players,Team2Players);
TextDrawSetString(Teams,string);
}



Re: team balancing? - MadeMan - 07.02.2010

Change your team defines

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    new Team1, Team2;
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && i != playerid)
        {
            if(gTeam[i] == TEAM1) Team1++;
            else if(gTeam[i] == TEAM2) Team2++;
        }
    }
    if(gTeam[playerid] == TEAM1 && Team1 > Team2)
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "This team is full!");
        return 0;
    }
    else if(gTeam[playerid] == TEAM2 && Team2 > Team1)
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "This team is full!");
        return 0;
    }
    return 1;
}



Re: team balancing? - Rubennnnn - 07.02.2010

Made, yours doesn't work


Re: team balancing? - MadeMan - 07.02.2010

Quote:
Originally Posted by Rubennnnn
Made, yours doesn't work
You are supposed to change that.


Re: team balancing? - Rubennnnn - 07.02.2010

Quote:
Originally Posted by MadeMan
Quote:
Originally Posted by Rubennnnn
Made, yours doesn't work
You are supposed to change that.
Into what?


Re: team balancing? - IcyBlight - 07.02.2010

Quote:
Originally Posted by Rubennnnn
Quote:
Originally Posted by MadeMan
Quote:
Originally Posted by Rubennnnn
Made, yours doesn't work
You are supposed to change that.
Into what?
Edit team names into your own. I.e.: Team1 to TEAM_COPS and Team2 to TEAM_GANG