Jump to content
DryFire117

Tell Server to Run a Script from a Client

Recommended Posts

Hey all,

Here's my problem: I have a script that is attached to a client action called client.sqf that looks like this:

// THIS SCRIPT IS ON THE CLIENTS COMPUTER
// run the actual bomb arm script from the server
_obj = _this select 3 select 0;

if (_obj == obj1) then {
//THIS SHOULD EXECUTE armObj1.sqf ON THE SERVER
[[[player,_obj],"armObj1.sqf"],BIS_fnc_execVM] remoteExec ["call",2,false];
}; 

The issue is that this does nothing. I'm not sure how to let the client tell the server to execute this script. If I set the target argument of remoteExec to 0 it runs locally on my client but that's not what I'm trying to do here. Any ideas? Here's the flow of the situation: Client triggers action -> action calls client.sqf locally on client -> client.sqf tells server to execute armObj1.sqf from client machine -> server does execVm "armObj1.sqf"

Share this post


Link to post
Share on other sites

may be that this works but i m not very familiar with remoteExec.
 
[_obj, {[player, _this] execVM "armObj1.sqf"}] remoteExec ["call", 2];
got it from Revos comment at wiki entry for remoteExec

Share this post


Link to post
Share on other sites

Alternatively you can use addPublicVariableEventHandler on the server and on the client you can use publicVariableServer.

 

Server:

"armObj" addPublicVariableEventHandler {
    [_this select 1 select 0, _this select 1 select 1] execVM "armObj1.sqf";
};

Client:

armObj = [player, _this select 3 select 0];
publicVariableServer "armObj";
  • Like 1

Share this post


Link to post
Share on other sites

 

Alternatively you can use addPublicVariableEventHandler on the server and on the client you can use publicVariableServer.

 

Server:

"armObj" addPublicVariableEventHandler {
    [_this select 1 select 0, _this select 1 select 1] execVM "armObj1.sqf";
};

Client:

armObj = [player, _this select 3 select 0];
publicVariableServer "armObj";

Holy crap...this worked! Thanks a lot!

Share this post


Link to post
Share on other sites
[[player,_obj],"armObj1.sqf"] remoteExec ["execVM",2];

 

 

I ll never learn it... I missed that in this case it goes to Server, not from...

Share this post


Link to post
Share on other sites
[[player,_obj],"armObj1.sqf"] remoteExec ["execVM",2];

Well this was the first thing I tried and it wasn't working, but now it is. I love programming :) I'll probably stick with this.

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

×