SA-MP Forums Archive
bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: bug (/showthread.php?tid=277894)



bug - svaba - 19.08.2011

If i restart the server while some players are online, their stats are fucked up on the next spawn! What could cause this?


Re: bug - Bakr - 19.08.2011

You are probably not saving player stats under the OnGameModeExit callback. You could either port all the saving information to that callback, under a loop, or have it call OnPlayerDisconnect for each connected player at the time.
pawn Код:
public OnGameModeExit( )
{
   for( new i = 0; i < MAX_PLAYERS; i++ )
   {
      if( IsPlayerConnected( i ) ) OnPlayerDisconnect( i, 2 );
   }
   return 1;
}
That is done assuming you save their stats under OnPlayerDisconnect callback.


Re: bug - svaba - 19.08.2011

Hmm thanks i will try it out


Re: bug - Kyle_Olsen - 19.08.2011

The code above won't work (no such thing as playerid stated there)

pawn Код:
public OnGameModeExit( )
{
   for( new i = 0; i < MAX_PLAYERS; i++ )
   {
      if( IsPlayerConnected( i ) ) OnPlayerDisconnect( i, 2 );
   }
   return 1;
}
However what I wrote there will most likely work. (Not tested)


Re: bug - =WoR=G4M3Ov3r - 19.08.2011

Quote:
Originally Posted by Bakr
Посмотреть сообщение
You are probably not saving player stats under the OnGameModeExit callback. You could either port all the saving information to that callback, under a loop, or have it call OnPlayerDisconnect for each connected player at the time.
pawn Код:
public OnGameModeExit( )
{
   for( new i = 0; i < MAX_PLAYERS; i++ )
   {
      if( IsPlayerConnected( i ) ) OnPlayerDisconnect( playerid, 2 );
   }
   return 1;
}
That is done assuming you save their stats under OnPlayerDisconnect callback.
ORly, And how would they save in scriptfiles > Users ?


Re: bug - Bakr - 19.08.2011

@Kyle_Olsen: A mere typo, no need to blow it up to such a big deal to claim your glory.

@BATAD: If you would read my original post, you just might be able to answer your own question. And one for you; how do you know where the original posters files are saved to?

I suggest people keep comments to themselves if they don't have an average IQ.


Re: bug - Kush - 19.08.2011

Quote:
Originally Posted by Kyle_Olsen
Посмотреть сообщение
The code above won't work (no such thing as playerid stated there)

pawn Код:
public OnGameModeExit( )
{
   for( new i = 0; i < MAX_PLAYERS; i++ )
   {
      if( IsPlayerConnected( i ) ) OnPlayerDisconnect( i, 2 );
   }
   return 1;
}
However what I wrote there will most likely work. (Not tested)
You've done nothing but replace 'playerid' in Bakr's code with the 'i' variable. People do tend to make mistakes.

Nice job Bakr.

Quote:
Originally Posted by BATAD
Посмотреть сообщение
ORly, And how would they save in scriptfiles > Users ?
He is assuming that OnPlayerDisconnect is the function in which save's the player's data. This has nothing to do with what was explained.


Re: bug - Kyle_Olsen - 19.08.2011

All I did was correct the mistake he did.
Just in case the guy that wanted to use it didn't see it.