fairyoggy Posted October 3, 2019 Posted October 3, 2019 For example, an account has a value: setAccountData (acc, "time", "10" ) How to make a timer on the server, by which in a minute this value will be "9" and after another 9 minutes it will become "0" Account must be offline
Moderators IIYAMA Posted October 3, 2019 Moderators Posted October 3, 2019 6 hours ago, slapz0r said: How to make a timer on the server The data type time in your database is not something you should animate. https://wiki.multitheftauto.com/wiki/GetRealTime Create your end time: (seconds) > End time (start time + duration) That is all you have to save. Remaining time = (End time - current time) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
fairyoggy Posted October 16, 2019 Author Posted October 16, 2019 @IIYAMA Can you give me example in code? I can’t understand how to use it correctly. I could only get this but how can i use it in my goal ? local time = getRealTime() local hours = time.hour local minutes = time.minute local seconds = time.second local duration = 10 local endtime = seconds + duration local curtime = hours..":"..minutes..":"..seconds local remaintime = endtime - curtime
Moderators IIYAMA Posted October 16, 2019 Moderators Posted October 16, 2019 4 hours ago, slapz0r said: I could only get this but how can i use it in my goal ? Use timestamp. Check the docs. And no I currently can't give any examples as I am extremely busy with a real life project that is killing all the hours I have. Please ask somebody else. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Overkillz Posted October 16, 2019 Posted October 16, 2019 (edited) Thats all what you need (If I didnt forget anything) local theTime = getRealTime() local secondsToAdd = 4500 local timeForPlayer = theTime.timestamp+(secondsToAdd) setAccountData (acc, "time", timeForPlayer ) --Your checker funciton local theTime = getRealTime() if theTime.timestamp > getAccountData(acc,"time") then -- DO WHATEVER YOU WANT end Edited October 16, 2019 by Overkillz
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