Jump to content

Recommended Posts

add this EH to your plane

this addEventHandler ["Gear", 
{
 params ["_vehicle", "_gearState"];
  
 if {_gearState} then
 {
  if (!isNil "ALTwarn") then { terminate ALTwarn };
 }
 else
 {
  ALTwarn = [] execVM "LowALT.sqf";
 };
}];

not tested!

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

I was bored so I made this script for you:

 

#define TOO_LOW_HEIGHT 100

altitudeWarning =
{
 params ["_plane"];
 _plane addEventHandler ["gear",
 {
  params ["_plane", "_gearState"];
  
  _plane setVariable ["altWarn", !_gearState];
 }];
 _plane setVariable ["altWarn", !(isTouchingGround _plane)];
 
 _plane spawn
 {
  params ["_plane"];
  while { alive _plane } do
  {
  _warn = false;
  if(_plane getVariable "altWarn") then
  {
   _dist = (getposASL _plane # 2) min (getposATL _plane # 2);
   
   if(_dist < TOO_LOW_HEIGHT) then
   {
   _warn = true;
   };
   
  };
  
  if(_warn) then
  {
    hintsilent "Low terrain!";
    playSound ["vtolalarm", true];
  }
  else
  {
    hintsilent "";
  };
    
  sleep 1;
  };
 };
};


jet call altitudeWarning;

 

 

Put all that in init.sqf

name your plane as "jet"

default too low height is 100, can be changed

 

works on water surface too

 

 

  • Like 2

Share this post


Link to post
Share on other sites

@sarogahtyp

Thanks for your help!
I put this EH in my JET init,

this addEventHandler ["Gear", { params ["_vehicle", "_gearState"]; if {_gearState} then { if (!isNil "ALTwarn") then { terminate ALTwarn }; } else { ALTwarn = [] execVM "LowALT.sqf"; }; }];

I think it says, if gearstate = 0 terminate ALTwarn, else ALTwarn = execute script.

It didn't work as posted but I think this is the right idea. Below is my warning script, a hybrid of the two is probably better. Will you take a look at this because I'm befuddled.

@gc8,
Thanks for your help, too!

I pasted your code, which I can't read at all because I'm bad at this, into my init.sqf and renamed my vehicle to "JET", but I got an error: missing ) on line 47 (including the existing lines in the init).

Here is the script from "lowALT.sqf", don't laugh, I'm sure it's terrible-- but it works. It will probably work better if we put the landing gear restriction into the script itself, no?

 

if ((getPos playerJET) select 2 < 50  && Alive PlayerJET) then {
    playSound ["vtolalarm", true];
    hint "Low Altitude";
sleep 2;
    nul = []execVM "LowALT.sqf"
    };

if ((getPos playerJET) select 2 > 50 && Alive PlayerJET) then {
    hint "";
    nul = []execVM "LowALT.sqf"
    };

So, regardless of anything so far, how to restrict the above based on gearstate?

Share this post


Link to post
Share on other sites

@wogz187 The code I posted worked in my tests

Share this post


Link to post
Share on other sites

@gc8

I'm sure your code works. Likely I've used it incorrectly because I'm bad at this. When I tried your code I first tried to change the final line to "PlayerJET", instead of "JET" like you said, because that is the name of the vehicle and it is referenced many times. That didn't work for me so I tried it exactly as you said, "JET". Also that didn't work for me. Should I try to make what you wrote as a script that runs from the init?

Share this post


Link to post
Share on other sites

@wogz187 The script should be run from init.sqf. There's not much point making it run from init IMO. I chose init.sqf because it was the simplest way...

 

Edit: I modified the script so that it stops if plane is destroyed

  • Thanks 1

Share this post


Link to post
Share on other sites

@gc8

So I should be able to paste this in my init.sqf, and is it okay to change JET to "playerJET"? As many other things reference "playerJET". Does the block need to be separate from the rest of my init text?

Should it be the first thing in the init text?

Share this post


Link to post
Share on other sites
5 minutes ago, wogz187 said:

So I should be able to paste this in my init.sqf, and is it okay to change JET to "playerJET"?

 

Yeah no problem there

 

it doesn't matter if you put the code first or last thing in the init.sqf file but it kinda is separate, so it isn't messed up with rest of the code 🙂

 

One thing you can do is but the code I gave to new .sqf file, let's say "altWarn.sqf" and then in init.sqf execute that file:

execVM "altWarn.sqf";

 

maybe that clears it up a little bit

Share this post


Link to post
Share on other sites

I tried the opposite of what you said. I removed everything else from the init.sqf and ran this code alone. I still got: missing ) on line 22. All I changed was "jet" to "playerJET".

I'll try the, execVM "altWarn.sqf", method you suggested.

I can't really read your code because I'm not very good at this. Can we add the "VTOLalarm" effect in addition to the text prompt? Like in the LowALT.sqf above?

Share this post


Link to post
Share on other sites
3 minutes ago, wogz187 said:

Can we add the "VTOLalarm" effect in addition to the text prompt? Like in the LowALT.sqf above?

 

sure but I'm unsure if there needs to be more changed with playSound

 

Edit: I modified my code again to include the alarm sound

Share this post


Link to post
Share on other sites

@gc8

"sure but I'm unsure if there needs to be more changed with playSound"

In regard to CFGsound? That was yesterday's problem! LOL!

As far as I can tell CFGsound class config is unnecessary with game sounds like "alarmVTOL". My script above works without sound class config, if that's what you mean.

Share this post


Link to post
Share on other sites
12 minutes ago, wogz187 said:

My script above works without sound class config, if that's what you mean.

 

I was thinking if the sound was going to loop many times when the function was called multiple times

 

anyway, it's late. talk to you tomorrow

Share this post


Link to post
Share on other sites

@gc8

Thanks again for all your help.

Since we're using the same script and I'm getting an error, I am trying to consider what else might be different. there's this line,

_plane setVariable ["altWarn", !(isTouchingGround _plane)];

the plane in my mission starts on the aircraft carrier.

I'm going to try your script in a fresh mission, which is what I should have done in the first place.

Talk to ya tomorrow.

Share this post


Link to post
Share on other sites

@wogz187 I uploaded the test mission with the code, you can take a look there how it's done. Hope that helps.  Link: Download

 

Edited by gc8
Starts from carrier
  • Like 1

Share this post


Link to post
Share on other sites

Thanks. I'll check it out now.

Share this post


Link to post
Share on other sites

@gc8

Thanks for all your hard work on this.

When I run the mission as is I get an error: "Undefined variable: AltitudeWarning"
After that I copied the init.sqf text into the editor init field and received: "Generic error in expression".
After that I removed "JET call AltitudeWarning" from the INIT and added it to a radio trigger which returned no errors but still didn't work.

I don't know what I could possibly be doing wrong.

  • Confused 1

Share this post


Link to post
Share on other sites

@wogz187 I don't know what could possibly be wrong, the mission is supposed to work as is.....

Which version of arma you have?

 

Share this post


Link to post
Share on other sites

@gc8

Yeah, I know. Version 1.78.43717. Not Steam.

Share this post


Link to post
Share on other sites
2 minutes ago, wogz187 said:

@gc8

Yeah, I know. Version 1.78.43717. Not Steam.

 

I have 1.92.x

 

That has to be the reason

Share this post


Link to post
Share on other sites

Shows how often I play online. I might just have to buy the Steam version.

Thanks for your help. We can shelve this for now, I have your script to test after updating.

  • Like 1

Share this post


Link to post
Share on other sites

@gc8
In the meanwhile,

I attached this script SQF to a button labelled "WARN" on my Mission Control GUI to toggle the system on and off,

if (ALTwarn == 0) then {
    hint "Warning System ONLINE";
    ALTwarning = []execVM "ALTwarn.sqf";
    ALTwarn=1;
sleep 2;
    hint "";
    }

else {
    hint "Warning System OFFLINE";
    terminate ALTwarning;
sleep 2;
    hint "";
    ALTwarn=0;
};


And called this "ALTwarn.sqf",

 

if ((getPos playerJET) select 2 < 50  && Alive PlayerJET && ALTwarn==1) then {
    playSound ["vtolalarm", true];
    titleText ["WARNING", "Plain", 0.1];

sleep 1;
    titleText ["ALTITUDE", "Plain", 0.1];


sleep 2;
    ALTwarning = []execVM "ALTwarn.sqf";
    }

else {
    ALTwarning = []execVM "ALTwarn.sqf";
    };

It's not as cool as tying the on/off action to the landing gear but it works for now.

Thanks again, all!

  • Like 1

Share this post


Link to post
Share on other sites

Fly Tanoa Air will be released soon but I wanted to add the result of this topic for anybody who may want it in the future. You may download the complete AWS system here.

This package of scripts work together to create a complete Radar Warning System for air vehicles. The system can be automatic, toggled by button, or both. It measures speed (high and low) and altitude. All the variables for speed and altitude can be easily changed within the scripts.

The result is both a visual and audio warning that are obvious without being completely annoying.

Have fun!

  • Thanks 1

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

×