OnPlayerRequestSpawn - Team Balancer
#1

Hey, i have been trying to fix my "team balancer" but it keeps being bugged.
I wont allow me to spawn.

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(Cmafia >= MafiaFull)
    {
        if(pi[playerid][Classid] == 1 || 2 || 3)
        {
            ForceClassSelection(playerid);
            return 0;
        }
        else
        {
            if(pi[playerid][Classid] == 1 || 2 || 3)
            {
                pi[playerid][Mafia] = 1;
            }
        }
    }
    if(Cpolice <= CopFull)
    {
        if(pi[playerid][Classid] == 4 || 5 || 6)
        {
            ForceClassSelection(playerid);
            return 0;
        }
        else
        {
            if(pi[playerid][Classid] == 4 || 5 || 6)
            {
                pi[playerid][Police] = 1;
            }
        }
    }
    return 1;
}
* pi[playerid][Classid] = classid
* CopFull/MafiaFull = 16 - Max Players per team
* Cpolice/Cmafia = players on each team
Reply
#2

I suggest you use a switch.
pawn Код:
switch(pi[playerid][Classid])
{
    case 1 .. 3:
    {
        if(Cmafia >= MafiaFull) return 0;
        pi[playerid][Mafia] = 1;
    }
    case 4 .. 6:
    {
        if(Cpolice <= CopFull) return 0;
        pi[playerid][Police] = 1;
    }
}
Reply
#3

Thanks, it still wont let me spawn though.. So it's properly something else, though i can't find anything that should relate to that.
Reply
#4

Use same tehnique just put it under OnPlayerSpawn, because one day I tested when this is called, but I didnt found, not on death or one sec before OnPlayerSpawn.
Reply
#5

Edited: I readed wrong
Reply
#6

What? I just say, I dont know when OnPlayerRequestSpawn is called.
Reply
#7

I guess it's called right after OnPlayerRequestClass?
Reply
#8

OnPlayerRequestSpawn is called when you hit on 'Spawn' button.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)