Possible to display a serverside timer on client?

Title says it all. Is it possible? if so, how?

If the client knows what time it started and the duration of the timer then its completely possible

Yea, client knows the duration since its in a table and I could make it know when it started.

Are you suggesting a timer on the client? That wouldn’t work since the function server-side checks your inventory and if its found the item, it sets a timer.
The only way I could think of was just fetching the serverside timer if it exists.

Explain what you are trying to do and I will tell you how to do it

Im trying to make the client display a timer set serverside that’s only created if another serverside value is true.

Is it a timer or a countdown?
If it’s a simple timer you just need to tell the client to start it from the server using the net Library, heres how it would work.



-- CLIENT
START_TIME = 0
TIMER = false
function StartTimer()
    START_TIME = CurTime()
    TIMER = true
end

hook.Add("Think", "LolImAHook", function ()
    if TIMER then
        print(CurTime() - START_TIME)
    end
end)


I don’t think that would work in this case.
Heres some code to help.



--Client
CCraftButton.DoClick = function()
			net.Start("CheckCraftable")
	        net.WriteString(v.Class)
            net.WriteString(v.ENT_Model)
            net.WriteString(v.CraftXP)
            net.WriteString(v.C_level)
	    net.WriteString(v.CraftTimer)
	        net.SendToServer()
end




--Serverside

if timer.Exists("CraftingObjectItem:"..ply:UniqueID().." Class:"..Class.."") or ply.CraftingShit then return end
if ply:GetCExp() < level then return end

if ply:GetItem( Class ) then --If the player has the shit in his inventory, then do this
ply.CraftingShit = true
timer.Create("CraftingObjectItem:"..ply:UniqueID().." Class:"..Class.."",time,1,function()
--Code for my shit
end)


Ok what you need to display on the client is a countdown, All you need to send to the client is when the timer will run it’s callback which is CurTime() + time



net.Receive("ReceiveTimer", function()
    TIMER_END = net.ReadInt()
end)

hook.Add("Think", "LolImAHook", function ()
    if CurTime() <= TIMER_END then
        print(TIMER_END - CurTime())
    end
end)


That worked. Thanks :slight_smile: