Jump to content
Sign in to follow this  
FoxClubNiner

RemoteExec a Function

Recommended Posts

I stayed up way too late last night trying to get this to work. Quite simply I am trying to remoteExec a end mission function through an addAction. The idea being that any client can end the mission for everybody when they choose.  I have the addAction already written and tested fine:
 

player addAction ["End Mission", {["end1", true , 3, true, true, true] call VN_fnc_endMission;}, nil, 7, false, true, "", ""];

But since an addAction has a local effect only this only activates on the client that executes it. So that means I need to remoteExec it. The problem is I don't quite know how to order the text. I've tried a few things but I get errors when I do. Here is an example of one I tried that didn't do anything:

Quote

[{player addAction ["End Mission", {["end1", true , true, true, true] call VN_fnc_endMission;}, nil, 7, false, true, "", ""]}] remoteExec ["call", 0];

 


 

Share this post


Link to post
Share on other sites

if you want the simplest approach you can just do:


 

// In client:

createTheMisEndingAction =
{

player addAction ["End Mission", {["end1", true , 3, true, true, true] call VN_fnc_endMission;}, nil, 7, false, true, "", ""];

};



// Then in server:


remoteExec ["createTheMisEndingAction ", 0];

 

didnt check your code for typos

 

you might want to change 0 to clients only (0 means everyone including server)

 

HTH

 

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, gc8 said:

if you want the simplest approach you can just do:


 


// In client:

createTheMisEndingAction =
{

player addAction ["End Mission", {["end1", true , 3, true, true, true] call VN_fnc_endMission;}, nil, 7, false, true, "", ""];

};



// Then in server:


remoteExec ["createTheMisEndingAction ", 0];

 

didnt check your code for typos

 

you might want to change 0 to clients only (0 means everyone including server)

 

HTH

 


I'd like to try implementing this. Can you clarify what it means by "In Client" and "In Server"? At first I thought maybe it means initPlayerLocal and initServer but now I'm unsure.

Share this post


Link to post
Share on other sites
16 hours ago, gc8 said:

 


// In client:

createTheMisEndingAction =
{

player addAction ["End Mission", {["end1", true , 3, true, true, true] call VN_fnc_endMission;}, nil, 7, false, true, "", ""];

};



// Then in server:


remoteExec ["createTheMisEndingAction ", 0];

 

 

Is not the same as

17 hours ago, FoxClubNiner said:

The idea being that any client can end the mission for everybody when they choose

 

This:

17 hours ago, FoxClubNiner said:


 


player addAction ["End Mission", {["end1", true , 3, true, true, true] call VN_fnc_endMission;}, nil, 7, false, true, "", ""];



 

Turns into this:

player addAction ["End Mission", {
   ["end1", true , 3, true, true, true] remoteExec ["VN_fnc_endMission", 0];
}, nil, 7, false, true, "", ""];

That being said I don't think it is a great idea to allow any old player to end the mission at their own whims.

Either let the host/admin decide or go for some kind of voting system, only if a majority says "End it!" then you do so.

 

Also since ending the mission is an irreversible action consider that actions added to the player will be available at all times.

You don't want a player to accidentally bring the session to a close prematurely, just cause they are in a high-stress situation and clicks the wrong action. Oh boy, the number of times I've seen people blow themselves up with charges or eject themselves... the action menu is really prone to mistakes like that.

 

I'd do either of these:

  • gate the action behind some "objectives complete" condition
  • add some kind of confirmation step
  • use another approach that requires deliberate user input (like using chat messages as input)
  • Like 1

Share this post


Link to post
Share on other sites

If it helps, I have used this for a simple confirmation:
 

player addAction ["End Mission", {


private _result = ["Do you want to end the mission?", "End Mission", "Yes", "No"] call BIS_fnc_guiMessage;
if (_result == true) then {
	["end1", true , 3, true, true, true] remoteExec ["VN_fnc_endMission", 0];
};


}, nil, 7, false, true, "", ""];

 

  • Like 3

Share this post


Link to post
Share on other sites
3 hours ago, mrcurry said:

Is not the same as

 

I assumed VN_fnc_endMission ends mission for all, havent seen that function used before

Share this post


Link to post
Share on other sites
12 hours ago, FoxClubNiner said:


I'd like to try implementing this. Can you clarify what it means by "In Client" and "In Server"? At first I thought maybe it means initPlayerLocal and initServer but now I'm unsure.

 

yes put the client part in initPlayerLocal and when you want execute the server part somewhere in server files. But if you want to have the action at the beginning of the mission then you don't need remoteExec at all, only the addAction call in initPlayerLocal

 

Share this post


Link to post
Share on other sites
18 hours ago, FoxClubNiner said:


I'd like to try implementing this. Can you clarify what it means by "In Client" and "In Server"? At first I thought maybe it means initPlayerLocal and initServer but now I'm unsure.


You can change how it is remoteExec'd.
 

params remoteExec [order, targets, JIP]

Params are the array of variables that are passed to the order.

Order is the command or function name (the what) you want to execute.

Target is the who. (optional). 

JIP is a boolean, so true/false (also optional). If true, a unique JIP ID is generated and the remoteExec statement is added to the JIP queue from which it will be executed for every JIP (player who joins while the mission is in progress).

We want the who, so Target:

0: the order will be executed globally, i.e. on the server and every connected client, including the machine where remoteExec originated

2: the order will only be executed on the server - is both dedicated and hosted server. See for more info

Other number: the order will be executed on the machine where clientOwner matches the given number

Negative number: the effect is inverted: -2 means every client but not the server, -12 means the server and every client, except for the client where clientOwner returns 12.

In the event that you only want it executed on players and not the server:

["end1", true , 3, true, true, true] remoteExec ["VN_fnc_endMission", -2];

If you wanted that to also apply to JIP:

["end1", true , 3, true, true, true] remoteExec ["VN_fnc_endMission", -2, true];

 

  • Like 2

Share this post


Link to post
Share on other sites

Thanks for the fantastic information everyone!

Indeed I will gate this action until the mission is almost over. Basically it becomes available to players if they don't want to wait out the 3 minute helicopter ride back to base and receive their mission debrief, which is just some sidechat I wrote. But for all intents and purposes the mission is already over at that point.

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  

×