04.10.2009, 12:12
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:
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
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
Код:
// 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");
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 |
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

