[FilterScript] Advanced Time (and date)
#1

I present to you my new (and fast) created filterscript: "Advanced Time".

What is it
Basically, your server will get a date and time. You can choose to sync this with the server or not.
When the time goes from 23:59:59 to 00:00:00, the day will also go to the next day.
There are calculations to check if a month has 28, 29, 30 or 31 days (on quite a simple way); no matter what day, time or year it is, no matter if you have a "fake" date and time or if it is synchronised with the server; the day-month ratio will always be correct as in reallife.
There are 3 time types:

TIME_DEFAULT (GTA:San Andreas standard):
Time will go at GTA:SA speed: 1 second in reallife is 1 minute in-game.
You can choose any date or time with this type, and freeze the time.

TIME_NORMAL (Normal speed):
Time will go at normal speed as in reallife: 1 second in reallife is 1 minute in-game.
You can choose any date or time with this type, and freeze the time.

TIME_SYNC (Server-synchronised):
Time and date are synchronised with the server. You can not modify or freeze the date or time with this type.


All the stats will be saved into a file inside the scriptfiles directory (called "time.conf"). The structure of this file goes like this (in case you want to edit it):
Код:
time_type
year
month
day
hour
min
sec
So if you have the TIME_NORMAL as time type (which is ID 1), and the date and time (DD-MM-YYYY HH:MM:SS) would be this: 30-10-2014 02:41:16, your file would look like this:
Код:
1
2014
10
30
2
41
16
Functions
This is (yet) a basic script for when you need a date/time script in your server. I did add functions, but not commands (yet). These are the functions:

SetTime(hour, minute, second); - Well, change the time of the server
SetDate(day, month, year); - Obviously aswell
SetTimeType(type); - Change the time type. Eg. if you have synchronised time and you are tired of not being able to change the time (which is impossible with the TIME_SYNC), you can change it.
ToggleTime(bool:toggle); - Freeze or unfreeze the time. Use 'true' to freeze the time and use 'false' to unfreeze the time. Also doesn't work with TIME_SYNC

Credits
* Jochemd for the TimestampToDate include. You can find it here: https://sampforum.blast.hk/showthread.php?tid=347605
* Myself off course.

You may remove the credits inside the scripts, but that's not really necesarry, is it?

Download
AdvancedTime v0.0.23-RC (Release Candidate): http://pastebin.com/Xgth3xJz


In progress
Код:
Nothing yet
If you have any questions, suggestions or bug reports, please let me know!
Reply
#2

I pretty much like the synced time system, I do believe this could come in handy. Great job
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)