SA-MP Forums Archive
team balancer didnt working. - 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 balancer didnt working. (/showthread.php?tid=179055)



team balancer didnt working. - Gh0sT_ - 25.09.2010

Код:
public OnPlayerRequestSpawn(playerid) 
{ 
    for(new p = 0; p < GetMaxPlayers(); p++)
    {
        if (gTeam[p] == Yakuza) Count1++; 
        else if (gTeam[p] == Nostra) Count2++;
        else if (gTeam[p] == Policija) Count3++; 
		else if (gTeam[p] == Triads) Count4++; 
    }
    if ((Count1 > Count2) && gTeam[playerid] == Yakuza) 
    { 
        ShowPlayerDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"GangWars", "Atsipraрome, taиiau\nРi komanda yra pilna, pasirinkite kitа.", "Gerai", "Uюdaryti");
        return 0;.
    }
    else if ((Count2 > Count1) && gTeam[playerid] == Nostra && GetPlayerScore( playerid ) < 1500 )
    { 
        ShowPlayerDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"GangWars", "Atsipraрome, taиiau\nJыs neturite 1.500 patirties taрkш,\nArba рi komanda yra pilna, pasirinkite kitа.", "Gerai", "Uюdaryti");
        return 0;
    }
    else if ((Count3 > Count2) && gTeam[playerid] == Policija && GetPlayerScore( playerid ) < 3000 )
    { 
        ShowPlayerDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"GangWars", "Atsipraрome, taиiau\nJыs neturite 3.000 patirties taрkш,\nArba рi komanda yra pilna, pasirinkite kitа.", "Gerai", "Uюdaryti"); 
        return 0;
    }
    if ((Count4 < Count3) && gTeam[playerid] == Yakuza) 
    { 
        ShowPlayerDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"GangWars", "Atsipraрome,\nРi komanda yra pilna, pasirinkite kitа.", "Gerai", "Uюdaryti");
        return 0;
    }
	return 1;
}
Sometimes it works, and sometimes no.. When i turn server on( OnGameModeInit ) and try to join Triads team, it say, that team is full ( on OGMI count1 2 3 4 = 0; ) when i try to join police team, its good, but my score <3000..


AW: team balancer didnt working. - Nero_3D - 25.09.2010

Although the checks for the balance dont make sense in my opinion

I think the main problem is that the count variable are global and never reseted
Means each time OnPlayerRequestSpawn is called the variables change and everything gets messed up