You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

75 lines
2.4 KiB

/* Plugin Template generated by Pawn Studio */
#include <sourcemod>
#include <steamtools>
#define UN_VERSION "1.4"
new Handle:cv_enabled, Handle:cv_text, Handle:cv_restart,
Handle:cv_restarttime, Handle:cv_warningintervall, Handle:cv_waringtext;
new Float:remtime;
public Plugin:myinfo =
{
name = "UpdateNotifier",
author = "Chefe",
description = "Plugin that notifiy clients about updates",
version = UN_VERSION,
url = "https://forums.alliedmods.net/showthread.php?t=163122"
}
public OnPluginStart()
{
cv_enabled = CreateConVar("sm_un_enabled", "1", "Enable/disable UpdateNotifier");
cv_text = CreateConVar("sm_un_text", "WARNING! Gameupdate has been released, server will restart for updating!", "Set text (MAX 200) that will be displayed when server needs restart for updating");
cv_restart = CreateConVar("sm_un_restart", "0", "Set restart handling: 0 = No restart caused by the plugin, restart is done by autoupdate on mapchange; 1 = restart server if no players are online; 2 = restart server even if there are players online");
cv_restarttime = CreateConVar("sm_un_restartdelay", "30.0", "Set the time (in sec) between the Warning and the restart if is set", _, true, 5.0);
cv_warningintervall = CreateConVar("sm_un_warnintervall", "5.0", "Set the intervall warnings should appear", _, true, 5.0)
cv_waringtext = CreateConVar("sm_un_warntext", "Server restart in %i seconds");
CreateConVar("sm_un_version", UN_VERSION, "Shows current plugin version.", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
AutoExecConfig(true);
}
public Action:Steam_RestartRequested()
{
if (GetConVarBool(cv_enabled))
{
new String:text[200];
GetConVarString(cv_text, text, sizeof(text));
PrintToChatAll("\x04%s", text);
PrintHintTextToAll("%s", text);
if (GetConVarInt(cv_restart) == 1)
{
if (GetClientCount(false) == 0)
{
ServerCommand("quit");
}
}
else if (GetConVarInt(cv_restart) == 2)
{
CreateTimer(GetConVarFloat(cv_restarttime), Timer_Restart);
remtime = Float:GetConVarFloat(cv_restarttime);
}
}
return Plugin_Continue;
}
public Action:Timer_Restart(Handle:timer)
{
remtime -= Float:GetConVarFloat(cv_warningintervall);
if (remtime <= 0.0)
{
ServerCommand("quit");
return;
}
new String:warntext[200];
GetConVarString(cv_waringtext, warntext, sizeof(warntext));
PrintToChatAll("\x04%s", warntext, remtime);
PrintHintTextToAll("%s", warntext, remtime);
}