balance system not working...[REP+]
#1

hey guys,

yes i already made another topic about this a week ago or something, and there 1 guy helped me but it didnt really worked wut he said...

so well here is the point:

i made a sorta balance system for my server and well, in the code it seems all alright to me, and NO errors/warns at all, but ingame it just doesnt works.... here its ment to do it that when the cops team has like 5 players and the terrorists have 4 or 3 players, then it should say when trying to spawn as a cop it should say its full , join other team... but it doesnt

same in the other way, if i have 3 terrors and 1 cop, a player still can join the terrorists... anyways anyone has got the answer to this? please

pawn Код:
new TeamArmy = 0, TeamTerrorists = 0;
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(TeamTerrorists > TeamArmy && (AllTeams[playerid] == TERRORISTS && (AllTeams[playerid] != ARMY)))
    {
        SendClientMessage(playerid, COLOR_ORANGE, "BALANCE: team Terrorists is full, join team Army");
        return 0;
    }
    else if(TeamTerrorists < TeamArmy && (AllTeams[playerid] == TERRORISTS && (AllTeams[playerid] != ARMY)))
    {
        TeamTerrorists++;
        SendClientMessage(playerid, COLOR_BLUE, "welcome to the Terrorists, use /cmds to see a list of commands");
        return 1;
    }
    else if(TeamArmy > TeamTerrorists && (AllTeams[playerid] == ARMY && (AllTeams[playerid] != TERRORISTS)))
    {
        SendClientMessage(playerid, COLOR_ORANGE, "BALANCE: Team Terrorists is full, join team Army");
        return 0;
    }
    else if(TeamArmy < TeamTerrorists && (AllTeams[playerid] == ARMY && (AllTeams[playerid] != TERRORISTS)))
    {
        TeamArmy++;
        SendClientMessage(playerid, COLOR_BLUE, "welcome to the Army, use /cmds to see a list of commands");
        return 1;
    }
    return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(AllTeams[playerid] == TERRORISTS && (AllTeams[playerid] != ARMY))
    {
        TeamTerrorists--;
    }
    else if(AllTeams[playerid] == ARMY && (AllTeams[playerid] != TERRORISTS))
    {
        TeamArmy--;
    }
    return 1;
}
ok well this is my pawn code till this far... cant really find the problem though

anyways REP+ for the ones who help me xD

greets niels
Reply
#2

Correct me if I am wrong. AllTeams[playerid] tells in which team is specific player (playerid).
Reply
#3

yup your right xD, the allteams is same as gteam, i just changed the variable, but yes its AllTeams[playerid] so it checks for the playerid, right? or am i wrong for that playerid thingy now? xD
Reply
#4

Your AND statements may not work the way they should be because you put backets around every one of them.
Reply
#5

yes cuz else i get errors, if i dont put the ( in front of them i get errors, example:
pawn Код:
if(AllTeams[playerid] == TERRORISTS && AllTeams[playerid] != ARMY)
    {
        TeamTerrorists--;
    }
this will get me errors, cuz i removed the ( and )....

anyways tell me if im wrong xD
Reply
#6

Quote:
Originally Posted by niels44
Посмотреть сообщение
yup your right xD, the allteams is same as gteam, i just changed the variable, but yes its AllTeams[playerid] so it checks for the playerid, right? or am i wrong for that playerid thingy now? xD
You are not storing it. When player spawns as a terrorist. You need to AllTeams[playerid]=TERRORIST plus TeamTerrorists++; (what you did already). As well as that, OnPlayerDisconnect you need to clean players team.( AllTeams[playerid]=NO_TEAM)
Reply
#7

wait i dont understand you...
Reply
#8

Can you show me OnPlayerRequestClass I will make it work.
Reply
#9

thnx xD:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 2486.6650,-1666.2847,13.3438);
    SetPlayerFacingAngle(playerid, 264.2691);
    SetPlayerCameraPos(playerid, 2492.1646,-1663.5969,13.3359);
    SetPlayerCameraLookAt(playerid, 2486.6650,-1666.2847,13.3438);
    switch(classid)
    {
        case 0 .. 5:
        {
            GameTextForPlayer(playerid, "~r~Terrorists", 3000, 6);
            AllTeams[playerid] = TERRORISTS;
        }
        case 6 .. 11:
        {
            GameTextForPlayer(playerid, "~b~Army", 3000, 6);
            AllTeams[playerid] = ARMY;
        }
    }
    return 1;
}
hmm also if i have to remove something, tell me pls, to prevent buggs xD

and thnx again
Reply
#10

Quote:
Originally Posted by niels44
Посмотреть сообщение
yes cuz else i get errors, if i dont put the ( in front of them i get errors, example:
pawn Код:
if(AllTeams[playerid] == TERRORISTS && AllTeams[playerid] != ARMY)
    {
        TeamTerrorists--;
    }
this will get me errors, cuz i removed the ( and )....

anyways tell me if im wrong xD
Well.. that is a rubbish comparison, but the syntaxis is right, so it shouldn't give you any errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)