Jump to content

Variables on different scripts.


Dreft

Recommended Posts

Posted

I have:

scriptone.lua - server side

scripttwo.lua - client side

In server side script "scriptone.lua" i created variable

a = 5

How to know what "a" is equal in client side script "scripttwo.lua" ?

I mean, how to move variables through all same resource scripts ?

Posted

It's easy to get them in another server-side script. Synching client-side though can pretty much only be done with triggerClientEvent/triggerServerEvent or setElementData. (imagine the bandwidth usage if every single var that has changed was synched :P)

Posted
It's easy to get them in another server-side script.

Uhm.. ok, how to get it in another server-side script ? If i set a = 5, then in others server-side scripts its automatically set to 5 too ?

Posted
If i set a = 5, then in others server-side scripts its automatically set to 5 too ?

Yup

Script 1:

a=5

Script 2:

outputDebugString(tostring(a))

Output:

INFO: 5
Posted

Oh, easy. Thanks for help ;)

And one more question on topic :}

Script 1:

setElementData( thePlayer, "variable.a", 5 )

Script2:

a = getElementData( thePlayer, "variable.a" )

This will be right ?

Posted

its true, but i think this is not what he meant. it sounds much more like he wanted to know if two separate resources can share cvariables... which would be CHAOS :P

SO: Serverside global variables can be reached within this single resource, no matter if you used two different files in your resource, but wont be existing in other resources.

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