Jump to content
Tory Xiao

Hight restriction script

Recommended Posts

I found this script to avoid players from flying too high

initPlayerlocal.sqf:


areaTimer = 0;

#define DTIME 30 // Time until death

while { true } do
{

 _p = getpos player;
 
 _hightplayer = _p select 2;
 
 if( _hightplayer > 2000 ) then
{
 areaTimer = time;
 hintSilent "";
}
else
{
 _t = time - areaTimer;
 if(_t >= DTIME) then
 {
  player setDamage 1;
 }
 else
 {
  hintSilent format["Please fly below 2km or you will died in %1 seconds!", DTIME - _t];
  playSound "FD_CP_Not_Clear_F";
 };
};

 sleep 1;
};

When I stand on the ground the warning kept showing up, and _hightplayer returns 0.000134. WHY????

Never mind Im an idiot

Share this post


Link to post
Share on other sites

You can add also a "hard" ceiling, so no need to warn the pilots, they can't fly above:


 

["ceilingFlight","onEachFrame",{
  if (objectParent player isKindOf "air" && {getPos objectParent player #2 > 2000}) then {
    private _plane = objectParent player;
    private _pos = getposASL _plane;
    _plane setVelocityTransformation [
      _pos,
      _pos vectorAdd velocityModelSpace _plane,
      velocity _plane,
      velocity _plane vectorAdd [0,0, - 1.1* (velocity _plane #2)],
      vectorDir _plane,
      vectorDir _plane,
      vectorUp _plane,
      [0,0,1],
      1
    ];
  };
}] call bis_fnc_addStackedEventHandler;

 

  • Like 1

Share this post


Link to post
Share on other sites
9 hours ago, pierremgi said:

You can add also a "hard" ceiling, so no need to warn the pilots, they can't fly above:


 


["ceilingFlight","onEachFrame",{
  if (objectParent player isKindOf "air" && {getPos objectParent player #2 > 2000}) then {
    private _plane = objectParent player;
    private _pos = getposASL _plane;
    _plane setVelocityTransformation [
      _pos,
      _pos vectorAdd velocityModelSpace _plane,
      velocity _plane,
      velocity _plane vectorAdd [0,0, - 1.1* (velocity _plane #2)],
      vectorDir _plane,
      vectorDir _plane,
      vectorUp _plane,
      [0,0,1],
      1
    ];
  };
}] call bis_fnc_addStackedEventHandler;

 

Oh I tried something similar but players said it was so stupid stuck mid-air while dogfighting with others 🤣🤣

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

×