SA-MP Forums Archive
Rcon gmx vs exit - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP (https://sampforum.blast.hk/forumdisplay.php?fid=3)
+--- Forum: Bug Reports (https://sampforum.blast.hk/forumdisplay.php?fid=20)
+--- Thread: Rcon gmx vs exit (/showthread.php?tid=250121)



Rcon gmx vs exit - GaGlets(R) - 22.04.2011

From my point this is a serious bug. Calling rcon function `gmx` OnPlayerDisconnect would be taken first which is my problem, but with function `exit` OnPlayerDisconnect gets called second so no problems and worries.

I don`t want to explane whole problem. I am just looking for solution to detect `gmx` before OnPlayerDisconnent gets called.


Re: Rcon gmx vs exit - Miguel - 22.04.2011

Sorry, nevermind.


AW: Rcon gmx vs exit - Meta - 22.04.2011

you could use a variable to stop OnPlayerDisconnect of processing, like this:
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    if(!OPD){return 1;}
   ...
}
and after you're done with the other functions, you do "OPD = 1;"

but you still have to see for a way to detect gmx ...


Re: Rcon gmx vs exit - Ash. - 22.04.2011

I was pondering this a couple of weeks ago, i came up with this:

You could create your own gmx command?
Here's what i came up with. Doing it this way means you can pass your own reasoning to the OnPlayerDisconnect callback also. ()

pawn Code:
#define GMX 10

public OnRconCommand(cmd[])
{
    if(!strcmp("gmxex", cmd)) //Obviously you could edit the command name
    {
        for(new i; i < GetMaxPlayers(); i++)
        {
            OnPlayerDisconnect(i, GMX);
        }
        SendRconCommand("gmx");
        return 1;
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    //Here you could use the reason param to pass the reason of a restart :)
    if(reason == GMX)
    {
        //Your restart message maybe?
        //Or, cancel the OnPlayerDisconnect callback, as in:
        return 0;
    }
   
    //Then your other stuff :)
}



Re: Rcon gmx vs exit - GaGlets(R) - 22.04.2011

That is the reason - if server restarts via console?

@meta Think before posting.

So we can make a little suggestion @ OnPlayerDisconnect add one more reason (Server crashed/shutting down/restarting)


Re: Rcon gmx vs exit - Ash. - 22.04.2011

It would be my approach, just to make an alternative command, and pass variables to OnPlayerDisconnect


Re: Rcon gmx vs exit - Miguel - 23.04.2011

Quote:
Originally Posted by ******
View Post
What are you on about? Gets called "first" and "second" - in relation to what? When it is called second what are you referring to that is called before it?
OnPlayerDisconnect gets called after OnGameModeExit. If you close the server connection to a MySQL database on the last one, everything goes wrong.


Re: Rcon gmx vs exit - dannyk0ed - 23.04.2011

My code for GMX is
Code:
if(strcmp(cmd, "/restart", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
            if (PlayerInfo[playerid][pAdmin] >= 1330)
			{
                format(string, sizeof(string), " An Admin has issued a server restart, this will take place in 10 seconds, please relog.", sendername);
				SendClientMessageToAll(COLOR_LIGHTBLUE, string);
				format(string, sizeof(string), "** Warning: Not logging could cause you to spawn in random locations!", sendername);
				SendClientMessageToAll(COLOR_YELLOW, string);
                RestartTime = SetTimer("Restart", 10000, 0);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
			}
		}
		return 1;



Re: Rcon gmx vs exit - GaGlets(R) - 23.04.2011

OMG just get the f. off this thread if you dont want to post something realy useful, stop collecting post ammount.

@ ****** - Miguel wrote an exclusive example. Although if I use array to store players name, all information would go wrong...


Re: Rcon gmx vs exit - SaW_[VrTx] - 09.05.2011

I had the same problem.. Just make new callback called OPB and put OnPlayerDisconnect code under there. put OPB under OnPlayerDisconnect and OnGameModeExit.