• game.GetWorld() not shared ?
    7 replies, posted
Hello, Why this ? How is possible and how to fix it ? Shared.lua : [lua] game.GetWorld().Status = 1 [/lua] Server : [lua] lua_run print( game.GetWorld().Status ) [/lua] Output : 2 In-Game client : [lua] lua_run_cl print( game.GetWorld().Status ) [/lua] Output : 1 Thanks in advance.
You're setting `Status` to 2 server side somewhere
Yes i know but game.GetWorld() is supposed to be shared ? server and client the same value ?
No, shared means it can be used on both the client and the server. If you want the server and client to have the same value, you'll either have to network the value, or set the value in a shared state (i.e. on both the client and server).
No, that's now how it works. Shared means a [b]function will able available on both client on server[/b] It doesn't mean that everything is magically synced up between client and server if you use that function. You gotta network the value yourself, with whatever method you prefer, net library or otherwise.
[QUOTE=Robotboy655;52269835]No, that's now how it works. Shared means a [b]function will able available on both client on server[/b] It doesn't mean that everything is magically synced up between client and server if you use that function. You gotta network the value yourself, with whatever method you prefer, net library or otherwise.[/QUOTE] Ahhh ... thanks you for the reply So no magic on Gmod :(
[QUOTE=killerrichard;52269874]Ahhh ... thanks you for the reply So no magic on Gmod :([/QUOTE] I'm sorry you had to find out this way little Billy. I guess if you know magic isn't real, well, there's no harm in telling you this... Santa Claus isn't real either.
If you want a shared value use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/SetGlobalInt]SetGlobalInt[/url] or other SetGlobal<type> functions. I believe that in practice it sets a NWVar on the world, just like you tried to do, but I only heard that somewhere a long time ago and never actually checked. Either way, it does what you want - a shared value between server and clients.
Sorry, you need to Log In to post a reply to this thread.