Thread: [Solved] Stopwatch for Server
View Single Post
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 03-31-2020 , 20:33   Re: Stopwatch for Server
Reply With Quote #2

untested

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "StopWatch"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

#define SWID 132465

new iSeconds;
new 
iMinutes;
new 
iHours;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd("say /start""StartStopWatch");
    
register_clcmd("say /stop""StopStartWatch");
}

#if AMXX_VERSION_NUM < 190
public client_disconnect(id)
#else
public client_disconnected(id)
#endif
{
    new 
iPlayers[32], iNum;
    
get_players(iPlayersiNum);
    
    if(
iNum == 0)
    {
        
StopStartWatch(id);
    }
}

public 
StartStopWatch(id)
{
    
set_task(1.0"ShowHud"SWID__"b");
}

public 
ShowHud(id)
{
    if(
iSeconds++ > 60)
    {
        if(
iMinutes++ > 60)
        {
            
iHours++;
        }
    }
    
    
set_hudmessage(42170255, -1.00.7606.01.0);
    
show_hudmessage(id"Stopwatch: %i:%i:%i"iHoursiMinutesiSeconds);
}

public 
StopStartWatch(id)
{
    if(
task_exists(SWID))
    {
        
iSeconds 0;
        
iMinutes 0;
        
iHours 0;
        
        
remove_task(SWID);
    }

__________________

Last edited by Napoleon_be; 03-31-2020 at 22:02.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be