Raised This Month: $300 Target: $400
 75% 

Solved Stopwatch for Server


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tepegoz
Member
Join Date: Apr 2019
Old 03-31-2020 , 18:55   Stopwatch for Server
Reply With Quote #1

I want to stopwatch plugin for my cs 1.6 server.
When I type /start , timer will start and when I type /stop timer will stop.
I want hud message as Hours:Minute:Seconds on screen(all players must see on their screens).

Last edited by tepegoz; 04-01-2020 at 05:30.
tepegoz is offline
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
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 03-31-2020 , 20:41   Re: Stopwatch for Server
Reply With Quote #3

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(PLUGINVERSIONAUTHOR);
    
register_clcmd("say""stopwatch");
}

public 
stopwatch(id)
{
    new 
said[32];
    
read_argv(1saidcharsmax(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), timeformatcharsmax(timeformat));
        
set_hudmessage(00255, -1.00.3500.51.00.00.1, -1);
        
show_hudmessage(0"%s"timeformat);
        
set_task(1.0"show_sw"task);
    }
}

get_time_format(Float:timesresult[], 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"hourminsec);

__________________
+ARUKARI- is offline
tepegoz
Member
Join Date: Apr 2019
Old 04-01-2020 , 05:29   Re: Stopwatch for Server
Reply With Quote #4

thanks it is working.
tepegoz is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:56.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode