Jump to content

Recommended Posts

Hey guys,

 

I am in need of a clever explanation of what I'm seeing and a helpful hand with fixing it.

 

I have created an action that calls for a chopper from a nearby location and makes it move and land in a different location.

The script works locally without issues.

The script works in multiplayer when called using the Zeus code module option.

The script does not work when called by addAction (either attached to a player or a static object).

 

By "does not work" I mean the helicopter does receive the cargo (which means it is recognised) but the chopper just sits there forever.

["Land_PaperBox_01_small_closed_brown_IDAP_F", helicopter1] call ace_cargo_fnc_addCargoItem;
["Land_PaperBox_01_small_closed_brown_IDAP_F", helicopter1] call ace_cargo_fnc_addCargoItem;
["Land_PaperBox_01_small_closed_brown_IDAP_F", helicopter1] call ace_cargo_fnc_addCargoItem;
["Land_PaperBox_01_small_closed_brown_IDAP_F", helicopter1] call ace_cargo_fnc_addCargoItem;

hint "Friendly chopper incoming";

helicopter1 move (getPos heli_landing_pad);

sleep 15;

while { ( (alive helicopter1) && !(unitReady helicopter1) ) } do
{
       sleep 1;
};

if (alive helicopter1) then
{
       helicopter1 land "LAND";
	   while { ( (alive helicopter1) && !(unitReady helicopter1) ) } do
		{
			helicopter1 engineOn false;
		};
};

For the love of me, I cannot understand why it keeps happening. I even called the helicopter1 move part individually from the zeus interface and it did work.

 

Thanks a lot,

Adam

Share this post


Link to post
Share on other sites

Your script works for me when spawned from the debug console.

 

I'm not convinced the while do loops are needed.

 

How are you using addAction?

 

 

I have simplified the script and it works with addAction.

I have used the default parameters.

 

You may want to look at removing the action from the player / object once the helicopter has landed.

player addAction
[
	"Call Helicopter",
	{
		//	ace_cargo_fnc_addCargoItem has a parameter for cargo amount.
		["Land_PaperBox_01_small_closed_brown_IDAP_F", helicopter1, 4] call ace_cargo_fnc_addCargoItem;

		hint "Friendly chopper incoming";

		_wp = (group helicopter1) addWaypoint [(getPosATL heli_landing_pad), 0];
		_wp setWaypointType "UNLOAD";
		_wp setWaypointStatements ["true", "(vehicle this) LAND 'LAND';"];
	}
];

 

Share this post


Link to post
Share on other sites

Hey @Maff,

 

That's the whole point - for some reason the script works when spawned by debug but does not when spawned from addAction, which is attached to a player using the simplest syntax for that command.

 

The while do loops were actually necessary for me as a workaround for when the heli reaches the vicinity of the landing pad, but hovers over it forever instead of just landing. I agree it's not always needed but it's the only way it has worked for me in this example. 

 

One more point I'd like to emphasize is that the addAction used on the player worked flawlessly in single player environment but failed on the "move" part in multiplayer, which boggles my mind. Not sure if you have tried your script on a dedicated?

 

When I get back home I will try that again, also using your script. 

 

Do you have any idea what might be the reason for the script working differently depending on SP/MP? 

Share this post


Link to post
Share on other sites
10 minutes ago, Dj Rolnik said:

One more point I'd like to emphasize is that the addAction used on the player worked flawlessly in single player environment but failed on the "move" part in multiplayer, which boggles my mind. Not sure if you have tried your script on a dedicated?

 

Did you get the hint message in Multiplayer?

 

I don't have access to dedicated server. I test whatever I write from the editor in multiplayer.

Every so often I'll grab anyone I can to test my creations "properly" in an actual multiplayer environment.

 

 

17 minutes ago, Dj Rolnik said:

Do you have any idea what might be the reason for the script working differently depending on SP/MP? 

 

Locality still confuses me to this day.
There are some commands that require the arguments to be local to the client executing the command.

Such as move... "Group or unit must be local to have global effect for this command.".
Whereas with addWaypoint arguments don't have to be local to the client the command is executed on.

Take that with a pinch of salt though as I am not 100% sure myself.

If something works then I usually don't question it.

  • Like 2

Share this post


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

Hey @Maff,

 

That's the whole point - for some reason the script works when spawned by debug but does not when spawned from addAction, which is attached to a player using the simplest syntax for that command.

 

The while do loops were actually necessary for me as a workaround for when the heli reaches the vicinity of the landing pad, but hovers over it forever instead of just landing. I agree it's not always needed but it's the only way it has worked for me in this example. 

 

One more point I'd like to emphasize is that the addAction used on the player worked flawlessly in single player environment but failed on the "move" part in multiplayer, which boggles my mind. Not sure if you have tried your script on a dedicated?

 

When I get back home I will try that again, also using your script. 

 

Do you have any idea what might be the reason for the script working differently depending on SP/MP? 

The move command fails in MP most likely due to the helicopter1 group not being local to the computer that is executing the command. In mulitplayer/ a dedicated environment you will want to use remoteexec to assure the unit gets his movement order correctly - or have the addaction call a function that is ran server side that will run all the code you need.

  • Like 2

Share this post


Link to post
Share on other sites

@Maff

2 hours ago, Maff said:

Did you get the hint message in Multiplayer?

 

I did. Only the move command did not work but again, it did not work only when called by addAction from the player/object.

 

Yep, locality is also something which I struggle with constantly as well. You may be right with the move command description (Group or unit must be local to have global effect for this command.). I actually thought about it as well but  did not manage to work around it. The idea of using the waypoint instead might be a good one. I will try that out as soon as I get back home 🙂

 

 

@genesis92x

Thanks for the input too. When you mention the remoteexec, do you suggest it would look like this? Think it would work then?

this addAction ["Call for a chopper", { remoteExec "call_heli_1.sqf" }]

 

Thanks for your help guys!

  • Like 1

Share this post


Link to post
Share on other sites
47 minutes ago, Dj Rolnik said:

do you suggest it would look like this

No. That would be a syntax error.

https://community.bistudio.com/wiki/remoteExec

remoteExec never takes string as right argument. Its always array.

 

I'd say just execute the whole waypoint code on the helicopter like so

{
    _wp = (group helicopter1) addWaypoint [(getPosATL heli_landing_pad), 0];
    _wp setWaypointType "UNLOAD";
    _wp setWaypointStatements ["true", "(vehicle this) LAND 'LAND';"];
} remoteExec ["call", helicopter1];

 

  • Like 2

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

×