Jump to content
Lucky44

land command works in SP but not on dedicated server - why?

Recommended Posts

I'm spawning 6 helos (one at a time), flying them into a location, having them land, then spawning infantry on the ground nearby (to simulate them getting out of the helos), then having the helos fly off. 

 

It works fine in SP, but when I run it on a dedi server, the helos won't land, they just hover near the landing spot.

 

I do have a bunch of helipads on the ground for them to land on. (More than one gets to the ground simultaneously, so I need multiple.) And as I said, it works fine in SP. I have to think it's something to do with the land command, that it doesn't work the same on a dedicated server.

 

Here's the code called each time through a loop (once per helo spawn) - 

_airGrp= createGroup east;

			_Air1 = [getMarkerPos "spawnAir", 0, "O_Heli_Transport_04_covered_F", _AirGrp] call bis_fnc_spawnvehicle; // this spawns the aircraft and includes crew
			//_Air1 is the VEHICLE array, with the actual vehicle being the first element of the array!! (Select 0)
			_helo = (_Air1 select 0);//give it a shorter name!

			_wp1 = _airGrp addWaypoint [getMarkerPos "WPair1", 0];

			_wp2 = _airGrp addWaypoint [getMarkerPos "WPair2", 0];
			_wp2 setWaypointSpeed "limited";

			_wp3 = _airGrp addWaypoint [getMarkerPos "WPair3", 0];
			_wp3 setWaypointSpeed "limited";
			_wp3 setWaypointStatements ["true", "this flyinHeight 25"];

			while {(_helo distance2D (getMarkerPos "WPair3")) >= 100} do {
				sleep 2;
			};
			sleep 2;
				doStop _helo;
				_helo land "land";

			while {(getPosATL _helo) select 2 >=1 } do {
	//			hint format ["alt = %1", (getPosATL _helo) select 2]; //debugging only!!!!!!!!!!!!!
				sleep 1;
			};
			sleep 2;//time to unload (fictional) troops
			  --spawn the infantry now--
			sleep 25;


			_helo doMove (getmarkerPos "WPair4");
			_wp4 = _airGrp addWaypoint [getMarkerPos "WPair4", 0];
			_wp4 setWaypointType "MOVE";
			_wp4 setWaypointSpeed "FULL";

I've had this issue in the past, but it's been years since I dealt with it, and I can't remember a solution! Any clues?

Share this post


Link to post
Share on other sites

try:

waitUntil {unitready _helo};  _helo land "land";

 

instead of

sleep 2; doStop _helo; _helo land "land";

 

 

 

Share this post


Link to post
Share on other sites
10 hours ago, lucky44 said:

while {(_helo distance2D (getMarkerPos "WPair3")) >= 100} do { sleep 2; };

This will always be true, even if you set the waypoints completion radius smaller. Helos automatic completion radius is something around ~230 meters.

Either as @pierremgi says use unitReady or use the waypoints statement to issue the land command.

Share this post


Link to post
Share on other sites

Thanks, Pierremgi and Larrow for the replies.

 

Correct me if I'm wrong, but in both your points, the problem isn't that the helo isn't waiting long enough to land or landing too soon. The problem is that it won't land, that it gets stuck hovering. So making it wait until "unitReady" would not make it more free to land, would it? 

 

But I tried both solutions and nothing changed.

 

Here's the code I changed it to:

while {(_helo distance2D (getMarkerPos "WPair3")) >= 280} do {
	sleep 2;
};
sleep 2;

waitUntil {unitReady _helo};
doStop _helo;
_helo land "land";

FWIW, I also tried removing the "doStop _helo" line, but that made no difference.

 

As I said, it all works fine in single player, but on a dedi server, the helos won't land. Something about the dedi server is the problem, I think.

Share this post


Link to post
Share on other sites

@lucky44 are u sure that the heli is local to that computer which executes the land command?

To get sure u could do

[_cobraOne, "LAND"] remoteExec ["land", _cobraOne]

 

Share this post


Link to post
Share on other sites
27 minutes ago, pierremgi said:

Why did you add a dostop command? (and sleep 2?)

 

I thought it was important for the land command. But as I said, I took it out and it made no difference on the dedi server.

Share this post


Link to post
Share on other sites

Is your helo in combat mode (under enemy fire)? You can add a line like:

driver _helo disableAI "autoCombat";   Before this Ai falls in combat behavior.

Share this post


Link to post
Share on other sites

idk if its important but wiki states uppercase usage for the string passed to land command.

Also there is a note about avoiding a landing bug. I suggest to try something like this:
 

sleep 3;

waitUntil
{
 sleep 1;
 unitReady _heli or {!alive _heli}
};

