u should have it for like 24 hours or 18 hours restart just helping new peaple to script
PHP Code:
/*
* Server Restart (Every hour)
*
* Description:
* A small plugin which restarts the server every hour for
* updates etc.
*
* Credits:
* jim_yang (helped me with the HUD message countdown)
*
* Changelog:
* v2.1
* -Changed the code a bit since the if(hour==0 && minute==0 && second==0) didn't work.
* -Countdown now is in hour:minute:second mode
* -Sorry for any inconvenience troubling the many updates today. Works fine now.
*
* v2.0
* -Added HUD Message countdown (Credits to jim_yang, The Specialist and Brad)
* -Added cvar for HUD Message countdown
* -Improved the code a little bit ;)
* -Deleted the cvar to change the restart time
*
* v1.2
* -Added so the server.cfg will be executed every time it restarts by the plugin
*
* v1.1
* -Changed the cvars to pcvars
*
* This plugin is provided as is (no warranties).
* Copyright (C) 2006 MaTTe
*/
#include <amxmodx>
#include <amxmisc>
#define TIMER_TASK 123456
new g_Switch, g_ShowTimer
new g_counter = 3600
new hour, minute, second
public plugin_init()
{
register_plugin("Server Restart","2.1b","MaTTe (mateo10)")
g_Switch = register_cvar("server_restart", "1")
g_ShowTimer = register_cvar("server_showtimer", "1")
set_task(1.0, "CountDown", TIMER_TASK, _, _, "b")
return PLUGIN_CONTINUE
}
public CountDown()
{
if(g_counter==0)
{
restartServer()
return
}
g_counter--
if(!get_pcvar_num(g_ShowTimer))
return
hour = g_counter / 3600
minute = g_counter % 3600 / 180 //<< the end bit is how much time 60 = 1 min 120 = 2 hours 3 hours 180
second = g_counter % 3600 % 180 //<< the end bit is how much time 60 = 1 min 120 = 2 hours 3 hours 180
set_hudmessage(0, 100, 0, -1.0, 0.35, 0, 0.01, 1.0, 0.01, 0.01, 4)
//show_hudmessage(0, "%d Seconds Until Server Restart.", g_counter)
show_hudmessage(0,"%02d:%02d:%02d Left",hour,minute,second)
}
public restartServer()
{
if(get_pcvar_num(g_Switch)==1)
{
server_cmd("restart")
}
return PLUGIN_CONTINUE
}