Position Saving Bug
#1

Hey,
I have made up a script which saves the location of where you last crash and that works if you crash.
But I changed it to where you last disconnect from the server and it works when you /q and join again.
BUT!! When I do /gmx or /rcon gmx it doesn't save the positions of the character in their files and it ends up spawning out underground near some farm.
Does anyone know what I should do to fix this?
Reply
#2

I think you have your stuff stored at OnPlayerDisconnect which doesn`t get executed when you restart your server.

OnGameModeExit is the function being called in this case.

What you could do is simply throw the stuff you have in OnPlayerDisconnect to OnGameModeExit (with a few adjustments of course).
Reply
#3

That doesn't seem to work.
It just does the same, loads out in red country.
I could always have the server kick all players before it GMX's, that works.
But how would I get it to work without kicking everyone?
Does the OnPlayerUpdate Function do anything? If there were 100 players online would it update instantly? Or would it take time to update?
I know the OnPlayerUpdate has the X Y and Z Pos saving in it, but how would I get it to save at GMX?
Reply
#4

I wouldn`t use OnPlayerUpdate for such stuff (see OnPlayerUpdate explanations @ wiki - it hasn`t much to do with what you said).

It works when you kickall players because then OnPlayerDisconnect gets executed before you actually restart the server.

As I said, throw the stuff that causes spawning at the proper locations in OnGameModeInit as well (just adjust it a little - you ll probably need to loop through all connected players) and you`ll see it will work -
Reply
#5

I've encountered the same exact problem, but this was caused when I upgraded SA-MP from 0.2 to 0.3. You can first try the OnPlayerDisconnect, but I got the feeling I tried that & it didn't work (Dont remember exactly), but when I put my save function there (Without the OnPlayerDisconnect), it worked, so I left it alone, but OnPlayerDisconnect is rather important to be called during a reset (For most scripts anyway) I recommend testing around a bit and see if you can get it to work with OnPlayerDisconnect instead:

pawn Code:
public OnGameModeExit()
{  
for(i=0;i<MAX_PLAYERS;i++)
{  
if(IsPlayerConnected(i)) // Mod this to whatever additional checks you need...
{  
OnPlayerDisconnect(i,1); // I think I tried this before actually and didnt work, but give it a shot anyways
save(i); // Or whatever your save function is (In case calling OnPlayerDisconnect doesn't work)
}
}
}
It's a start anyway, just test around until something goes right :P
Reply
#6

Wouldn`t call OnPlayerDisconnect but do as I said what is equal to parts of your code.
Reply
#7

Kicking every player just to do a restart may cause some of them to just leave, I don't recommend it at all...

Alright, I had thought maybe OnPlayerDisconnect isn't called during a gamemode reset, so I'd then throw in your save function because it worked for me. If OnPlayerDisconnect is too important & MUST be called before the reset, I have to suggest creating a command that just calls that call back alone which would then be followed by your GMX command manually.

I think in my GMX command, I tried to call OnPlayerDisconnect before the gamemodeexit function, but don't think it worked, but could always try that if you want before making a new command
Reply
#8

I didn`t say to kick all players .

I would put the stuff I have in OnPlayerDisconnect that saves playerfiles simply in OnGameModeExit. Easy as it is.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)