Returning to Position after Death [0.3 Bug] ?
#6

Thanks for the answears, i now tested every part you mentioned, to make sure he loads and saves the right coordinates. My Test Code looked like:
Код:
// Login of Player

// Loading Stuff
SetSpawnInfo(...); // See above
SpawnPlayer(playerid);

// OnPlayerDisconnect
if(reason == 0)
{
	pInfo[playerid][pCrashed] = true;
	GetPlayerPos(...)
	pInfo[playerid][p_X] = x;
	// ...
	// Save Stuff
}

// OnPlayerSpawn
if(pInfo[playerid][pCrashed])
{
	// Some other Stuff
  if(pInfo[playerid][pCrashed] == 1)
	{
	  new
	    string[60];
		format(string, sizeof(string), "RIGHT U SHOULD REED THIS MESSAGE: Returning to Pos: %f %f %f", pInfo[playerid][p_X], pInfo[playerid][p_Y], pInfo[playerid][p_Z]);
		SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	  SetPlayerVirtualWorld(playerid, 0);
	  SetPlayerInterior(playerid, 0);
	  SetPlayerPos(playerid, pInfo[playerid][p_X], pInfo[playerid][p_Y], pInfo[playerid][p_Z]);
	  pInfo[playerid][pCrashed] = 0; // Reset
	  return 1;
	}
	SendClientMessage(playerid, COLOR_LIGHTBLUE, "WRONG, YOU CANT READ THIS MESSAGE IF YOU JUST CRASHED");
	// Normal Spawn (where i spawn everytime) goes here
}

// PLAYER_STATE_SPAWNED under OnPlayerStateChange

SendClientMessage(playerid, COLOR_LIGHTBLUE, "PLAYER_STATE_SPAWNED WAS CALLED");
So now i joined the Server, teleportet me to a Pos (noticed the Coords) and stopped the process of GTA while ingame (-> Crash). After that i joined again to see which of these messages appear ingame, it looked like
Quote:

Connected to ...
PLAYER_STATE_SPAWNED WAS CALLED
RIGHT U SHOULD REED THIS MESSAGE: Returning to Pos: [THE RIGHT KOORDS HERE]
WRONG, YOU CANT READ THIS MESSAGE IF YOU JUST CRASHED

So the problem should be clear but im not sure how the fix it. OnPlayerSpawn gets called TWO times. The fist time i spawn at the right Coords, but the Second time i spawn at the normal Coors, because the Crashvariable gets reset after the first one.

But this problem only happens when i spawn for the first time right after Login. When i die ingame, theres just one message. So i think it has to do with my Login Stuff, where i used (see above) SetSpawnInfo and SpawnPlayer

Anybody else has this problem? Hope you can help me out of it, in 0.2 it worked with exactly this Code. Well i think it would work if i put my crash Code under PLAYER_STATE_SPAWED, but this wont be a solution for the Problem, just another fix...

If you need more info or Code about this, just ask
Reply


Messages In This Thread
Returning to Position after Death [0.3 Bug] ? - by Doktor - 03.10.2009, 17:29
Re: Returning to Position after Death [0.3 Bug] ? - by ruarai - 04.10.2009, 01:25
Re: Returning to Position after Death [0.3 Bug] ? - by ruarai - 04.10.2009, 03:54
Re: Returning to Position after Death [0.3 Bug] ? - by Joe Staff - 04.10.2009, 06:18
Re: Returning to Position after Death [0.3 Bug] ? - by Andom - 04.10.2009, 08:42
Re: Returning to Position after Death [0.3 Bug] ? - by Doktor - 04.10.2009, 12:12
Re: Returning to Position after Death [0.3 Bug] ? - by Doktor - 04.10.2009, 13:29
Re: Returning to Position after Death [0.3 Bug] ? - by Doktor - 04.10.2009, 14:37

Forum Jump:


Users browsing this thread: 1 Guest(s)