If (alive _heli) then
{
 if (local _heli) then
 {
       _heli land "LAND";
 }
 else
 {
  [_heli, "LAND"] remoteExec ["land", _heli]
 };
};

 

Edited by sarogahtyp
deleted double trouble

Share this post


Link to post
Share on other sites
19 minutes ago, sarogahtyp said:

idk if its important but wiki states uppercase usage for the string passed to land command.

Also there is a note about avoiding a landing bug. I suggest to try something like this:
 


sleep 3;

waitUntil
{
 sleep 1;
 unitReady _heli or {!alive _heli}
};

If (alive _heli) then
{
 if (local _heli) then
 {
       _heli land "LAND";
 }
 else
 {
  [_heli, "LAND"] remoteExec ["land", _heli]
 };
};

 

 

"land" works fine.

you don't need to remoteexec anything for AI helo spawned on server.

I'm using these kind of script in all my SP/MP missions and there is no reason to fail but the behavior of the crew.

Share this post


Link to post
Share on other sites

Here is a cut down test mission I just created. Works both SP and MP (tested on local dedicated).

  • Player has action to spawn heli
  • Action creates pad infront of player
  • Action calls server side script via remoteExec
  • Function spawns heli and crew giving waypoint to pad
  • heli lands at pad
  • group of soldiers is spawned
  • heli gets waypoint back to spawn where it and crew are deleted

params[ "_pad", "_heliSpawnPos" ];

[_heliSpawnPos, 0, "B_Heli_Transport_01_F", createGroup west ] call BIS_fnc_spawnVehicle params[ "_heli", "_heliCrew", "_heliGrp" ];

