Jump to content

Timer sync.


roaddog

Recommended Posts

Posted

Any idea can we make timer in serverside then send it to clientside as a timer?

timer = setTimer(..., 5000, 1) 
triggerClientEvent(el, "timerClient", el) 

addEvent("timerClient", true) 
addEventHandler("timerClient", root, function() 
timer = setTimer(..., 5000, 1) 
end) 

this was my attempt but I need a better synced one

You gone learn today.

I work my ass off, but I still can't pay tho.

Posted

Its not actually "send" the timer (i dont know if it is even possible), but you can use arguments to make the client call variables that were defined server-side.

There's no point on creating a new timer server-side since it will be totally different from the one on client-side and you will just call the function twice (once on client and once on server).

-- Client-side -- 
addEvent("timerClient", true) 
addEventHandler("timerClient", root, function(arguments) 
timer = setTimer(functionName, 5000, 1,arguments) 
end) 
  
-- Server-side -- 
function startTimer() 
arguments = something 
triggerClientEvent("timerClient",source,arguments) 
end 

Of course you have to define the variables and trigger the event on the same server-side function.

Posted

You just gave me a light.

Im gonna do is setTimer in clienside only then call it twice.

Thank you.

You gone learn today.

I work my ass off, but I still can't pay tho.

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