TorNix~|nR Posted January 18, 2021 Share Posted January 18, 2021 (edited) Hello guys, I have a problem, I have this jail system and I added textCreateTextItem to start counting the left jail time but it didn't work local jailtime = jailLeftTimer[thePlayer] local remaining = getTimerDetails(jailtime) local display = textCreateDisplay () if (jailtime) and (isTimer(jailtime)) then local text = textCreateTextItem("["..math.floor(remaining/1000).."]", 0.15, 0.53, "high", 150, 0, 0, 255, 2, "right", "bottom") textDisplayAddText(display, text) textDisplayAddObserver(display, thePlayer) end I made a command that works fine but only with command addCommandHandler( "jailtime", function (thePlayer) local jailtime = jailLeftTimer[thePlayer] if (jailtime) and (isTimer(jailtime)) then local remaining = getTimerDetails(jailtime) outputChatBox("You have ["..math.floor(remaining/1000).."] left for your jail time.", thePlayer, 0, 255, 0, true) end end) I want to make the textCreateTextItem work, help please by the way, the textCreateTextItem shows only the first left seconds example [200] and it stucks there and never change Edited January 18, 2021 by TorNix~|nR Link to comment
SpecT Posted January 18, 2021 Share Posted January 18, 2021 (edited) textCreateTextItem displays static text. It's not like rendering dxDrawText with onClientRender. To make it work use textItemSetText(text, ...) with a timer (per 1 second maybe?). Edited January 18, 2021 by SpecT 1 Link to comment
TorNix~|nR Posted January 19, 2021 Author Share Posted January 19, 2021 I tried making a timer but didn't know how to make it I tried this but it's the same, stuck at the same remaining time local jailtime = jailLeftTimer[source] if (jailtime) and (isTimer(jailtime)) then local remaining = getTimerDetails(jailtime) local display = textCreateDisplay() local text = textCreateTextItem("", 0.15, 0.53, "high", 150, 0, 0, 255, 2, "right", "bottom") textDisplayAddText(display, text) textDisplayAddObserver(display, source) textItemSetText(text, math.floor(remaining/1000)) end Link to comment
SpecT Posted January 19, 2021 Share Posted January 19, 2021 (edited) updateTimer = setTimer(function() textItemSetText(text, math.floor(remaining/1000)) end,1000,0) -- when the player gets out of the jail if isTimer(updateTimer) then killTimer(updateTimer) end This will create a timer which will trigger the setText function per 1 second so the player will see in real time how much time left to wait. And put the killTimer where you take the player out of jail. Feel free to ask if you can't understand something. Edited January 19, 2021 by SpecT 1 Link to comment
TorNix~|nR Posted January 19, 2021 Author Share Posted January 19, 2021 It's finally working, thank you so much. Link to comment
SpecT Posted January 19, 2021 Share Posted January 19, 2021 4 minutes ago, TorNix~|nR said: It's finally working, thank you so much. You're welcome! 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