Panda Posted December 27, 2014 Posted December 27, 2014 Hello Everyone, i tried to make something, i mean the car spawn after 10 secs when i press on the button! I don't what to do to make it count from 10 to 0 Look what i did! I need help Thanks. function drawDisplay() local message = "Your car will be spawned in"..tonumber(10).." seconds." dxDrawText(message,2,2,resX + 2,102,tocolor(255,255,255,255),2,"default-bold","center","center",true,true,false) dxDrawText(message,0,0,resX,100,tocolor(255,255,255,200),2,"default-bold","center","center",true,true,false) end function startDisplay(jTime) addEventHandler("onClientRender",root,drawDisplay) end addEvent("hii",true) addEventHandler("hii", localPlayer, startDisplay)
AfuSensi Posted December 27, 2014 Posted December 27, 2014 You can do it with setTimer() getTimerDetails()
Et-win Posted December 27, 2014 Posted December 27, 2014 yourTimer = setTimer(function() --Script stuff (spawnVehicle) end, 10000 --[[Time in milliseconds]], 1 --[[Times to execute]]) And then, with 'getTimerDetails', you can check how much time is left and put it inside of the DX functions.
Panda Posted December 27, 2014 Author Posted December 27, 2014 I still don't get it.. i tried it but it doesn't work. I'm sure that there is a way to count from 10 to 0. local message = "Your car will be spawned in"..tonumber(10).." seconds." Well if there is not, can u help with the "getTimerDetails" ? Thanks mate.
AfuSensi Posted December 27, 2014 Posted December 27, 2014 This is how i would do it (not tested by the way, but hopefully you'll get the general idea): function drawDisplay() if isTimer(theTimer) then -- Check if timer is running to prevent errors local timeLeft = mstoSec(getTimerDetails(theTimer)) -- Get ms from timer and convert to seconds local message = "Your car will be spawned in"..tostring(timeLeft).." seconds." dxDrawText(message, ,2,2,resX + 2,102,tocolor(255,255,255,255),2,"default-bold","center","center",true,true,false) dxDrawText(message, 0,0,resX,100,tocolor(255,255,255,200),2,"default-bold","center","center",true,true,false) end end addEventHandler("onClientRender",root,drawDisplay) function startDisplay(jTime) theTimer = setTimer(function() -- Set the timer -- Write what timer has to execute here, or to a named function end ,10000,1) end addEvent("hii",true) addEventHandler("hii", localPlayer, startDisplay) function mstoSec(ms) local ms = ms/1000 if string.find(tostring(ms),"%.") then local seconds = string.match(tostring(ms),"%d+") return seconds else return ms end end
Panda Posted December 27, 2014 Author Posted December 27, 2014 Wow Man! Thanks mate it works! Thank u once again <3.
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