SA-MP Forums Archive
!!Important!! Team Balance!! - 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: !!Important!! Team Balance!! (/showthread.php?tid=236460)



!!Important!! Team Balance!! - BlackWolf120 - 07.03.2011

hi,

i dont know what else i would have to change.
It seems correct ot me.
I also made a command that i can see where the error is.
It seems that after a few joins and disconnects it f**s up somehow.
The team balance just doesnt work. It counts wrong sometimes....
Pls can someone tell me whats wrong?

pawn Код:
#define TEAM_POLICE 1
#define TEAM_TERRORISTS 2
#define MAX_TEAMS 2

new firstspawn[MAX_PLAYERS];

new Count_Police;
new Count_Terrorists;

//OnPlayerConnect
firstspawn[playerid] = 0;

//OnPlayerDisconnect
    if(GetPlayerTeam(playerid) == TEAM_POLICE)
    {
        Count_Police--;
    }
    else if(GetPlayerTeam(playerid) == TEAM_TERRORISTS)
    {
        Count_Terrorists--;
    }

//OnPlayerSpawn

    if(firstspawn[playerid]==0)
    {

    if(GetPlayerTeam(playerid) == TEAM_POLICE)
    {
        Count_Police++;
    }
    else if(GetPlayerTeam(playerid) == TEAM_TERRORISTS)
    {
        Count_Terrorists++;
    }
}

firstspawn[playerid] = 1;

//OnPlayerRequestSpawn
    if((Count_Police > Count_Terrorists) && GetPlayerTeam(playerid) == TEAM_POLICE)
    {
        SendClientMessage(playerid,0xE100E1FF,"{2B2B2B}Please join the {CC7F32}adverse team {2B2B2B}in order to keep the {CC7F32}teams balanced.");
        GameTextForPlayer(playerid, "~b~~h~CTU ~r~team is full!", 800, 5);
        PlayerPlaySound(playerid,1055,0, 0, 0);
        return 0;
    }
    if((Count_Police < Count_Terrorists) && GetPlayerTeam(playerid) == TEAM_TERRORISTS)
    {
        SendClientMessage(playerid,0xE100E1FF,"{2B2B2B}Please join the {CC7F32}adverse team {2B2B2B}in order to keep the {CC7F32}teams balanced.");
        GameTextForPlayer(playerid, "~r~~h~~h~Coral Snake ~r~team is full!", 800, 5);
        PlayerPlaySound(playerid,1055,0, 0, 0);
        return 0;
    }
Pls this is very important i really need ur help here


Re: !!Important!! Team Balance!! - GaGlets(R) - 07.03.2011

under OnPlayerRequestClass put team variable
for example
pawn Код:
if(class == POLICE)
{ playerteam[playerid] = police; }
else if (...) {playerteam[playerid] = terror;}
and then use `if(playerteam[playerid] == team)` instead of GetPlayerTeam


Re: !!Important!! Team Balance!! - BlackWolf120 - 07.03.2011

hi, thx for ur answer.
does it really make a difference if i use GetPlayerTeam or playerteam?


Re: !!Important!! Team Balance!! - GaGlets(R) - 07.03.2011

I dont know i would preffer integer(variable). Earlyer GetPlayerTeam had bug and it works if you use SetPlayerTeam I guess?