Is executing a "Run on Owning Client" event from the Server secure?
I'm trying to wrap my head around how certain calls work together. I'm concerned about how and where I'm running certain sections of code because I want it to be secure. For example, if I ran something like this:
...would the "Very Important Variable" be liable to alteration by the player on the client machine? Or is it safe because that event was run on the server? I notice that when I add a Switch Has Authority after the Client event (that is being run by the Server) like this:
...the variable is not set, though I'm not sure if that necessarily means the code is running on the client itself. Is this safe? If not, what's the recommended way of setting an important variable for a specific client such that they cannot alter it?
If you have a variable that your clients should not be able to manipulate you can not add functions for the client to manipulate that variable.
The "execute on server" event can be called from the client and in your example sets the variable which would allow the clients to do whatever with it.
Execute on owning clients gets called on the owner of the actor, if it is a client it will never have authority and your client important things will never do anything.
If you only want your server to change this data use replication.
this will automatically set the value on your clients without any chance of the clients to change it on the server.
Don't forget to switch on replication on the actor you have the data on otherwise nothing will happen.
If you need your clients to react to the variable change use the RepNotify and do your reaction in the created function.
answered Apr 12 '19 at 11:25 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here