//Magyar fordítás: sNaiL
//Plugin készítõje: pizzahut
//Weboldal: www.netmaffia.hu
#include <amxmodx>
#include <amxmisc>
#define Plugin "Time left in hostname"
#define Version "1.3.6"
#define Author "Doombringer,pizzahut"
#define CVARNAME "amx_hostname_update"
new g_old_hostname[64]
new g_mp_timelimit
public plugin_init()
{
register_plugin(Plugin,Version,Author)
register_cvar(CVARNAME,"1.0")
g_mp_timelimit = get_cvar_pointer("mp_timelimit")
set_task(2.0,"check_time")
}
// Check cvar for valid values, correct if needed, update hostname now and set
// up a task.
public check_time()
{
new Float:time = get_cvar_float(CVARNAME)
if(time != 0.0)
{
time = floatabs(time)
if(time < 1.0)
time = 1.0
get_cvar_string("hostname",g_old_hostname,63)
if(strlen(g_old_hostname))
{
update_time()
set_task(time,"update_time",1,"",0,"b")
}
}
}
// Update hostname.
public update_time()
{
static new_hostname[64]
static h,m,s
if(strlen(g_old_hostname))
{
if(get_pcvar_float(g_mp_timelimit))
{
s = get_timeleft()
m = s/60
h = m/60
s = s-m*60
m = m-h*60
if(h)
format(new_hostname,63,"%s (Hatramaradt ido %d:%02d:%02d)",g_old_hostname,h,m,s)
else
format(new_hostname,63,"%s (Hatramaradt ido %d:%02d)", g_old_hostname,m,s)
}
else
format(new_hostname,63,"%s (No time limit)",g_old_hostname)
set_cvar_string("hostname",new_hostname)
}
}
// Restoring hostname in case it's not reset in server.cfg.
public plugin_end()
{
if(task_exists(1))
{
remove_task(1)
if(strlen(g_old_hostname))
set_cvar_string("hostname", g_old_hostname)
}
}