AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Converting a specific date to epoch (https://forums.alliedmods.net/showthread.php?t=244505)

Bladell 07-19-2014 13:14

Converting a specific date to epoch
 
I want to make a plugin wich execute a certain command at a specific time. There are some cvar like:
Code:

        p_Year = register_cvar("sh_resetyear", "2014")
        p_Month = register_cvar("sh_resetmonth, "1")
        p_Day = register_cvar("sh_resetday", "1")
        p_Hour = register_cvar("sh_resethour", "1")
        p_Minute = register_cvar("sh_resetminute", "1")
        p_Second = register_cvar("sh_resetsecond", "1")

So, in 2014, first month of the year, first day of the month, first hour of the day, first minute of the hour and first second of the minute a command will be executed.
I need to transform a date into epoch time so I could use get_systime() and obatin the difference(in seconds) between today and a specific date. After I get the result of this difference I can easily find out how many days, hours, minutes and seconds are until the execution of the command, so I can show it on a hud message.
Now you know what my plugin should do. I think that this method is the best, if you know another wich is better please share it with me or help me to transform a specific date into epoch.

Flick3rR 07-19-2014 13:39

Re: Converting a specific date to epoch
 
Well, as far as I know, you have to convert each value to seconds (because that's the value of get_systime). So simply increase the values by 60, 3600, 86400, etc. I tihnk you got my idea. Take a look here, too, https://forums.alliedmods.net/showthread.php?t=23912

Bladell 07-21-2014 03:13

Re: Converting a specific date to epoch
 
Right... I have to convert each value to seconds. Try to convert a date and you'll find out that is not as simple as you think since there are years with 365 days, 366 days etc...

YamiKaitou 07-21-2014 03:38

Re: Converting a specific date to epoch
 
Rather than trying to figure out how to convert it, try explaining what it is that you are doing. There may be an easier way

Backstabnoob 07-21-2014 05:17

Re: Converting a specific date to epoch
 
Also, there is a cronjob plugin for AMXX.

Bladell 07-21-2014 07:17

Re: Converting a specific date to epoch
 
I am trying to make a plugin wich execute a command at a specific date, hour and minute. This plugin should also show a cooldown in last 3 days.(e.g. 2 days, 8 hours, 1 minute, 32 seconds)

Backstabnoob 07-21-2014 08:13

Re: Converting a specific date to epoch
 
I like the fact you completely ignored my post, but I'll be nice and post you a link anyway:
https://forums.alliedmods.net/showth...=69068?t=69068

Bladell 07-21-2014 09:33

Re: Converting a specific date to epoch
 
I ignored your post because it doesn't help me. I already knew about this plugin... isn't good for me because have many useless features for me. Also, I can't add a hud countdown message.

Backstabnoob 07-21-2014 10:47

Re: Converting a specific date to epoch
 
Then good luck recreating something that already exists.

meTaLiCroSS 07-21-2014 22:26

Re: Converting a specific date to epoch
 
Our friend Bugsy made a useful include time ago: https://forums.alliedmods.net/showthread.php?t=91915 take a look and use TimeToUnix.


All times are GMT -4. The time now is 12:59.

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