Reconnect Players on restart
#1

I send "exit" to the console to shut down the server.My server is started by a batch file.The batch is such that when the server exits the server is started again.

The issue is that it disconnects all players when the server shuts down(actually its being restarted).The players cannot reconnect until they close GTA SA and start all over again.This is very annoying.

How do I prevent the players from disconnecting?I want them to reconnect when the server starts again(without forcing the player to close his GTA SA and connect again, just connect directly).

I know there is some code to do it because I had seen it before.But I couldn't find the code using the search.

Thanks
Reply
#2

try typing /rcon gmx.
Reply
#3

-_- I don't want to use gmx or loadfs or unloadfs.I want to completely restart the server.I want to close my server using that 'X' button and start the server again.
Reply
#4

I'm not sure and haven't tried it ever but maybe timeout the player then reboot then the player client's will automatically reconnect.

Again I'm not sure about what I'm telling so if it doesn't work I think it's normal.
Reply
#5

In normal circumstances the client should automatically reconnect after a short while of receiving "server didn't respond, retrying" messages.
Reply
#6

Yeah, but when the server shuts down it disconnects all the players(you get "You've been banned from the server" message).I will trying timing out all the players.
Reply
#7

Код:
public OnRconCommand(cmd[])
{
	if(!strcmp(cmd,"restart"))
	{
	    //restart server
	    print("[DEINIT]Server will restart in 3 seconds");
		for(new i;i < maxplayers;i++) TimePlayer(i);
	    SetTimer("ExitServer",3000,false);
	}
	return 1;
}
I did something like this.But when I restart after 3s (when the server exits) I get a message "Server closed connection.".

The TimePlayer Function is working(used before for timing out desynced players).


EDIT:What if I somehow crash the server when I want to restart? :P
Reply
#8

i made this code now try it,i am sure that it will work:
pawn Код:
if(strcmp(cmd, "/gmx", true) == 0)
    {
        if(IsPlayerAdmin(playerid)) //place your Playerinfo..padmin thingy here
        {
            GameModeInitExit();
        }
        else
        {
            SendClientMessage(playerid, -1, "   You are not an admin !");
        }
        return 1;
    }
and :
pawn Код:
forward GameModeInitExit();
public GameModeInitExit()
{
    new string[128];
    format(string, sizeof(string), "Server Restarting...");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            OnPlayerSave(i); //to save stats and...
            GameTextForPlayer(i, string, 4000, 5);
            SetPlayerInterior(i, 0);
            SetPlayerVirtualWorld(i, 0);
            SetPlayerCameraPos(i,1460.0, -1324.0, 287.2);
            SetPlayerCameraLookAt(i,1374.5, -1291.1, 239.0);
        }
    }
    SetTimer("GameModeExitFunc", 4000, 0);
    return 1;
}
and:
pawn Код:
public GameModeExitFunc()
{
    GameModeExit(); //if you have timers running ,use Kill timer before this line to stop the timer.
}
Reply
#9

I want to completely restart my server.I do not want to disconnect players when my server shuts down so that they can reconnect once its starts up again.

How do I crash a server?
a[10]; a [1000] =10000; will crash?
Reply
#10

Just try the code i gave you because i tried it and it works fine
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)