PDA

View Full Version : Empty Servers



Ruth
08-09-2016, 04:51 PM
Hey just wondering if i did this from the sp if it would break anything? i compiled it but i dont want to test it since waves are random. Will it restart my empty & active servers while i'm away at work :P

Before:

public void RestartServerIfRequired()
{
if (!s_RestartRequired)
return;

for (int client = 1; client < MaxClients; client++)
{
if (!IsClientInGame(client))
continue;

if (IsFakeClient(client))
continue;

KickClientEx(client, "Server is restarting...");
}

PrintToServer("Server restarting!");
PrintToChatAll("> \x05Server is graciously restarting.");
ServerCommand("quit");
}

After:

public void RestartServerIfRequired()
{
if (!s_RestartRequired)
PrintToServer("Server restarting!");
PrintToChatAll("> \x05Server is graciously restarting.");
ServerCommand("quit");
return;


}

Neuro Toxin
08-09-2016, 06:47 PM
The only way to have empty servers restart is to set sv_hibernate to 0.

Why: Sourcepawn timers dont tick when the server is hibenating.

To answer your question. Your edit will work. However: when quit is called the disconnect message to clients is the server has been shutdown. Using kick enables clients to receive a much friendlier disconnect message.