SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 20/03/2010, 08:53 AM   #1
Jbosh123
Little Clucker
 
Join Date: Jan 2009
Posts: 39
Reputation: 0
Default Position Saving Bug

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?
Jbosh123 is offline  
Old 20/03/2010, 08:55 AM   #2
ray187
Big Clucker
 
Join Date: Nov 2008
Posts: 196
Reputation: 0
Default Re: Position Saving Bug

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).
ray187 is offline  
Old 20/03/2010, 10:05 AM   #3
Jbosh123
Little Clucker
 
Join Date: Jan 2009
Posts: 39
Reputation: 0
Default Re: Position Saving Bug

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?
Jbosh123 is offline  
Old 20/03/2010, 10:08 AM   #4
ray187
Big Clucker
 
Join Date: Nov 2008
Posts: 196
Reputation: 0
Default Re: Position Saving Bug

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 -
ray187 is offline  
Old 20/03/2010, 10:25 AM   #5
XGh0stz
Huge Clucker
 
XGh0stz's Avatar
 
Join Date: Nov 2007
Location: Florida
Posts: 273
Reputation: 17
Default Re: Position Saving Bug

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
__________________
Please respect the SA-MP Development Team
XGh0stz is offline  
Old 20/03/2010, 10:32 AM   #6
ray187
Big Clucker
 
Join Date: Nov 2008
Posts: 196
Reputation: 0
Default Re: Position Saving Bug

Wouldn`t call OnPlayerDisconnect but do as I said what is equal to parts of your code.
ray187 is offline  
Old 20/03/2010, 10:58 AM   #7
XGh0stz
Huge Clucker
 
XGh0stz's Avatar
 
Join Date: Nov 2007
Location: Florida
Posts: 273
Reputation: 17
Default Re: Position Saving Bug

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
__________________
Please respect the SA-MP Development Team
XGh0stz is offline  
Old 20/03/2010, 11:09 AM   #8
ray187
Big Clucker
 
Join Date: Nov 2008
Posts: 196
Reputation: 0
Default Re: Position Saving Bug

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.
ray187 is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Position Saving Sascha Help Archive 2 25/05/2010 11:43 PM
Position saving martyz-lithuania Help Archive 5 23/04/2010 01:24 PM
Saving position bug. rbN. Help Archive 6 16/04/2010 07:38 PM
About saving position pierhs Help Archive 18 25/07/2009 12:06 PM
Saving Position Adamrcook Help Archive 5 10/07/2009 03:19 PM


All times are GMT. The time now is 12:34 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.