_wp1 = _heliGrp addWaypoint [getPosATL _pad, 0];
_wp1 setWaypointStatements[ "true", "
	_heli = vehicle this;
	_heli land 'land';
"];

waitUntil{ isTouchingGround _heli };

sleep 5;

[
	_heli getPos[ 10, ( getDir _heli ) - 90 ],
	west,
	configFile >> "CfgGroups" >> "West" >> "BLU_CTRG_F" >> "Infantry" >> "CTRG_InfTeam"
] call BIS_fnc_spawnGroup;

sleep 5;

_wp = _heliGrp addWaypoint [ _heliSpawnPos, 0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "FULL";
_wp setWaypointStatements[ "true", "{
	deleteVehicle _x;
}foreach ( thislist + [ vehicle this ] )" ];

Hope it helps.

  • Like 3

Share this post


Link to post
Share on other sites

Thanks, Larrow! I was just writing a post to request someone who has a stripped down, simple version of the concept working on a dedicated server post it when I saw your post!

 

I tried it, and I got an error on this line:

waitUntil{ isTouchingGround _heli };

_heli was undefined.  Did I do something wrong?

 

Share this post


Link to post
Share on other sites

:shrug: Not giving me any errors and ive just tested it about 5-6 times in both local and dedi.

You can see _heli is clearly defined from the params passed back from the BIS_fnc_spawnVehicle.

Share this post


Link to post
Share on other sites

Hmm. 

 

I actually don't know how to use the params with BIS_fnc_spawnVehicle. (I'm not the greatest coder!) I don't even see that explained on the https://community.bistudio.com/wiki/BIS_fnc_spawnVehicle page. Is the first argument going to name the spawned vehicle? 

 

Anyway, I've copied and pasted your code exactly. I created a blank mission on the VR map. I put the mission here, so you can see if I'm doing something wrong/different. ( https://drive.google.com/open?id=0BxwwP5x2h_hBbFlZM2ZQMVpDczA )

Share this post


Link to post
Share on other sites

Bis_fnc_spawnvehicle returns an array which larrow used directly as parameter for the params command which splits that array into local variables.

He just avoided to assign the return value to a variable first and then using that variable with params.

sent from mobile using Tapatalk

Share this post


Link to post
Share on other sites
28 minutes ago, lucky44 said:

Anyway, I've copied and pasted your code exactly.

Actually download the example mission so you can see how I call the script from the addAction.

You call my script yet you do not pass it any of the variables that are needed.

 

28 minutes ago, lucky44 said:

I actually don't know how to use the params with BIS_fnc_spawnVehicle.

You can see the example in the code posted.

As per your own code you are aware of the array returned from BIS_fnc_spawnVehicle..

_Air1 = [getMarkerPos "spawnAir", 0, "O_Heli_Transport_04_covered_F", _AirGrp] call bis_fnc_spawnvehicle; // this spawns the aircraft and includes crew
//_Air1 is the VEHICLE array, with the actual vehicle being the first element of the array!! (Select 0)

//_Air1 is the VEHICLE array, with the actual vehicle being the first element of the array!! (Select 0)

so you would do something like

_Air1 = [ /*vehicle stuff*/ ] call bis_fnc_spawnvehicle;
_heli = _Air1 select 0;
_heliCrew = _Air1 select 1;
_heliGrp = _Air1 select 2;

but you can also pull out the variables using params

_Air1 = [ /*vehicle stuff*/ ] call bis_fnc_spawnvehicle;
_Air1 params[
    "_heli",
    "_heliCrew",
    "_heliGrp"
];

Is exactly the same thing.

I just didnt bother putting the returned data from BIS_fnc_spawnVehicle into a variable before extracting the data.

[ /*vehicle stuff*/ ] call BIS_fnc_spawnVehicle params[ "_heli", "_heliCrew", "_heliGrp" ];

Same thing

  • Like 1

Share this post


Link to post
Share on other sites

OK, I understand the problem (that I didn't include the variables in the addAction line. -Haha, the problem is that I'm not sure how to do that or which to include! 

 

I'm guessing I need to pass the _heli, _helicrew and _heligroup, but what would that addAction look like? This? 

this addAction ["Start it", "Larrow1.sqf", [_heli, _heliCrew, _heliGrp] ];

 

Share this post


Link to post
Share on other sites

By the way, I now understand the way you used the params in the BIS_fnc_spawnVehicle. Thanks for explaining it!

Share this post


Link to post
Share on other sites
4 minutes ago, lucky44 said:

I'm guessing I need to pass the _heli, _helicrew and _heligroup, but what would that addAction look like? This? 

No the heli variables have nothing to do with how to call the script and (as explained above) are retrieved from using BIS_fnc_spawnVehicle.

If you download the test mission I provided, inside the initPlayerLocal.sqf you will find this...


player addAction [ "Spawn Heli", {
		params [
			"_target",
			"_caller",
			"_id",
			"_args"
		];
		_pad = createVehicle [ "Land_HelipadEmpty_F", player getPos[ 20, getDir player ], [], 0, "CAN_COLLIDE" ];
		[ _pad, player getPos[ 800, getDir player ] ] remoteExec[ "LARs_fnc_spawnHeli", 2 ];
	},
	[],
	1,
	true,
	true,
	"",
	//_target (unit to which action is attached to) and _this (caller/executing unit)
	""
];

This adds the action to the player. Which spawns an invisible helipad _pad. It then calls (remoteExec) my function LARs_fnc_spawnHeli on the server (2) passing the variables [ _pad, player getPos[ 800, getDir player ] ] so the _pad and a position 800 meters infront of the player in the direction he is facing.

LARs_fnc_spawnHeli is created via using the functions library which you can see in description.ext and the included file functions/test.fncs

Share this post


Link to post
Share on other sites

Ah! Sorry! I didn't see that you had linked your mission earlier! I'll look at it now.

Share this post


Link to post
Share on other sites

OK, I tried yours, and it works fine.

 

Well, I'll be honest: your code is too complicated for me. I really appreciate you taking the time to help, but I can't follow the way you've done things! (I wish I could!)

 

But I was able to deconstruct the code and make up my own version that works:

if (!isServer) exitwith {};

private ["_pad", "_airGrp", "_Air1", "_wp1", "_wp2", "_wp3","_heli"];

//spawn the helo
	_airGrp= createGroup east;
	_Air1 = [getMarkerPos "spawnPt", 0, "O_Heli_Transport_04_covered_F", _AirGrp] call bis_fnc_spawnvehicle;

//give the helo a WP where it should (move to and) land
	_wp1 = _airGrp addWaypoint [getPosATL pad1, 0];
	_wp1 setWaypointStatements[ "true", "_heli = vehicle this; _heli land 'land';"];
	_heli = (_Air1 select 0);
	sleep 3;

//wait for it to touch the ground, plus a bit
	waitUntil{ isTouchingGround _heli };
	doStop _heli;
	sleep 3;

//simulate infantry getting out and moving off on their own WPs
	["", ["spawnMarker7"], 10, 12, 1, "CSAT",["WP2a","WP2b","WP2z"]]  execVM "spawnInfSqdNOSCALE.sqf";
	sleep 15;//

//make the helo takeoff, fly to a far WP and be deleted
	_heli doMove (getmarkerPos "WP4");
	_wp4 = _airGrp addWaypoint [getMarkerPos "WP4", 0];
	_wp4 setWaypointType "MOVE";
	_wp4 setWaypointSpeed "FULL";

	sleep 40;//wait while helo flies off out of area, then...
	{_heli deleteVehicleCrew _x} forEach crew _heli;
	deleteVehicle _heli;

The spawning of the infantry calls my own script for spawning units, obviously.

 

Now I want to put it into a loop to do this 6 times...

 

Thanks heaps for the help!

 

 

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

×