TogglePlayerSpectating + SetPlayerPos
#2

First of all, real sorry about the double post. But in case someone cares - here's what I learnt, and how I 'fixed' it:

It seems that it wasn't TogglePlayerSpectating that reset the players position, but just called OnPlayerSpawn twice. And OnPlayerSpawn callback did the reset to AddPlayerClass position. The workaround I found is simply delaying the actual player spawn-setup by 200ms with a timer. Here's the code:
pawn Код:
public OnPlayerSpawn(playerid)
{
    if( !PLAYER[Spec] )Spawning(playerid);
    else PlayerSpec(playerid, false);
    return 1;
}
public PlayerSpec(playerid, toggle)
{
    PLAYER[Spec] = toggle;
    TogglePlayerSpectating(playerid, toggle);
    return 1;
}
Delay:Spawning[200, i](playerid)
{
    SetPlayerSkin(playerid, PLAYER[Skin]);
    SetPlayerInterior(playerid, PLAYER[Interior]);
    SetPlayerVirtualWorld(playerid, PLAYER[VW]);
    SetPlayerPos(playerid, PLAYER[X], PLAYER[Y], PLAYER[Z]);
    SetPlayerFacingAngle(playerid, PLAYER[Angle]);
    SetPlayerHealth(playerid, PLAYER[HP]);
    SetPlayerArmour(playerid, PLAYER[Armor]);
    SetCameraBehindPlayer(playerid);
}
And just in case someone's wondering:
pawn Код:
#define PLAYER PlayerData[playerid]
Only took me what... 2 hours of messing around with different ideas? Finally resorted on the one I actually didn't want to use, but at least it works.
Reply


Messages In This Thread
TogglePlayerSpectating + SetPlayerPos - by TheXIII - 22.11.2010, 20:21
Re: TogglePlayerSpectating + SetPlayerPos - by TheXIII - 22.11.2010, 22:35
Re: TogglePlayerSpectating + SetPlayerPos - by bigcomfycouch - 22.11.2010, 22:37
Re: TogglePlayerSpectating + SetPlayerPos - by TheXIII - 22.11.2010, 23:31
Re: TogglePlayerSpectating + SetPlayerPos - by ReVo_ - 19.08.2012, 13:02

Forum Jump:


Users browsing this thread: 1 Guest(s)