djharbi2 Posted August 15, 2018 Posted August 15, 2018 Do you have a script that counts back in 10 minutes?
Keiichi1 Posted August 15, 2018 Posted August 15, 2018 setTimer(function() outputChatBox("Time's up!") end, 600000, 1)
djharbi2 Posted August 15, 2018 Author Posted August 15, 2018 2 hours ago, Keiichi1 said: setTimer(function() outputChatBox("Time's up!") end, 600000, 1) I'm counting down. sample 10:00 09:59 09:58 .....
DiGiTal Posted August 15, 2018 Posted August 15, 2018 4 minutes ago, djharbi2 said: I'm counting down. sample 10:00 09:59 09:58 ..... explaine what u searching?
djharbi2 Posted August 15, 2018 Author Posted August 15, 2018 6 minutes ago, DiGiTal said: explaine what u searching? I forgot my friend
djharbi2 Posted August 15, 2018 Author Posted August 15, 2018 https://media.giphy.com/media/ZdT2zDh3Bvnkk/giphy.gif
DiGiTal Posted August 15, 2018 Posted August 15, 2018 https://community.multitheftauto.com/index.php?p=resources&s=details&id=14306
djharbi2 Posted August 15, 2018 Author Posted August 15, 2018 this is not what I want if you look at the picture
djharbi2 Posted August 15, 2018 Author Posted August 15, 2018 (edited) https://media.giphy.com/media/ZdT2zDh3Bvnkk/giphy.gif how can i count down like in the picture ------------------eg countdown from 10 minutes10:00 > 09:59 > 09:58 ..... Edited August 15, 2018 by djharbi2
djharbi2 Posted August 15, 2018 Author Posted August 15, 2018 eg countdown from 10 minutes 10:00 > 09:59 > 09:58 .....
ViRuZGamiing Posted August 15, 2018 Posted August 15, 2018 Just create a variable that represents the timer in seconds (since thats the smallest time you'd want to show) so if you'd want a timer of 10 min you'd have: timer = 600 You'd draw that timer variable as a dxtext on render and decrement the timer by 1. You'd want to convert the 600s to min and seconds tho but thats just some simple math.
djharbi2 Posted August 15, 2018 Author Posted August 15, 2018 1 minute ago, ViRuZGamiing said: Just create a variable that represents the timer in seconds (since thats the smallest time you'd want to show) so if you'd want a timer of 10 min you'd have: timer = 600 You'd draw that timer variable as a dxtext on render and decrement the timer by 1. You'd want to convert the 600s to min and seconds tho but thats just some simple math. do you make an example
ViRuZGamiing Posted August 15, 2018 Posted August 15, 2018 Just now, djharbi2 said: do you make an example I basically told you what to do in text. Just try it, if you encounter a problem I'll gladly help.
Keiichi1 Posted August 15, 2018 Posted August 15, 2018 (edited) Client: local sx, sy = guiGetScreenSize() function renderText() dxDrawText(timeText, sx/2, sy/2, 0, 0, tocolor(255, 255, 255), 2, "default-bold") end function updateTime() if isTimer(timer) then timeText = formatTime(getTimerDetails(timer)) end end addCommandHandler("timer", function(cmd, min) if tonumber(min) then if not isTimer(timer) then local time = tonumber(min) * 60000 timer = setTimer(function() removeEventHandler("onClientRender", getRootElement(), renderText) end, time, 1) setTimer(updateTime, 1000, 0) timeText = formatTime(getTimerDetails(timer)) addEventHandler("onClientRender", getRootElement(), renderText) end else outputChatBox("SYNTAX: /timer [minutes]") end end) function formatTime(ms) local totalseconds = math.floor(ms / 1000) local ms = ms % 1000 local seconds = totalseconds % 60 local minutes = math.floor(totalseconds / 60) % 60 return string.format("%02d:%02d", minutes, seconds) end Edited August 15, 2018 by Keiichi1 2
djharbi2 Posted August 16, 2018 Author Posted August 16, 2018 8 hours ago, Keiichi1 said: Client: local sx, sy = guiGetScreenSize() function renderText() dxDrawText(timeText, sx/2, sy/2, 0, 0, tocolor(255, 255, 255), 2, "default-bold") end function updateTime() if isTimer(timer) then timeText = formatTime(getTimerDetails(timer)) end end addCommandHandler("timer", function(cmd, min) if tonumber(min) then if not isTimer(timer) then local time = tonumber(min) * 60000 timer = setTimer(function() removeEventHandler("onClientRender", getRootElement(), renderText) end, time, 1) setTimer(updateTime, 1000, 0) timeText = formatTime(getTimerDetails(timer)) addEventHandler("onClientRender", getRootElement(), renderText) end else outputChatBox("SYNTAX: /timer [minutes]") end end) function formatTime(ms) local totalseconds = math.floor(ms / 1000) local ms = ms % 1000 local seconds = totalseconds % 60 local minutes = math.floor(totalseconds / 60) % 60 return string.format("%02d:%02d", minutes, seconds) end thanks bro
Discord Moderators Pirulax Posted August 16, 2018 Discord Moderators Posted August 16, 2018 (edited) function formatTime(ms) local totalseconds = math.floor(ms / 1000) return string.format("%.2i:%.2i", math.floor(totalseconds / 60) % 60, totalseconds % 60) end Edited August 16, 2018 by Pirulax 1
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