/*
* Plugin generated by AMXX-Studio
* Plugin create by Hisence
*/
#include <amxmodx>
#define PLUGIN "Timer menu"
#define VERSION "1.0"
#define AUTHOR "Hisence"
const TASK_TIMER = 8080;
new szPrefix[] = "Amxx";
new Float:g_fTimer[2];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /timer", "TimerMenu")
}
public TimerMenu(id)
{
if(get_user_team(id) != 2 || !is_user_alive(id))
return client_print(id, print_chat, "[%s] You cannot use this command!", szPrefix);
new menu,Text[40];
formatex(Text, 39, "\r%s\w Timer menu:", szPrefix);
menu = menu_create(Text, "SubTimer");
menu_additem(menu, "Start timer");
menu_additem(menu, "Stop timer");
menu_additem(menu, "\yReset timer");
menu_display(id, menu);
return 1;
}
public SubTimer(id, menu, item)
{
switch(item)
{
case 0:
{
if(g_fTimer[0] > 0.0)
client_print(id, print_chat, "[%s] Timer is already running", szPrefix);
else
{
client_print(0, print_chat, "[%s] %s started the timer", szPrefix, get_name(id));
set_task(0.1, "CreateTimer",TASK_TIMER,_,_, "b");
}
menu_display(id, menu);
}
case 1:
{
if(g_fTimer[0] > 0.0)
{
remove_task(TASK_TIMER);
client_print(0, print_chat, "[%s] %s stoped the timer at %.1f", szPrefix, get_name(id), g_fTimer[0]);
g_fTimer[1] = g_fTimer[0];
g_fTimer[0] = 0.0;
}
else
client_print(id, print_chat, "[%s] The timer isnt started yet!", szPrefix);
menu_display(id, menu);
}
case 2:
{
if(g_fTimer[0] > 0.0)
{
client_print(0, print_chat, "[%s] %s reset the timer at %.1f", szPrefix, get_name(id), g_fTimer[0]);
g_fTimer[1] = 0.0;
g_fTimer[0] = 0.0;
}
else
client_print(id, print_chat, "[%s] The timer isnt started yet!", szPrefix);
menu_display(id, menu);
}
}
}
public CreateTimer()
{
g_fTimer[0] += 0.1;
set_hudmessage(0, 170, 255, 0.0, 0.75, 0, 6.0, 0.1)
show_hudmessage(0, "Timer Menu:^nTime: %.1f^nLast reset: %.1f",g_fTimer[0], g_fTimer[1])
}
stock get_name( index )
{
new szName[32];
get_user_name(index, szName, 31);
return szName;
}