Rcon gmx vs exit
#1

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

Sorry, nevermind.
Reply
#3

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

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 :)
}
Reply
#5

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

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

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

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;
Reply
#9

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

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


Forum Jump:


Users browsing this thread: 3 Guest(s)