Team Balancer
#1

I've developed my own team balancer but my friends can join the same team as mine.
pawn Код:
new tcount, acount;
//NOTE: Sorted script
//onplayerrequestspawn
    if(class2[playerid] == 2 && GetPlayerTeam(playerid) == 2) {
    tcount--;
    acount++;
    return 1; }
   
    if(class1[playerid] == 1 && GetPlayerTeam(playerid) == 1) { //The GetPlayerTeam is when you press F4 and select a new class
    acount--;
    tcount++;
    return 1; }
   
    if(class1[playerid] == 1) {
    tcount++;
    return 1; }
   
        // new code
    if(class1[playerid] == 1 || class2[playerid] == 1) {
    if(acount > tcount)
    {
        SendClientMessage(playerid, -1, "Team is "COL_VIOLET"full"COL_WHITE".");
        return 0;
    }
    else
    {
        SendClientMessage(playerid, -1, "Team is "COL_VIOLET"full"COL_WHITE".");
        return 0;
    } }
   
    if(class2[playerid] == 1) {
    acount++;
    return 1; }
//OnPlayerRequestClass
    if(classid == 0) {
    GameTextForPlayer(playerid, "~r~Terrorist", 9999999, 6);
    class1[playerid] = 1;
    class2[playerid] = 0;
    class3[playerid] = 0;
    class4[playerid] = 0; }
    if(classid == 1) {
    GameTextForPlayer(playerid, "~b~Police", 9999999, 6);
    class1[playerid] = 0;
    class2[playerid] = 1;
    class3[playerid] = 0;
    class4[playerid] = 0; }
    SetPlayerTeamFromClass(playerid, classid);
    SetPlayerPos(playerid, 259.9881,2904.1746,7.2830);
    SetPlayerFacingAngle(playerid, 0.2501);
    SetPlayerCameraPos(playerid, 260.2059,2910.6101,6.2248);
    SetPlayerCameraLookAt(playerid, 259.9881,2904.1746,7.2830);
Reply
#2

not sure what you're trying to accomplish, but this is one way you could do it.

pawn Код:
if( tcount > acount )
{
    // class 1 has more players than class 2.
}
else
{
    // class 2 has more players than class 1.
}
Reply
#3

Okay, let me try. Thanks.
Reply
#4

BUMP, new code, but still doesn't work!
pawn Код:
//I've changed it
    if(class1[playerid] == 1 || class2[playerid] == 1) {
    if(acount > tcount)
    {
        SendClientMessage(playerid, -1, "Team is "COL_VIOLET"full"COL_WHITE".");
        return 0;
    }
    else
    {
        SendClientMessage(playerid, -1, "Team is "COL_VIOLET"full"COL_WHITE".");
        return 0;
    } }
Reply
#5

Bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)