Dreft Posted August 28, 2009 Share Posted August 28, 2009 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 ? Link to comment
Gamesnert Posted August 28, 2009 Share Posted August 28, 2009 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 ) Link to comment
Dreft Posted August 28, 2009 Author Share Posted August 28, 2009 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 ? Link to comment
Gamesnert Posted August 28, 2009 Share Posted August 28, 2009 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 Link to comment
Dreft Posted August 28, 2009 Author Share Posted August 28, 2009 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 ? Link to comment
DutchCaffeine Posted August 28, 2009 Share Posted August 28, 2009 That is very very good, here i got something else: Useful functions: https://wiki.multitheftauto.com/index.ph ... _Functions callClientFunction: https://wiki.multitheftauto.com/index.ph ... ntFunction callServerFunction: https://wiki.multitheftauto.com/index.ph ... erFunction Link to comment
jkub Posted August 28, 2009 Share Posted August 28, 2009 can callClientFunction be a good alternative to triggerClientEvent? Link to comment
CodeMaster Posted August 28, 2009 Share Posted August 28, 2009 Yup it can. https://wiki.multitheftauto.com/index.php?title=CallClientFunction for more info about it (but I guess you found it there). @Gamesnert: You're sure that serverside scripts share variables? Wouldn't that cause some of the confusion? I thought they were separated (partially)... Link to comment
Gamesnert Posted August 28, 2009 Share Posted August 28, 2009 Only vars in different resources or defined with "local" aren't shared. I'm pretty much sure of that yes. Link to comment
CodeMaster Posted August 28, 2009 Share Posted August 28, 2009 Ktnx, that helps a lot. Link to comment
Dark Dragon Posted August 28, 2009 Share Posted August 28, 2009 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 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. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now