Raised This Month: $ Target: $400
 0% 

/time countdown


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 10-29-2022 , 15:57   Re: /time countdown
Reply With Quote #7

Took it off my VIP Expire plugin, just removed some parts:

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define parseTime(%1)            parse_time(%1, "%m/%d/%Y %H:%M:%S")

const iYearSeconds =            31536000
const iMonthSeconds =             2629800
const DaySeconds =             86400
const HourSeconds =             3600
const MinuteSeconds =             60

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_concmd("amx_display_time""cmdDateCommand"ADMIN_KICK"<date format> - example: 05/01/2025 18:00:00")
}

public 
cmdDateCommand(idiLeveliCid)
{
    if(!
cmd_access(idiLeveliCid2))
        return 
PLUGIN_HANDLED
        
    
new szTime[60]
    
read_argv(1szTimecharsmax(szTime))
    
    new 
szMessage[192], iTime parseTime(szTime)
    
formatTime(iTimeszMessagecharsmax(szMessage))
    
console_print(id"Time remaining: %s"szMessage)
    return 
PLUGIN_HANDLED
}

formatTime(iTimeszMessage[] = ""iLen 0

    if(!
iTime)
    {
        
formatex(szMessageiLen"No time to expire")
        return
    }
    
iTime -= get_systime()
    
    new 
iYeariMonthiDays
    
new iHouriMinuteiSecond
    iTime 
-= iYearSeconds * (iYear iTime iYearSeconds)
    
iTime -= iMonthSeconds * (iMonth iTime iMonthSeconds)
    
iTime -= DaySeconds * (iDays iTime DaySeconds)
    
iTime -= HourSeconds * (iHour iTime HourSeconds
    
iTime -= MinuteSeconds * (iMinute iTime MinuteSeconds
    
iSecond iTime

    
new szMessageFmt[64]
    if(
iYear)
    {
        
formatex(szMessageFmtiLen"%s%d year%s"szMessageFmtiYear, (iYear 1) ? "s" "")
    }

    if(
iMonth)
    {
        
formatex(szMessageFmtiLen"%s, %d month%s"szMessageFmtiMonth, (iMonth 1) ? "s" "")
    }

    if(
iDays)
    {
        
formatex(szMessageFmtiLen"%s%s %d day%s"szMessageFmtiHour "," " and"iDays, (iDays 1) ? "s" "")
    }
        
    if(
iHour)
    {
        
formatex(szMessageFmtiLen"%s%s %d hour%s"szMessageFmtiMinute "," " and"iHour, (iHour 1) ? "s" "")
    }
        
    if(
iMinute)
    {
        
formatex(szMessageFmtiLen"%s%s %d minute%s"szMessageFmtiSecond "," " and"iMinute, (iMinute 1) ? "s" "")
    }
        
    if(
iSecond)
    {
        
formatex(szMessageFmtiLen"%s and %d second%s"szMessageFmtiSecond, (iSecond 1) ? "s" "")
    }
    
copy(szMessageiLenszMessageFmt)

To use the command properly:

amx_display_time month/day/year
If you want to know by hour/minute/second, just pass them as hour:minute:second

Example: amx_display_time "10/30/2023"

Code:
Time remaining: 1 year and 1 day
Example: amx_display_time "6/30/2027"

Code:
Time remaining: 4 years, 8 months, 1 day and 12 hours
Example: amx_display_time "6/30/2027 18: 30:15"

Code:
Time remaining: 4 years, 8 months, 1 day, 13 hours, 24 minutes and 52 seconds
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 10-29-2022 at 16:13.
EFFx is offline
 



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