Jump to content

Sending timer from server-side to client-side and vice-versa


GTX

Recommended Posts

How can I send a timer (so, I can do getTimerDetails later) from server-side to client-side? At the moment, I'm using this:

Server-sided code:

  
function endA() 
    -- Something. 
end 
  
endTimer = setTimer(endA, 60000, 1) 
if isTimer(endTimer) then 
    -- Success. 
    triggerClientEvent("onTimerRecieve", root, endTimer) 
end 
  

Client-sided code:

  
local endTimer 
  
function draw() 
    if isTimer(endTimer) then 
        -- Nothing here. Maybe timer is not timer? 
        local a, b, c = getTimerDetails(endTimer) 
        if a then 
            dxDrawText(a, 10, 10) 
        end 
    end 
end 
addEventHandler("onClientRender", root, draw) 
  
addEvent("onTimerRecieve", true) 
addEventHandler("onTimerRecieve", root, 
    function(timer) 
        -- Success till here. 
        outputDebugString(type(timer)) -- Returns: userdata. 
        endTimer = timer 
    end 
) 
  

The text doesn't draw. Maybe sent timer isn't a timer?

Thanks in advance.

Link to comment

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...