GMX instantly restarts despite timer?
#1

pawn Код:
CMD:gmx(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");

    new reason[128], time, query[128];
    if(AdminLevel[playerid] < 3) return SendClientMessage(playerid, COLOUR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "ds[128]", time, reason)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /gmx [time till restart] [reason]");
    if(time < 1 ||time > 60) return SendClientMessage(playerid, COLOUR_GREY, "Time must be between 1 minute and 1 hour.");
    format(reason, sizeof(reason), "Admin %s has scheduled a Server Restart in %d minute(s) [Reason: %s]", GetNameEx(playerid), time, reason);
    SendClientMessageToAll(0x95FFB4FF, reason);
    //kick all
    for(new x = 1; x < GetVehiclePoolSize()+1; x++)
    {
        UpdateVehicleParts(x);
    }
    foreach(Player, i)
    {
        SavePlayerData(i);
    }
    for(new x = 1; x < MAX_BUSINESSES; x++)
    {
        if(BizEntX[x] != 0)
        {
            format(query, sizeof(query), "UPDATE `businesses` SET BizBank = %d WHERE id = %d", BizBank[x], x);
            mysql_tquery(dbHandle, query,"", "");
        }
    }
    GMXTIME = time;
    return 1;
}
GMXTIME is a global variable.

None of those functions call anything apart from MYSQL.

pawn Код:
if(GMXTIME > 0)
            {
                GMXTIME --;

                if(GMXTIME == 0)
                {
                        SetPlayerName(p, MAName[p]);
                        SendClientMessage(p,COLOUR_WHITE, "Server Restart Initiated.");
                        GameModeExit();
                }
                else
                {
                    new string1[128];
                    format(string1, sizeof(string1), "(( Reminder: Server will restart in %d minute(s). (Leave the server to avoid losing items.) ))", GMXTIME);
                    SendClientMessage(p, COLOUR_WHITE, string1);
                }
            }
Under a one minute timer.
Reply
#2

Restarts instantly after you launch the game mode without even using the command or after using the command?


Check whether you created GMXTIME with static, if so, either remove the static or do GMXTIME = -1; before you restart.


EDIT: not GMX = 0, I meant = -1; sorry.
Reply
#3

It's because it checks if GMXTIME is over 0. If it is, it subtracts it by one and there's no timer making it subtract by 1 ever 1 second. So, it repeats until it's 0 then restarts which is done in milliseconds. Try making it set a timer for the amount of time you enter times 1000, so it'd be:

/gmx 60 test
PHP код:
forward GMXTIMER(); 
PHP код:
 if(GMXTIME 0)
            {
                
SetTimer("GMXTIMER"GMXTIME*60000false);
                if(
GMXTIME == 0)
                {
                        
SetPlayerName(pMAName[p]);
                         
SendClientMessage(p,COLOUR_WHITE"Server Restart Initiated.");
                        
GameModeExit();
                }
                else
                {
                    new 
string1[128];
                     
format(string1sizeof(string1), "(( Reminder: Server will restart in %d minute(s). (Leave the server to avoid losing items.) ))"GMXTIME);
                    
SendClientMessage(pCOLOUR_WHITEstring1);
                }
            } 
PHP код:
public GMXTIMER()
{
    
GMXTIME 0;
    
//Then call whatever the hell function you have that makes it exit the gamemode and save, etc.

Reply
#4

@oSAINTo

He is using a global timer for this.

Quote:

Under a one minute timer.

pawn Код:
if(time < 1 ||time > 60) return SendClientMessage(playerid, COLOUR_GREY, "Time must be between 1 minute and 1 hour.");
Reply
#5

"time" is just a variable, that code above it only allowing it to have a max of 60 minutes and a minimum of 1 minute. That doesn't actually wait for the timer to finish. If it does, he didn't provide that code.
Reply
#6

Quote:
Originally Posted by oSAINTo
Посмотреть сообщение
"time" is just a variable, that code above it only allowing it to have a max of 60 minutes and a minimum of 1 minute. That doesn't actually wait for the timer to finish. If it does, he didn't provide that code.
Yes, I included it because it denoted that he is using a global timer.
Reply
#7

Thanks for the replies, I think I had it under a foreach per-player loop, so it would decrease each time.
Reply
#8

GMX is not a full server-restart therefore not that useful to have a command like that.
Reply
#9

Quote:
Originally Posted by Dokins
Посмотреть сообщение
Thanks for the replies, I think I had it under a foreach per-player loop, so it would decrease each time.
How and why, if I may ask.


Quote:
Originally Posted by Astralis
Посмотреть сообщение
GMX is not a full server-restart therefore not that useful to have a command like that.
I don't think he uses gmx anyway.
pawn Код:
{
    SetPlayerName(p, MAName[p]);
    SendClientMessage(p,COLOUR_WHITE, "Server Restart Initiated.");
    GameModeExit();
}
Reply
#10

I think /gmx is a default sa-mp command that can not be overwritten, try using gmxe as the command name for testing purposes.

EDIT : nvm i 4got the in-game command was /rcon gmx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)