SA-MP Forums Archive
OnPlayerRequestSpawn - Team Balancer - 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: OnPlayerRequestSpawn - Team Balancer (/showthread.php?tid=192703)



OnPlayerRequestSpawn - Team Balancer - Naxix - 23.11.2010

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


Re: OnPlayerRequestSpawn - Team Balancer - Vince - 23.11.2010

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;
    }
}



Re: OnPlayerRequestSpawn - Team Balancer - Naxix - 23.11.2010

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.


Re: OnPlayerRequestSpawn - Team Balancer - Voldemort - 23.11.2010

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.


Re: OnPlayerRequestSpawn - Team Balancer - Naxix - 23.11.2010

Edited: I readed wrong


Re: OnPlayerRequestSpawn - Team Balancer - Voldemort - 23.11.2010

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


Re: OnPlayerRequestSpawn - Team Balancer - Naxix - 23.11.2010

I guess it's called right after OnPlayerRequestClass?


Re: OnPlayerRequestSpawn - Team Balancer - The_Moddler - 23.11.2010

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