Hey guys, I have a server side file where the BankTable is defined, now, I need a way to access it from the client file, even tho the server file gets called first the client seems not to be able to access it?
How do I do this so I could access the table from both clientside and serverside files?
Do I need to redefine the table in each file?
Lua does not magically transfer all your serverside variables to the client automatically, you need to do this yourself.
If it's a static table ([i]e.g. you're not gonna change it based on the server variables[/i]) then you can just redefine it on the client. To save time and everything you could use a shared file that's included both on the client and the server which could contain the table so they're both up to date.
If it's a table that changes a lot and needs to be sent to the client ([i]or just changed in any way[/i]) then you need to send the new information to the player(s), preferably with [b][url=http://wiki.garrysmod.com/?title=Usermessages]Usermessages [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b].
couldnt you just run the table shared?
[QUOTE=Deadman123;34154280]couldnt you just run the table shared?[/QUOTE]
Yes but keep in mind that changes wont be synchronized
[QUOTE=Dame Flawless;34164933]Yes but keep in mind that changes wont be synchronized[/QUOTE]
true
Global variables are just variables that can be accessed from any function running in the same state as that variable. You can't access a global serverside variable from the client without first streaming that to the client, which has already been gone over in this thread.
But yeah, what you're wanting is a something that's broadcasted, and in the future that's what you should be asking for.
Sorry, you need to Log In to post a reply to this thread.