SA-MP Forums Archive
[Include] A_TimeFunctions ( Perfect for timing systems ) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] A_TimeFunctions ( Perfect for timing systems ) (/showthread.php?tid=404884)



a_timefunctions 0.2 (Update) - gabyk - 04.01.2013

a_timefunctions
Include
Introduction

Creator: Armyw0w ( PAWN Team )
Credits: FarSe ( Expiry date scheme )
Description: This include uses 3 timing functions.
Original topic: Click here

Download


(All copyrights go to © GTA-MP Romania)

Functions

Update 0.2

Fix bug at A_DifferenceTime.
Added A_FormatTime function.

Use

1. A_CalculateDate
This function is used for calculating a future date. What does this mean? Let's say we have the following time: (actual time) (22:07) and we want it 10 hours forward. A normal calculator would result 32, but this include will cronologically calculate it, so the calculated time will be 08:07 AM.

pawn Code:
new year, month, day, hour = 10, min, sec;
A_CalculateDate ( year, month, day, hour, min, sec );
printf ( "%d:%d:%d %d/%d/%d", hour, min, sec, day, month, year );
In order to understand the function, you can use variables to replace all the function parameters.
After calculating, the result will be the chronologically calculated date.
So if the current date is (21:17:0 4/1/2013), the result will be:

pawn Code:
7:17:0 5/1/2013
2. A_ExpireDate

This function is used for checking if the current date passes the stabilised date.

pawn Code:
new year, month, day, hour, min, sec;
getdate ( year, month, day ), gettime ( hour, min, sec );
if ( A_ExpireDate ( 2013, 1, 5, 21, 30, 0 ) )
{
      print ( "It passed 5/1/2013 21:30:0!" );
} else {
      print ( "It isn't yet 5/1/2013 21:30:0!" );
}
Returns 0 if it didn't expire.

3. A_DifferenceDate

This function differences two dates.

pawn Code:
A_Difference_Second ( 0, 0 );
A_Difference_Minute ( 42, 42 );
A_Difference_Hour ( 21, 19 );
A_Difference_Day ( 4, 4 );
A_Difference_Month ( 1, 1 );
A_Difference_Year ( 2013, 2013 );

new year, month, day, hour, min, sec;
A_Difference_Date ( year, month, day, hour, min, sec );

printf ( "%d:%d:%d %d/%d/%d", hour, min, sec, day, month, year );
Now it will be returned:

pawn Code:
2:0:0 0/0/0
So the difference of time between the two dates is: 2 hours.

4. A_FormatTime

Ok, so the function A_FormatTime will return with a text ( ex: month: 3, days: 5, minutes: 39, seconds: 15 )
If from years to seconds the value is 0, it doesn't will show.
Ex: If year and mounth have the value 0, it doesn't appear.

pawn Code:
printf ( "You still have to wait: %s", A_FormatTime ( 0, 0, 5, 0, 0, 0 ) );
Now it will be returned:

pawn Code:
You still have to wait: days: 5, hours: 0, minutes: 0, seconds: 0
P.S: This function it combine very good with A_DifferenceDate.

The end

This include is made for GTA-MP Romanian Community.
Thank you!


Re: A_TimeFunctions ( Perfect for timing systems ) - DiGiTaL_AnGeL - 04.01.2013

Good work Army, repped+! Keep up the good work!


Re: A_TimeFunctions ( Perfect for timing systems ) - gabyk - 04.01.2013

Thanks!


Re: A_TimeFunctions ( Perfect for timing systems ) - gabyk - 21.01.2013

Update 0.2

Fix bug at A_DifferenceTime.
Added A_FormatTime function.


Re: A_TimeFunctions ( Perfect for timing systems ) - DiGiTaL_AnGeL - 12.05.2013

Reinstalled my system, link down.


Re: A_TimeFunctions ( Perfect for timing systems ) - Pottus - 02.06.2013

Anyone have a link to this include ?


Re: A_TimeFunctions ( Perfect for timing systems ) - Vlad_Dredd - 02.06.2013

Re-Upload please


Re: A_TimeFunctions ( Perfect for timing systems ) - czerwony03 - 07.06.2013

need re-upload :/