UptimeRestarts: small adjustements

This commit is contained in:
Dogan 2019-11-07 14:59:46 +01:00
parent ee131275b7
commit 44a024b078

View File

@ -11,17 +11,17 @@ public Plugin myinfo =
name = "UptimeRestart",
author = "Dogan",
description = "Display Server Uptime and do controlled Restarts",
version = "1.0.0",
version = "1.1.0",
url = ""
};
public void OnPluginStart()
{
RegAdminCmd("uptime", Command_Uptime, ADMFLAG_GENERIC, "Displays server Uptime (controlled Restarts not included)");
RegAdminCmd("sm_uptime", Command_Uptime, ADMFLAG_GENERIC, "Displays server Uptime (controlled Restarts not included)");
RegAdminCmd("uptime", Command_Uptime, ADMFLAG_GENERIC, "Displays server Uptime since last Crash");
RegAdminCmd("sm_uptime", Command_Uptime, ADMFLAG_GENERIC, "Displays server Uptime since last Crash");
RegAdminCmd("c_uptime", Command_C_Uptime, ADMFLAG_RCON, "Displays server Uptime since last controlled Restart");
RegAdminCmd("sm_c_uptime", Command_C_Uptime, ADMFLAG_RCON, "Displays server Uptime since last controlled Restart");
RegAdminCmd("realuptime", Command_RealUptime, ADMFLAG_RCON, "Displays server Uptime since last controlled Restart/Crash");
RegAdminCmd("sm_realuptime", Command_RealUptime, ADMFLAG_RCON, "Displays server Uptime since last controlled Restart/Crash");
g_iRestartCountdown = 5;
GetUptimeIfControlledRestart();
@ -33,7 +33,7 @@ public void GetUptimeIfControlledRestart()
{
File UptimeFile = OpenFile("uptime.txt", "r");
if(UptimeFile != null)
if(UptimeFile != null)//Server was restarted automatically by this plugin
{
char sUptime[64];
UptimeFile.ReadLine(sUptime, sizeof(sUptime));
@ -41,6 +41,8 @@ public void GetUptimeIfControlledRestart()
delete UptimeFile;
DeleteFile("uptime.txt");
}
else//Server crashed or restarted manually
LogToFile("addons/sourcemod/logs/restarts.txt", "Server crashed or was restarted manually.");
}
public Action Command_Uptime(int client, int args)
@ -68,7 +70,7 @@ public Action Command_Uptime(int client, int args)
return Plugin_Handled;
}
public Action Command_C_Uptime(int client, int args)
public Action Command_RealUptime(int client, int args)
{
float fUptime = GetEngineTime();
@ -89,13 +91,13 @@ public Action Command_C_Uptime(int client, int args)
else
Format(sUptime, sizeof(sUptime), "%d Seconds.", iSeconds);
ReplyToCommand(client, "[SM] Server Uptime since last controlled restart: %s", sUptime);
ReplyToCommand(client, "[SM] Server Uptime since last controlled restart/crash: %s", sUptime);
return Plugin_Handled;
}
public Action CheckRestart(Handle timer)
{
if(!IsItRestartTime)
if(!IsItRestartTime())
return Plugin_Continue;
if(GetEngineTime() < 57500) //16 hours