Jump to content
Sign in to follow this  
Instynct

Private server variable and return server function value

Recommended Posts

Is it possible for the server to assign private variables to units that the client can't edit using setVariable?

And also is it possible for the client to remotely execute a function on the server that returns said variable.

Say I wanted to set a variable for a player called money, and not let the client have only read access to it.

Edited by Instynct

Share this post


Link to post
Share on other sites

I've been wondering the same thing about the remote function with return value.

Share this post


Link to post
Share on other sites

Usually everything is possible. It's only a question of how much work you're willing to put into it.

Preventing the client from doing a setVariable, though, is something you probably don't want to trouble yourself with. If the client can run scripts freely on his machine there are much worse things he can do to your server/mission than setting some variables, such as becoming invulnerable and spawning bombs all over the island killing everyone and maybe even sacking the server's (and everyone else's) CPU and bandwidth.

As for a remote function with a return value, you probably have to script the system yourself, using publicVariableServer and publicVariableClient, combined with addPublicVariableEventHandler. Should be pretty easy, though. Remember that arrays can be sent across the network and work correctly as long as none of their elements are arrays, so you could use something like:

request = [player, "varName"];
publicVariable "request";

And on the server:

"request" addPublicVariableEventHandler
{
private ["_client", "_varName"];

_client = (_this select 1) select 0;
_varName = (_this select 1) select 1;

if (!(isNil _varName)) then
{
	(owner client) publicVariableClient _varName;
};
};

Of course in this way it's pretty pointless, as you could have just synchronized the variable's value in advance, but if you want it to only be available under certain conditions that only the server can calculate properly, then you can easily add them to the above code.

But again, if your goal is to stop cheating via scripting, you can pretty much forget about it as the cheater will easily find another (better) way to cheat.

Edited by galzohar

Share this post


Link to post
Share on other sites
Remember that arrays can be sent across the network and work correctly as long as none of their elements are arrays

u can send arrays in arrays...

i tryed pass dedicated <-> client something like:

[0, 0, 0, 0, [[true, false], [0, 0, 0], ["something", "something"]]]

and it was ok...

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×