Place to get help with not working mods / modding interface.
5 posts • Page 1 of 1
There is no such thing as a flag that tells you if code runs on server or not. There was never a need for such a thing and there is no reason to have something like that. Reason is simple: you should never ever change your script behavior on that, because in multiplayer your script is in fact being executed in muliple instances synchroniously at the same time: on the server and on all of the connected clients. If those multiple instances would at any point in time produce an observable difference in game state, then the game desyncs and a client for which script gave a different result is disconnected from the server.
Thanks for replying.
The purpose is that, I need to display something for players. They are trivial and not worthy any memory on server.
But if there is not such a mechanism, it's the same for me to do it in a unified script and cost some extra memory on server.
By doing that you would literally produce a desync. Things that are displayed to the player are (almost) always a part of game state so if an instance on the player to which you want to print would game.print a message (=change game state) while the server would not follow the same print code, game state would diverge and desync would occur.
I see no reason in trying to optimize memory usage so much on particular instances. Having all instances produce the same output is by far the most important thing and if that requires more memory then i am fine with that.