Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | dawkot | |
Old Version | Published before Godot 3 was released. |
How do you make sure that a function is only executable on the server?
I don’t want to do a simple get_tree().is_network_server() check because it doesn’t feel safe enough, I would prefer for a function to be completely unaccessible for clients.
There is no #ifdef like in C++ or C#, so if you want to make it completely unavailable, you can make two Godot projects. One for the server, and one for the client. But I find this a bit unpractical for sharing code.
If you keep the same project, whatever you do using GDScript, you’ll have to use is_network_server
at some point. Either to call a function or not, or to instance a manager or another.
Zylann | 2016-10-14 22:51