Raised This Month: $ Target: $400
 0% 

/time countdown


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 10-29-2022 , 10:26   Re: /time countdown
Reply With Quote #4

I think that using parse_time we were able to overcome the problem of months with plus or minus days.

PHP Code:
#include <amxmodx>

#define PLUGIN  "AlliedTest"
#define VERSION "1.0"
#define AUTHOR  "iceeedR"

new g_CvarDate[30]

public 
plugin_init()
{
        
register_plugin(PLUGINVERSIONAUTHOR)

        
bind_pcvar_string(create_cvar("amx_target_time""09:00:00 11/22/2023"), g_CvarDatecharsmax(g_CvarDate))
}

public 
plugin_cfg() 
        
CalculateStrings()

public 
CalculateStrings()
{
        new 
iTargetDateTime parse_timeg_CvarDate "%H:%M:%S %m/%d/%Y" )
        new 
iCurrentDateTime get_systime()

        new 
Counter iTargetDateTime iCurrentDateTime
        
        
new iSeconds iMinutes iHours iDays

        convert_seconds
Counter iSeconds iMinutes iHours iDays );

        if(
Counter 0)
        {
                if(
iDays)
                {
                        
server_print("Time to day %s: %d day(s) and %d Hour(s)"g_CvarDateiDaysiHours)
                        return 
PLUGIN_HANDLED
                
}

                
server_print("Time to day %s: %d:%d:%d"g_CvarDateiHoursiMinutesiSeconds)
                return 
PLUGIN_HANDLED
        
}
        else
        {
                
server_print("Has passed: %d day(s) %d Hour(s) %d Minute(s) and %d Second(s) until %s"iDays *= -1iHoursiMinutesiSecondsg_CvarDate)
                return 
PLUGIN_HANDLED
        
}
}

convert_secondsiTotalSeconds , &seconds , &minutes , &hours , &days )
{
        
days iTotalSeconds 86400
        hours 
= ( iTotalSeconds 3600 ) % 24
        minutes 
= ( iTotalSeconds 60 ) % 60
        seconds 
iTotalSeconds 60

It is also possible to get the time elapsed from the date.

HTML Code:
Time to day 09:00:00 11/22/2023: 388 day(s) e 19 Hour(s)
Has passed: 4 day(s) 3 Hour(s) 49 Minute(s) and 46 Second(s) until 18:00:00 10/25/2022
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 10-29-2022 at 13:11.
iceeedr is offline
Send a message via Skype™ to iceeedr
 


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 10:33.


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