22.11.2010, 22:35
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:
And just in case someone's wondering:
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.
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);
}
pawn Код:
#define PLAYER PlayerData[playerid]