Jump to content
Luft08

remoteExec is confusing to me

Recommended Posts

I have read the information here: https://community.bistudio.com/wiki/remoteExec and they make it look easy but I get really confused on some commands. Specifically I found out that the effects of setTriggerStatements is local and I'm tearing what little hair I have left out trying to convert the following line of code to use remoteExec:

trg1 setTriggerStatements["!alive weaponsCache", "[] execVM missionPath + 'tsk1Succeeded.sqf'", ""]; 

Thanks for any help. 

Share this post


Link to post
Share on other sites

Personally I'd do it this way but there are other approaches as well (assuming the tsk1Succeeded.sqf must be run on client)

 

// In server:

trg1 setTriggerStatements["!alive weaponsCache", " remoteExec ['taskSucceedClient']; ", ""];



// In client:

taskSucceedClient =
{

[] execVM missionPath + 'tsk1Succeeded.sqf;

};

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks gc8. I think I'm getting the idea. You define an inline function available on all clients  and on the server call that function using remoteExec. The syntax is still a little confusing but I think that now I have a fighting chance to work it out. I think your code is a lot better than what I was trying (which didn't work)

[trg1,["!alive weaponsCache", "missionPath + 'tsk1Succeeded.sqf'",""]] remoteExec ["setTriggerStatements"];

 

Thanks again.

Share this post


Link to post
Share on other sites
1 hour ago, gc8 said:

(assuming the tsk1Succeeded.sqf must be run on client)

Arrrrggghhhh! It's not. tsk1Succeeded.sqf is run on the server.  So close and yet so far.

 

Maybe I don't have to run the entire tsk1Succeeded.sqf code on the server.  I'll work with it.  Thanks yet again. 🙂

Share this post


Link to post
Share on other sites
22 minutes ago, Luft08 said:

Arrrrggghhhh! It's not. tsk1Succeeded.sqf is run on the server.  So close and yet so far.

 

If it's run on server why do you need remoteExec then?

 

I'm not expert of triggers so maybe there is something I don't know

Share this post


Link to post
Share on other sites

I'm no expert either so maybe I'm doing completely wrong. I read that the setTriggerStatements only runs locally.  I recently installed a dedicated server on my PC so that I could test as a non-server. I noticed that what I was seeing wasn't always the same as when I was both the server and a player.  For example I would see the characters move their lips when speaking but my friends would not. (randomLip is also local.)

 

I also noticed when playing as a non-server that when I completed the final task the mission wouldn't end so I assumed it was a scope problem with the setTriggerStatements. 

 

Here's the tsk1Succeeded.sqf code that creates the final task (which is simply to fly back to base:

if(isServer) then {
	["tsk1","SUCCEEDED"] call BIS_fnc_taskSetState;
	deleteVehicle trg1; // delete the trigger.

	if(!isNil "player_1") then {
		[80]execVM missionPath + "goAfterPlayer_1.sqf";
	};

	if(!isNil "player_2") then {
		[80] execVM missionPath + "goAfterPlayer_2.sqf";
	};
	
	if (!isNil "player_3") then {
		[80] execVM missionPath + "goAfterPlayer_3.sqf";
	};

	if(alive heli_01) then {
		[true, ["tsk2"], ["Fly the littlebird back to base and land on the helipad", "Return to base", "returnMarker"], hPad_01, "ASSIGNED", 1, true, "land", true] call BIS_fnc_taskCreate;	
		handle = execVM "missionPath + createReturnToBaseTrigger.sqf";
	} else {
		// give option to call for extraction.
	};
};

 

I'm getting better (believe it or not) but I still have a long ways to go.

Share this post


Link to post
Share on other sites

gc8,

 

I think you are correct. I believe I have an error elsewhere. For one thing the quote mark in the above code. 😞 Your code example does help however. That's the way I'll be doing a lot of remoteExec from now on.

 

Thanks again.

Share this post


Link to post
Share on other sites
9 hours ago, Luft08 said:

[80]execVM missionPath + "goAfterPlayer_1.sqf";

1. There is no missionPath command, if that's what you want, there is getMissionPath
2. But if it is just a variable then SQF operator precedence (https://community.bistudio.com/wiki/SQF_syntax#Rules_of_Precedence) you should use brackets:

[80] execVM (missionPath + "goAfterPlayer_1.sqf");

Or

[80] execVM getMissionPath "goAfterPlayer_1.sqf";

if you want to use the built-in command

  • Like 2

Share this post


Link to post
Share on other sites

Thanks, it is a variable so I'll use the brackets. I have scripts in several directories. "missionPath" is actually a misleading variable name. Hmmm... I think I need to pay a little more attention to detail.

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

×