i try to do timer of arrest time left and the number rises and does not fall
local endTime = v:GetNWFloat("TimeArrested") + v:GetNWFloat("ArrestLength")
local timeLeft = math.max(math.Round(endTime - CurTime()), 0)
print(CurTime(), v:GetNWFloat("TimeArrested"), v:GetNWFloat("ArrestLength"))
Try something like this, if it still doesn't work tell us what is printed in your console.
the console print 0
Are you using DarkRP with the regular jail system?
yeah
I looked at DarkRP's code and this looks like abit messy to get working.
Try this
local StartArrested
local ArrestedUntil
usermessage.Hook("GotArrested", function(msg)
StartArrested = CurTime()
ArrestedUntil = msg:ReadFloat()
end)
hook.Add("HUDPaint", "asdf", function()
if LocalPlayer():getDarkRPVar("Arrested") and StartArrested then
local timeLeft = math.max(math.ceil(ArrestedUntil - (CurTime() - StartArrested)), 0)
print(timeLeft)
end
end)
it is dosent work . if you dont know to fix that it is ok but if you know you can to continue
-- Use boolean and float to make drawing check more efficient
local bArrested = false
local flArrestEndTime = 0
usermessage.Hook("GotArrested", function(msg)
local flTime = msg:ReadFloat()
local flCurTime = CurTime()
-- Have they already been unarrested?
if (flTime > flCurTime) then
bArrested = true
flArrestEndTime = flTime
end
end)
hook.Add("HUDPaint", "DrawArrestedTime", function()
if (bArrested) then
local flCurTime = CurTime()
if (flArrestEndTime > flCurTime) then
local iSecondsLeft = math.ceil(flArrestEndTime - flCurTime)
-- Do drawing here
else
bArrested = false
end
end
end)
Sorry, you need to Log In to post a reply to this thread.