Egor_Varaksa Posted November 18, 2021 Share Posted November 18, 2021 (edited) 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 November 18, 2021 by Egor_Varaksa Link to comment
The_GTA Posted November 18, 2021 Share Posted November 18, 2021 (edited) 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 November 18, 2021 by The_GTA Link to comment
Egor_Varaksa Posted November 20, 2021 Author Share Posted November 20, 2021 Thanks. How do I make it show a maximum of 23 hours and 59 minutes? https://imgur.com/a/ARAK9Fh Link to comment
The_GTA Posted November 20, 2021 Share Posted November 20, 2021 (edited) You forgot to apply the same scheme for calculation as I did the minutes, with the use of modulus operator. Try a % 24. Edited November 20, 2021 by The_GTA Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now