Jump to content

Server side variable passed to client side?


Atti

Recommended Posts

Posted

Can I sync a variable between server and client?

i.e. i want to create a server-side timer with a variable that is passed to my client-side script, where it's used for a GUI.

So

--server side:

on start -> var=500

every second -> var=var-1

--client side:

every second -> print(tostring(var))

Actually with this code i get "nil" client-side. How can I do?

Posted

I usually just start a game round by using triggerClientEvent() and passing any variables the client needs (round duration etc.) to a client-side event which I've made e.g. "startRace"

Posted

element data is also synced ( setElementData / getElementData )

PS) you shouldn't send data too often tho and for long periods of time, it's bandwith consuming

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