SA-MP Forums Archive
ToggleSpec | SpawnPlayer | OPS called twice bypass - 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)
+--- Thread: ToggleSpec | SpawnPlayer | OPS called twice bypass (/showthread.php?tid=516524)



ToggleSpec | SpawnPlayer | OPS called twice bypass - trapstar2020 - 31.05.2014

I "HAVE" to use toggple spec and then spawn The Player because i am using setspawn info and the player cannot click the spawn, i don't want them to cause i'm using textdraw is there anyway to bypass OnPlayerSpawn calling twice.... when i use ToggleSpec(id, 0) and then SpawnPlayer ?


Re: ToggleSpec | SpawnPlayer | OPS called twice bypass - trapstar2020 - 01.06.2014

bump


Re: ToggleSpec | SpawnPlayer | OPS called twice bypass - Threshold - 01.06.2014

Example:
pawn Код:
CMD:spec(playerid, params[])
{
    //...
    TogglePlayerSpectating(playerid, true);
    //....
    return 1;
}

CMD:specoff(playerid, params[])
{
    //...
    TogglePlayerSpectating(playerid, false); //At this point, OnPlayerSpawn will be called.
    PreviousSpectate[playerid] = true; //This will let the script know that the player was previously spectating someone
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(PreviousSpectate[playerid]) return 1; //At the top of OnPlayerSpawn
    //...
    return 1;
}

public OnPlayerConnect(playerid)
{
    PreviousSpectate[playerid] = false; //At the top of OnPlayerConnect, so it doesn't bug your OnPlayerSpawn.
    //...
    return 1;
}

//At the top of your script:
new bool:PreviousSpectate[MAX_PLAYERS];