From 44a024b07809a56e020bc5f34f26db9468b83380 Mon Sep 17 00:00:00 2001 From: Dogan Date: Thu, 7 Nov 2019 14:59:46 +0100 Subject: [PATCH] UptimeRestarts: small adjustements --- UptimeRestarts/scripting/UptimeRestarts.sp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/UptimeRestarts/scripting/UptimeRestarts.sp b/UptimeRestarts/scripting/UptimeRestarts.sp index 4870b084..1e72d87f 100644 --- a/UptimeRestarts/scripting/UptimeRestarts.sp +++ b/UptimeRestarts/scripting/UptimeRestarts.sp @@ -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