Jump to content

(Question) invokeServerFunction - is it safe?


Rinart73

Recommended Posts

As I understand, using invokeServerFunction function client can call almost any lua function of any entity on a server side. And if this function isn't supposed to be called by the client, some random junk arguments can cause error on a server side and affected script will be unattached. And this eventually will get us to the entity that doesn't work properly for all players.

Am I right or I don't understand something? Yes, I know that function must be in the same attached script.

Link to comment
Share on other sites

As I understand, using invokeServerFunction function client can call almost any lua function of any entity on a server side. And if this function isn't supposed to be called by the client, some random junk arguments can cause error on a server side and affected script will be unattached. And this eventually will get us to the entity that doesn't work properly for all players.

Am I right or I don't understand something? Yes, I know that function must be in the same attached script.

 

the function is not safe related to your concerns, as every invoked function should be prepared for invocation and you could produce errors with wrong parameters or timing ... BUT i think thats not really an issue, since a normal function call can fuck up the same way! plan the functions, invoke only functions that should be invoked and which have onClient() / onServer() conditions ... with producing "bad" code you are always at risk of corrupting things in the game... and invokeServerFunction is just essential to use, since many important function/properties are not available client-side

Link to comment
Share on other sites

As I understand, using invokeServerFunction function client can call almost any lua function of any entity on a server side. And if this function isn't supposed to be called by the client, some random junk arguments can cause error on a server side and affected script will be unattached. And this eventually will get us to the entity that doesn't work properly for all players.

Am I right or I don't understand something? Yes, I know that function must be in the same attached script.

 

the function is not safe related to your concerns, as every invoked function should be prepared for invocation and you could produce errors with wrong parameters or timing ... BUT i think thats not really an issue, since a normal function call can fuck up the same way! plan the functions, invoke only functions that should be invoked and which have onClient() / onServer() conditions ... with producing "bad" code you are always at risk of corrupting things in the game... and invokeServerFunction is just essential to use, since many important function/properties are not available client-side

 

I totally agree that invokeServerFunction is essential, but it would be good to just implement some sort of 'flags' or 'labels' in Lua for the functions that can be invoked. Like public/private but in the client-server terms.

Link to comment
Share on other sites

As I understand, using invokeServerFunction function client can call almost any lua function of any entity on a server side. And if this function isn't supposed to be called by the client, some random junk arguments can cause error on a server side and affected script will be unattached. And this eventually will get us to the entity that doesn't work properly for all players.

Am I right or I don't understand something? Yes, I know that function must be in the same attached script.

 

the function is not safe related to your concerns, as every invoked function should be prepared for invocation and you could produce errors with wrong parameters or timing ... BUT i think thats not really an issue, since a normal function call can fuck up the same way! plan the functions, invoke only functions that should be invoked and which have onClient() / onServer() conditions ... with producing "bad" code you are always at risk of corrupting things in the game... and invokeServerFunction is just essential to use, since many important function/properties are not available client-side

 

I totally agree that invokeServerFunction is essential, but it would be good to just implement some sort of 'flags' or 'labels' in Lua for the functions that can be invoked. Like public/private but in the client-server terms.

 

Doesn't exist, will never exist, is impossible to do in LUA. Since that's simply not how LUA works.

 

LUA is a single pass script interpreter, basically, and the invoke functions are something that is implemented in Avorion and not standard LUA.

 

LUA has no concepts of objects, private or public functions, or anything like that. Even 'worse' from your point of view is that you can actually store functions in variables, and call them through those variables.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...