 |
|
Senior Member
|

06-16-2020
, 10:57
Re: Stopwatch for Server
|
#4
|
Quote:
Originally Posted by +ARUKARI-
I was late
PHP Code:
#pragma semicolon 1
#include <amxmodx>
#define PLUGIN "StopWatch"
#define VERSION "0.1"
#define AUTHOR "Aoi.Kagase"
#define TASK_ID 1122
new g_stopwatch = false;
new Float:g_starttime;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("say", "stopwatch");
}
public stopwatch(id)
{
new said[32];
read_argv(1, said, charsmax(said));
if (equali(said,"/start"))
{
g_stopwatch = true;
g_starttime = get_gametime();
set_task(0.1, "show_sw", TASK_ID + id);
return PLUGIN_HANDLED;
} else
if (equali(said, "/stop"))
{
g_stopwatch = false;
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public show_sw(task)
{
if (g_stopwatch)
{
new timeformat[8];
get_time_format((get_gametime() - g_starttime), timeformat, charsmax(timeformat));
set_hudmessage(0, 0, 255, -1.0, 0.35, 0, 0.5, 1.0, 0.0, 0.1, -1);
show_hudmessage(0, "%s", timeformat);
set_task(1.0, "show_sw", task);
}
}
get_time_format(Float:times, result[], len)
{
new hour = floatround(times) / 60 /60;
new min =(floatround(times) / 60) % 60;
new sec = floatround(times) % 60;
formatex(result[0], len, "%i:%i:%i", hour, min, sec);
}
|
Hi I want to stop and resume the time. Can you help me? When I type /stop the timer will stop, and when I type /resume the timer will resume from old time.
|
|
|
|