I’m fairly new to using AGF and I’ve arrived at an impasse of sorts. I have what will be a fairly large table of all available weapons and relevant data, and I want to include the code for each weapon’s usable abilities in the table - both for the server and the client. For security purposes, however, I figured I couldn’t include server code in a shared table because the client would then be able to see it and execute it.
That said, I decided to migrate the weapon table into a service instead and simply have the server provide data to the client per-request, but this came with a new issue: the client needs to be able to readily access weapon data for the purpose of displaying it in the in-game shop and combat UI; if I’m forcing the client to interact with the server each time it needs to access weapon data, wouldn’t the delivery be slowed down due to network latency? Are client-exposed methods in AGF the same as RemoteFunctions, or do they work differently? Do I even need to worry about including server-code in a table?
Do these values change at run-time? If no, then just stick the data as a shared module. The server should be validating any gameplay-critical actions anyway so it doesn’t matter if the client tries to modify its copy.
So I don’t need to worry about clients attempting to execute code meant for the server if I include it in the table? Even if they don’t modify it at all?
I don’t quite know what you mean, but the client cannot execute code on the server. Also, as sparker22 said, if these values don’t change, you can just put them in a module script that’s accessible to the client. As for sending server code, I don’t know why it needs to be sent to the client. Just send the needed data.
It’s difficult to find a way of explaining my thought process here - AGF is set up in such a way that server-client communication is made easier by making most code accessible from anywhere. I guess it still can’t violate the basic principles of the client/server boundary. I just wanted to be sure.
I think I have the general idea of what I’m supposed to be doing, though. Thanks!