Anything wrong with this method of saving stats? -
2KY - 27.05.2012
pawn Код:
CMD:restartserver( playerid, params[] )
{
new
msgStr [ 85 ];
if( accInfo [ playerid ] [ Auth ] < 4 || accLoggedIn [ playerid ] == 0 )
return NOAUTH;
for( new u; u < MAX_PLAYERS; u ++ )
{
ClearChat( u );
OnPlayerDisconnect( u, 1 );
TogglePlayerControllable( u, false );
//Kick( u );
}
format( msgStr, sizeof( msgStr ), " The server is restarting. "#LG"Please wait..." );
SendClientMessageToAll( -1, msgStr );
SendRconCommand( "gmx" );
return true;
}
Basically, I just call OnPlayerDisconnect for all players, and then GMX the server. Is there anyway this could bug out? What are some other solutions?
Re: Anything wrong with this method of saving stats? -
ReneG - 27.05.2012
I've never tried it that way, but if it works for you then by all means use it.
I'd rather use foreach and call the saving function that way, or check if the player is connected in the loop, otherwise you'll most likely get blank-named .ini files.
EDIT:
For safety reasons you could even just save all the playerdata, and then set a delaying timer (1-2 seconds) to officially restart the server.
Re: Anything wrong with this method of saving stats? -
2KY - 27.05.2012
Quote:
Originally Posted by VincentDunn
I've never tried it that way, but if it works for you then by all means use it.
I'd rather use foreach and call the saving function that way, or check if the player is connected in the loop, otherwise you'll most likely get blank-named .ini files.
|
Well, OnPlayerDisconnect, it checks if they're logged in before saving their stats. As to the saving function, I don't have one, lol, it's all done OnPlayerDisconnect.
But I appreciate the input!
Re: Anything wrong with this method of saving stats? -
ReneG - 27.05.2012
Quote:
Originally Posted by 2KY
Well, OnPlayerDisconnect, it checks if they're logged in before saving their stats. As to the saving function, I don't have one, lol, it's all done OnPlayerDisconnect.
But I appreciate the input!
|
As long as it works for you. I tend to separate huge chunks of code into functions for ease of use.
Re: Anything wrong with this method of saving stats? -
2KY - 27.05.2012
Quote:
Originally Posted by VincentDunn
As long as it works for you. I tend to separate huge chunks of code into functions for ease of use.
|
I'm a bit of an efficiency junky. (Ironic because I just noticed I used a random string for no apparent reason), so I tend to just write large pieces of code over-and-over, although in my released works, I do use functions, it's odd. I agree about the timer though, thanks for the idea!
Re: Anything wrong with this method of saving stats? -
mprofitt - 27.05.2012
Quote:
Originally Posted by 2KY
I'm a bit of an efficiency junky. (Ironic because I just noticed I used a random string for no apparent reason), so I tend to just write large pieces of code over-and-over, although in my released works, I do use functions, it's odd. I agree about the timer though, thanks for the idea!
|
"I'm a bit of an efficiency junky. so I tend to just write large pieces of code over-and-over"
what?
Re: Anything wrong with this method of saving stats? -
JhnzRep - 27.05.2012
https://sampforum.blast.hk/showthread.php?tid=319439
If you haven't figured it out yet.