Jump to content
Sign in to follow this  
Beerkan

Check Helicopter height and warm if above certain height.

Recommended Posts

I'm creating a Helicopter training mission where want to add a constant check on the Helicopter's height so it reminds the pilot to stay below the maximum permitted Combat Height of 20m. I use 25m as the height check to allow for the odd indiscretion because of terrain or obstacles.

This is the init on the pilot where 25 is the max height in metres.

null = [25] execVM "heightcheck.sqf";

And this is the heightcheck.sqf script

// heightcheck.sqf by Beerkan 1.20
// Put this in the init of the unit to check it's height
// null = [25] execVM "scripts\heightcheck.sqf";

_maxheight = _this select 0;
if !(isServer) exitwith{};
sleep 1;

while {alive player} do 
{
	if ((vehicle player) isKindOf "Air" && (getPos (vehicle player) select 2) > _maxheight)
	then
		{titletext[format["STAY BELOW %1m PILOT!!",_maxheight],"PLAIN"];titleFadeOut 1;
		sleep 2;
		};
};

--- UPDATE 2 ---

Script above now working with Full release 1.08

Edited by Beerkan

Share this post


Link to post
Share on other sites

Well looking at this I can already see you are missing brackets {} and you have too many (). Check your if command.

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Yeah, I just realised, I added the extra () in the if line as a last ditched attempt to get it all to work. It worked before I added them, and I know it should be

if ((getPosATL player) select 2 > 25) then

I forgot to take it out when I posted.

But damn it if I can see where the extra {} are needed.

---- UPDATE ----

Thanks cobra4v320.. I figured it out.

Please accept a virtual Chocolate Easter egg for your help.. :)

(It doesn't mean we're engaged or anything.)

P.S. Script fixed in the first post.

Edited by Beerkan

Share this post


Link to post
Share on other sites

You are running this on client and 'player' object is always local to client machine so a bit confused about the use of

if (!(local player)) exitWith {};

Share this post


Link to post
Share on other sites

This script works well in my Helicopter Training Mission. However I just noticed that it displays the height warning when flying over water, even though I'm only a few metres above the surface. Clearly this is because it's reporting based on the height above land, including the sea bed. Can anyone suggest how to display the correct warning message when over both land AND water? i.e. when 20m above sea level when over water?

Share this post


Link to post
Share on other sites
Try using the normal getPos.
Works a treat. Script above amended.

Share this post


Link to post
Share on other sites
This script works well in my Helicopter Training Mission. However I just noticed that it displays the height warning when flying over water, even though I'm only a few metres above the surface. Clearly this is because it's reporting based on the height above land, including the sea bed. Can anyone suggest how to display the correct warning message when over both land AND water? i.e. when 20m above sea level when over water?

you will most likely need to use "surfaceIsWater" command and then have the getPosATL changed to getPosASL when over water and then switch back when over land.

Used the same command for some projects I have that essential do the same thing for units... :)

hope this helps,

-VRCRaptor

Share this post


Link to post
Share on other sites

An old script I had to refer to wasn't working. I've fixed the above script to work in latest release. (1.08)

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  

×