Thread: [Solved] Stopwatch for Server
View Single Post
tepegoz
Senior Member
Join Date: Apr 2019
Old 06-17-2020 , 08:58   Re: Stopwatch for Server
Reply With Quote #9

Quote:
Originally Posted by +ARUKARI- View Post
Not Tested.
PHP Code:
#pragma semicolon 1
#include <amxmodx>
#include <hamsandwich>

#define PLUGIN    "StopWatch"
#define VERSION    "0.1"
#define AUTHOR    "Aoi.Kagase"
#define TASK_ID    1122

enum _:WATCH_STATUS
{
    
START,
    
STOP,
}
new 
g_starttime;
new 
g_counttime;
new 
WATCH_STATUS:g_status;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd("say""stopwatch");
    
RegisterHam(Ham_Think"player""ThinkTime");
}

public 
stopwatch(id)
{
    new 
said[32];
    
read_argv(1saidcharsmax(said));

    if (
equali(said,"/start"))
    {
        
g_starttime get_systime();
        
g_counttime 0;
        
g_status WATCH_STATUS:START;
        return 
PLUGIN_HANDLED;
    } else
    if (
equali(said"/stop"))
    {
        
g_counttime = (get_systime() - g_starttime);
        
g_status WATCH_STATUS:STOP;
        return 
PLUGIN_HANDLED;
    } else
    if (
equali(said"/pause"))
    {
        
g_counttime = (get_systime() - g_starttime);
        
g_status WATCH_STATUS:STOP;
        return 
PLUGIN_HANDLED;
    } else
    if (
equali(said"/resume"))
    {
        
g_status WATCH_STATUS:START;
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}

public 
ThinkTime(id)
{
    static 
timeformat[8];

    switch(
g_status)
    {
        case 
START:
        {
            
get_time_format((get_systime() - g_starttime) + g_counttimetimeformatcharsmax(timeformat), 0);
            
set_hudmessage(00255, -1.00.3500.51.00.00.1, -1);
            
show_hudmessage(0"[STOP WATCH]: %s"timeformat);
        }
        case 
STOP:
        {
            
get_time_format(g_counttimetimeformatcharsmax(timeformat), 0);
            
set_hudmessage(00255, -1.00.3500.55.00.00.1, -1);
            
show_hudmessage(0"[STOP WATCH]: %s"timeformat);
        }
    }
}

get_time_format(timesresult[], lenmode)
{
    switch(
mode)
    {
        case 
'H':
            
format_time(resultlen"%H"times);
        case 
'M':
            
format_time(resultlen"%M"times);
        case 
'S':
            
format_time(resultlen"%S"times);
        default:
            
format_time(resultlen"%H:%M:%S"times);
    }

Thanks but not working.
tepegoz is offline