Get player position before closing GM? -
conspi - 09.10.2010
I wish to save player when GM closes. However GetPlayerPos returns just 0's under OnGameModeExit. What to do?
Re: Get player position before closing GM? -
Danny - 09.10.2010
I had exactly the same problem. When i restarted the server, the position returns 0, so the player will spawn somewhere on 0, 0 ,0. My solution was creating a check at the savesection, to make sure the position dont save it is was 0:
Код:
if(YOUR_POS_VARIABLE != 0) SavePos // or something
The cause of this problem is that the server dont have enough time to save the stats.
I use a timer in my restart command to, to make sure the server has time to save the value's.
Re: Get player position before closing GM? -
conspi - 09.10.2010
Quote:
Originally Posted by -Danny-
I had exactly the same problem. When i restarted the server, the position returns 0, so the player will spawn somewhere on 0, 0 ,0. My solution was creating a check at the savesection, to make sure the position dont save it is was 0:
Код:
if(YOUR_POS_VARIABLE != 0) SavePos // or something
The cause of this problem is that the server dont have enough time to save the stats.
I use a timer in my restart command to, to make sure the server has time to save the value's.
|
Thanks for answer. I did the same for now (doesn't save, if pos = 0,0,0).. but isn't there any work-around? Rollbacks are bad
Re: Get player position before closing GM? -
Danny - 09.10.2010
Yes, there are some other options, i read that you are using OnGameModeExit. Where are you exactly using this for (restarts, /rcon exit?)
EDIT:
If you want to use /rcon exit:
Код:
dcmd_rexit(playerid, params[]) {
SetTimer("Exittimer",2000,0);
SendClientMessageToAll(YOURCOLOR,"SERVER: Exit cmd activated, server shutdown!");
SaveAllStats // Add here your statssaving function
return 1;
}
public Exittimer() {
SendRconCommand("exit");
return 1;
}
I have made this code in about 1 minute, i think there are some simple mistakes in it but it only is to explain what im talking about. Cuz the server now have enough time to save the stats, the rollback will dissepear
Re: Get player position before closing GM? -
iJumbo - 09.10.2010
try
pawn Код:
enum Pos {
Float:XPos,
Float:YPos,
Float:ZPos,
};
new Gi[MAX_PLAYERS][Pos];
at the top
then in the script
pawn Код:
GetPlayerPos(playerid,Gi[playerid][XPos],Gi[playerid][YPos],Gi[playerid][ZPos]);
then save gi[playerid][XPos] ... y ... and z to a dini then when player spawn
if he save
pawn Код:
SetPlayerPos(playerid,Gi[playerid][XPos],Gi[playerid][YPos],Gi[playerid][ZPos]);
Re: Get player position before closing GM? -
conspi - 09.10.2010
I know I could make a custom command with delayed restart. But if I'm not mistaken - OnGameModeExit also gets called when GM crashes, no? So it also saves position then.
But I guess position rollback ain't that bad. I already save everything else in the moment it changes. (ex. Save money everytime you buy something / get money somewhere )
Still. If someone knows a workaround that doesn't require too much resource (Like updateing player pos into out-side var OnPlayerUpdate or something), I would be real thankful.