Raised This Month: $60 Target: $400
 15% 

Add milliseconds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HowToRuski
Member
Join Date: Feb 2019
Location: Latvia
Old 10-17-2020 , 09:07   Add milliseconds
Reply With Quote #1

Hey, i wondered how to add milliseconds to this plugin? Because when i searched on google there wasnt what i needed...
Any help is appreciated.

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


#include <amxmodx>
#include <cstrike>

#define PLUGIN "Auto Restart vl"
#define VERSION "1.4"
#define AUTHOR "vato loco [GE-S]"

#define TIMER_TASK        123456
#define RESTART_TASK      789123

new g_counter  

new g_autorestart
new g_autoenabled
new g_autocds
new g_autocount_color
new g_autostart_color
new g_auto_xypos

new g_SyncRestartTimer

new bool:g_bRoundStart 

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_logevent("RoundStart"2"1=Round_Start")
    
register_event("TextMsg","RestartTask","a","2&#Game_C")   
    
    
register_dictionary("auto_restart_vl.txt")
    
    
g_autoenabled register_cvar("amx_autorr_enable","1")
    
g_autocds register_cvar("amx_autorr_cds","1")
    
g_autorestart register_cvar("amx_autorr_time","15")
    
g_autocount_color register_cvar("amx_autorr_count_color","255 0 0")
    
g_autostart_color register_cvar("amx_autorr_start_color","0 255 255")
    
g_auto_xypos register_cvar("amx_autorr_xypos","-1.0 0.25")
    
    
g_SyncRestartTimer CreateHudSyncObj()
}

public 
RoundStart()
{
    if(!
get_pcvar_num(g_autoenabled))
        return 
PLUGIN_HANDLED
    
    
if(g_bRoundStart)
    {
        static 
rgbFloat:xFloat:y
        HudMsgPos
(x,y)
        
HudMsgColor(g_autostart_colorrgb)
        
        
set_hudmessagerandom(256),random(256),random(256), xy15.08.00.00.0, -1)
    }
    
g_bRoundStart false
    
    
return PLUGIN_CONTINUE
}

public 
RestartTask() 
{
    if(!
get_pcvar_num(g_autoenabled))
        return 
PLUGIN_HANDLED
    
    set_task
(1.0,"TimeCounter",TIMER_TASK,_,_,"a",get_pcvar_num(g_autorestart))
    
set_task(get_pcvar_float(g_autorestart),"RestartRound",RESTART_TASK)
    
    return 
PLUGIN_CONTINUE
}

public 
TimeCounter(id
{
    
    
g_counter++
    
    new 
Float:iRestartTime get_pcvar_float(g_autorestart) - g_counter
    
new Float:fSec
    fSec 
iRestartTime 
    
    
static rgbFloat:xFloat:y
    HudMsgPos
(x,y)
    
HudMsgColor(g_autocount_colorrgb)
    
    
set_hudmessagerandom(256),random(256),random(256), xy00.01.00.00.0, -1)
    
ShowSyncHudMsg0g_SyncRestartTimer"%L",LANG_PLAYER"AUTO_RESTART"floatround(fSec))
        
    if(
get_pcvar_num(g_autocds) && get_pcvar_num(g_autorestart) - g_counter 11 && get_pcvar_num(g_autorestart) - g_counter !=0)
    {
        static 
szNum[32]
        
num_to_word(get_pcvar_num(g_autorestart) - g_counterszNum31)
    }
    if(
g_counter == get_pcvar_num(g_autorestart))
    {
        
g_bRoundStart true
        g_counter 
0
    
}
}

public 
RestartRound() 
{
    
server_cmd("sv_restartround 1")
}

public 
HudMsgColor(cvar, &r, &g, &b)
{
    static 
color[16], piece[5]
    
get_pcvar_string(cvarcolor15)
    
    
strbreakcolorpiece4color15)
    
str_to_num(piece)
    
    
strbreakcolorpiece4color15)
    
str_to_num(piece)
    
str_to_num(color)
}

public 
HudMsgPos(&Float:x, &Float:y)
{
    static 
coords[16], piece[10]
    
get_pcvar_string(g_auto_xypos coords15)
    
    
strbreak(coordspiece9coords15)
    
str_to_float(piece)
    
str_to_float(coords)

HowToRuski is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-17-2020 , 15:42   Re: Add milliseconds
Reply With Quote #2

use floats, easy as that lol..
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
HowToRuski
Member
Join Date: Feb 2019
Location: Latvia
Old Yesterday , 02:38   Re: Add milliseconds
Reply With Quote #3

Quote:
Originally Posted by Napoleon_be View Post
use floats, easy as that lol..
Any examples on how to do that, as im new to amxx?
HowToRuski is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old Yesterday , 03:50   Re: Add milliseconds
Reply With Quote #4

To show fractional seconds in the HUD message, you would need to change the AUTO_RESTART value in the lang files (for all lanugages) to use "%.3f" instead of "%i" or "%d" and then change floatround(fSec) to fSec.

But note it will probably look really strange because it only updates the value once every second.
__________________
fysiks is offline
HowToRuski
Member
Join Date: Feb 2019
Location: Latvia
Old Yesterday , 14:25   Re: Add milliseconds
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
To show fractional seconds in the HUD message, you would need to change the AUTO_RESTART value in the lang files (for all lanugages) to use "%.3f" instead of "%i" or "%d" and then change floatround(fSec) to fSec.

But note it will probably look really strange because it only updates the value once every second.
And whats the possbile way to make it update every millisecond?
HowToRuski is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old Today , 09:34   Re: Add milliseconds
Reply With Quote #6

Quote:
Originally Posted by HowToRuski View Post
Any examples on how to do that, as im new to amxx?
Didn't realize you wanted it to be shown in the hud.

Quote:
Originally Posted by HowToRuski View Post
And whats the possbile way to make it update every millisecond?
You could update it every few miliseconds using set_task, but that's probably not good for your server as this might cause lagg or even crash your server.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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 22:26.


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