Tory Xiao 5 Posted December 19, 2021 Is there a way to limit the flying altitude of a drone by script? I'm currently using this to limit manned aircraft's altitude initPlayerLocal.sqf: areaTimer = 0; #define DTIME 40 // Time until death while { true } do { _p = getpos player; _hightplayer = _p select 2; if( _hightplayer < 2000 ) then { areaTimer = time; } else { _t = time - areaTimer; if(_t >= DTIME) then { ["<t color='#ff0000' size='2'>Killed by hight limitation</t>",-1,-1,5,1,0,789] spawn BIS_fnc_dynamicText; player setDamage 1; } else { _time = [DTIME - _t, 0] call BIS_fnc_cutDecimals; hintSilent parseText format ["<t size='2' color='#ff0000'>Hight Limit</t><br/><br/>Please return below 2000m in %1 seconds<br />Or you will get killed</t>", _time]; playSound "FD_CP_Not_Clear_F"; }; }; sleep 1; }; But this wont work for UAVs Share this post Link to post Share on other sites
Harzach 2505 Posted December 19, 2021 Tangential to your question - in addition to being very inefficient, getPos returns height above the terrain surface below. Assuming you want to limit flight altitude, you should use getPosASL, which will return height Above Sea Level. If for some reason you do want to get height above terrain, then try getPosATL. I don't really mess with UAVs much, but I expect the issue is that a player controlling a UAV is not actually in the UAV - the player is still on the ground controlling it. Try using getConnectedUAV. Something like : params ["_player", "_didJIP"]; areaTimer = 0; #define DTIME 40; while { true } do { _unit = _player; _uav = getConnectedUAV _unit; _driver = (UAVControl _uav#1); if ((!isNull _uav) && _driver != "") then { _unit = _uav; }; _p = getpos _unit; _hightplayer = _p#2; if( _hightplayer < 2000 ) then { areaTimer = time; } else { _t = time - areaTimer; if(_t >= DTIME) then { ["<t color='#ff0000' size='2'>Killed by hight limitation</t>",-1,-1,5,1,0,789] spawn BIS_fnc_dynamicText; _player setDamage 1; } else { _time = [DTIME - _t, 0] call BIS_fnc_cutDecimals; hintSilent parseText format ["<t size='2' color='#ff0000'>Hight Limit</t><br/><br/>Please return below 2000m in %1 seconds<br />Or you will get killed</t>", _time]; playSound "FD_CP_Not_Clear_F"; }; }; sleep 1; }; Sort of tested and working. One issue is that the player is considered to be in the position of the UAV until they actually disconnect their terminal, rather than just releasing controls. UAVControl will return null (or rather, an array where the second element is null) if there is no one currently controlling the targeted UAV, so I'm also checking for that. You might also want to check that they are not in the gunner seat (fourth element of UAVControl.) 2 Share this post Link to post Share on other sites
Sertica 18 Posted December 21, 2021 I would try: if( _vehicleZ > 2000 ) then { vehicle addForce [force, position]; } //make force downward https://community.bistudio.com/wiki/addForce Share this post Link to post Share on other sites