Beerkan 71 Posted March 28, 2013 (edited) 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 January 6, 2014 by Beerkan Share this post Link to post Share on other sites
cobra4v320 27 Posted March 28, 2013 (edited) Well looking at this I can already see you are missing brackets {} and you have too many (). Check your if command. Edited March 28, 2013 by cobra4v320 Share this post Link to post Share on other sites
Beerkan 71 Posted March 28, 2013 (edited) 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 March 29, 2013 by Beerkan Share this post Link to post Share on other sites
killzone_kid 1326 Posted March 29, 2013 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
Beerkan 71 Posted May 13, 2013 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
Tuliq 2 Posted May 13, 2013 Try using the normal getPos. Share this post Link to post Share on other sites
Beerkan 71 Posted May 13, 2013 Try using the normal getPos.Works a treat. Script above amended. Share this post Link to post Share on other sites
vrcraptor 11 Posted May 16, 2013 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
Beerkan 71 Posted January 6, 2014 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