Jump to content

Timer


Egor_Varaksa

Recommended Posts

Hello, how can I make it so that when I enter the command /timer 3600, the timer is displayed for the players, and the time 1 hour 00 minutes 00 seconds is displayed on it, and then 59 minutes 59 seconds and so on. In short, I only need the remaining time to be displayed.

Edited by Egor_Varaksa
Link to comment

Hello Egor_Varaksa,

this sounds like a simple time-distance mathematical problem. You define a point in time where you want to count to and calculate the amount of time until that point. In MTA you have the ability to use the getRealTime function to get the timestamp value which is the seconds count since 1970. You should then add 3600 to timestamp and store this as destination time-point (dtp). Then if you want know how much time is left until the dtp simply subtract the current timestamp values retrieved using a current call to getRealTime from dtp = diff_seconds.

diff_seconds = dtp - now

diff_minutes = math.floor( diff_seconds / 60 ) % 60

diff_hours = math.floor( diff_seconds / 3600 )

Have fun!

Edited by The_GTA
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...