Jump to content

textCreateTextItem


Recommended Posts

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 by TorNix~|nR
Link to post

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 post
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 by SpecT
  • Thanks 1
Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...