Anything wrong with this method of saving stats?
#1

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?
Reply
#2

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.
Reply
#3

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!
Reply
#4

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.
Reply
#5

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!
Reply
#6

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?
Reply
#7

https://sampforum.blast.hk/showthread.php?tid=319439

If you haven't figured it out yet.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)