Jump to content
Sign in to follow this  
Yolo Joe

Adding a new action to the scroll menu?

Recommended Posts

I want to add a extra option to the scroll menu when I'm inside a helicopter.

So I want it to be like this:

Auto-hover on

Engine off

Manual fire

Damage menu

When I press the "Damage menu" button, I want it to go on to Damage menu >> Disable tail-rotor

The script I'm using to disable the tail-rotor is

vehicle player setHit ["mala vrtule", 1]

How can I do this? :)

Share this post


Link to post
Share on other sites

ok there are a few scripts you need to create:

Damage_Init.sqf

Damage_Manu.sqf

Damage_Close.sqf

Damage_Tail.sqf

Damage_Reset.sqf

now, in the editor, add to the chopper init field the following:

in = this addEventHandler ["GetIn", {_this execVM "Damage_Init.sqf"}]; out = this addEventHandler [""GetOut"", {_this execVM "Damage_Close.sqf"}];

this makes the scripts run when someone gets into the chopper.

Damage_Init.sqf:

_veh = _this select 0;

if ((count (crew _veh)) < 2) then {
Dmanu = _veh addAction ["Damage Manu", "Damage_Manu.sqf"];
};

Damage_Manu.sqf:

_target = _this select 0;
_id = _this select 2;

_target removeAction _id;

Dtail = _target addAction ["Damage Manu - Tail rotor Failure", "Damage_Tail.sqf"];
Dreset = _target addAction ["Damage Manu - Reset Aircraft", "Damage_Reset.sqf"];

Damage_Tail.sqf:

_target = _this select 0;

_target removeAction Dtail;
_target removeAction Dreset;

(vehicle _target) setHit ["mala vrtule", 1];

Dmanu = _target addAction ["Damage Manu", "Damage_Manu.sqf"];

Damage_Reset.sqf:

_target = _this select 0;


_target removeAction Dtail;
_target removeAction Dreset;

(vehicle _target) setHit ["mala vrtule", 0];

Dmanu = _target addAction ["Damage Manu", "Damage_Manu.sqf"];

Damage_Close.sqf:

_veh = _this select 0;

if (count (crew _veh)) = 0) then {
_veh removeAction Dmanu;
_veh removeAction Dtail;
_veh removeAction Dreset;
};

Edited by Silderoy

Share this post


Link to post
Share on other sites

There is some wrong with the Init script

in = this addEventHandler ["GetIn", {_this execVM "Damage_Init.sqf"}]; out = this addEventHandler [""GetOut"", {_this execVM "Damage_Close.sqf"}];

It does not work. When I press OK it says "Missing [" and skips to [""GetOut""

I edited it to

in = this addEventHandler ["GetIn", {_this execVM "Damage_Init.sqf"}]; out = this addEventHandler [b]["GetOut"[/b], {_this execVM "Damage_Close.sqf"}];

But now the menu dont disappear when Im exiting the chpper. I can use the menu from outside the chopper.

Anyone?

Share this post


Link to post
Share on other sites

that might be it:

Damage_Close.sqf:

_veh = _this select 0;

if (count (crew _veh)) [color="#FF0000"]=[/color]= 0) then {
_veh removeAction Dmanu;
_veh removeAction Dtail;
_veh removeAction Dreset;
};

it will remove the actions when the chopper is empty. if there are gunners or riders in the back then it will still have the actions.

Share this post


Link to post
Share on other sites

Awesome! Thanks alot :D Do you know how I can add a blue color to the "Damage Menu"? So it's like this:

Get out

engine Off

auto-hover on

damage menu (with blue letters)

Can this be done? :)

Share this post


Link to post
Share on other sites

Define the color in the first addAction script, then add it to the addAction.

Damage_Init.sqf:

_veh = _this select 0;
blueText = {"<t color='#0000FF'>" + _this + "</t>"};

if ((count (crew _veh)) < 2) then {
Dmanu = _veh addAction ["Damage Manu", call blueText, "Damage_Manu.sqf"];
};

Then, since the color is defined globally, just add the "call blueText" bit to each of the other scripts where an addAction is created.

Share this post


Link to post
Share on other sites

Dude, there is something wrong here..

I didnt get to try it out before now, but when I apply the color code to Damage_Init.sqf the menu dont show up in the chopper menu..

there is something here that deletes the script.. (?)

blueText = {"<t color='#0000FF'>" + _this + "</t>"};

Edited by Chillroy

Share this post


Link to post
Share on other sites

And also this did not get fixed by adding the double ==.

There is some wrong with the Init script

in = this addEventHandler ["GetIn", {_this execVM "Damage_Init.sqf"}]; out = this addEventHandler [""GetOut"", {_this execVM "Damage_Close.sqf"}];

It does not work. When I press OK it says "Missing [" and skips to [""GetOut""

I edited it to

in = this addEventHandler ["GetIn", {_this execVM "Damage_Init.sqf"}]; out = this addEventHandler [b]["GetOut"[/b], {_this execVM "Damage_Close.sqf"}];

But now the menu dont disappear when Im exiting the chpper. I can use the menu from outside the chopper.

Anyone?

Share this post


Link to post
Share on other sites
Dude, there is something wrong here..

I didnt get to try it out before now, but when I apply the color code to Damage_Init.sqf the menu dont show up in the chopper menu..

there is something here that deletes the script.. (?)

blueText = {"<t color='#0000FF'>" + _this + "</t>"};

Use that:

Dmanu = _veh addAction ["<t color='#0000FF'>Damage Manu</t>", "Damage_Manu.sqf"];

And also this did not get fixed by adding the double ==.

found the (stupid) problem i did:

Damage_Close.sqf:

_veh = _this select 0;

if ([color="#FF0000"]([/color]count (crew _veh)) == 0) then {
_veh removeAction Dmanu;
_veh removeAction Dtail;
_veh removeAction Dreset;
};

my fail, sorry. :p

Share this post


Link to post
Share on other sites

Works like a charm :) Thank you!

Now anyone have a recipe for adding more options to the menu?

Tried this but after I activate it the menu don't show up. I have to re-enter the chopper.

In Damage_Elek.sqf:

_target = _this select 0;

_target removeAction Dtail;
_target removeAction Delek;
_target removeAction Dreset;


(vehicle _target) setHit ["elektronika", 1]

Delek = _target addAction ["Damage Menu", "Damage_Menu.sqf"];

Damage_Close.sqf:


_veh = _this select 0;

if ((count (crew _veh)) == 0) then {
_veh removeAction Dmenu;
_veh removeAction Dtail;
_veh removeAction Delek;
_veh removeAction Dreset;

};

In Damage_Menu.sqf:

_target = _this select 0;
_id = _this select 2;

_target removeAction _id;

Dtail = _target addAction ["Tail rotor Failure", "Damage_Tail.sqf"];
Delek = _target addAction ["Destroy Electronics", "Damage_Elek.sqf"];
Dreset = _target addAction ["Reset Aircraft", "Damage_Reset.sqf"];

Damage_Reset.sqf

_target = _this select 0;


_target removeAction Dtail;
_target removeAction Dreset;

(vehicle _target) setHit ["mala vrtule", 0];
(vehicle _target) setHit ["motor", 0];
(vehicle _target) setHit ["velka vrtule", 0];
(vehicle _target) setHit ["elektronika", 0];

Dmenu = _target addAction ["Damage Menu", "Damage_Menu.sqf"];

Damage_Tail.sqf:

_target = _this select 0;

_target removeAction Dtail;
_target removeAction Delek;
_target removeAction Dreset;


(vehicle _target) setHit ["mala vrtule", 1];

Dmenu = _target addAction ["Damage Menu", "Damage_Menu.sqf"];

What am I doing that fucks everything up?

Share this post


Link to post
Share on other sites
Works like a charm :) Thank you!

Now anyone have a recipe for adding more options to the menu?

Tried this but after I activate it the menu don't show up. I have to re-enter the chopper.

In Damage_Elek.sqf:

_target = _this select 0;

_target removeAction Dtail;
_target removeAction Delek;
_target removeAction Dreset;


(vehicle _target) setHit ["elektronika", 1]
[color="#FF0000"]
Dmanu = _target addAction ["<t color='#0000FF'>Damage Manu</t>", "Damage_Manu.sqf"];
[/color]

In Damage_Menu.sqf:

_target = _this select 0;
_id = _this select 2;

_target removeAction _id;

Dtail = _target addAction ["Tail rotor Failure", "Damage_Tail.sqf"];
Delek = _target addAction ["Destroy Electronics", "Damage_Elek.sqf"];
Dreset = _target addAction ["Reset Aircraft", "Damage_Reset.sqf"];

Damage_Reset.sqf

_target = _this select 0;

[color="#FF0000"]_target removeAction Delek;[/color]
_target removeAction Dtail;
_target removeAction Dreset;

(vehicle _target) setHit ["mala vrtule", 0];
(vehicle _target) setHit ["motor", 0];
(vehicle _target) setHit ["velka vrtule", 0];
(vehicle _target) setHit ["elektronika", 0];

[color="#FF0000"]Dmanu = _target addAction ["<t color='#0000FF'>Damage Manu</t>", "Damage_Manu.sqf"];[/color]

Damage_Tail.sqf:

_target = _this select 0;

_target removeAction Dtail;
_target removeAction Delek;
_target removeAction Dreset;


(vehicle _target) setHit ["mala vrtule", 1];

[color="#FF0000"]Dmanu = _target addAction ["<t color='#0000FF'>Damage Manu</t>", "Damage_Manu.sqf"];[/color]

What am I doing that fucks everything up?

thats all I could see. It should work now.

Share this post


Link to post
Share on other sites

No, still have to re-enter the helicopter.

Here are all the scripts:

In helicopter Init:

in = this addEventHandler ["GetIn", {_this execVM "Damage_Init.sqf"}]; out = this addEventHandler ["GetOut", {_this execVM "Damage_Close.sqf"}];

In Damage_Close.sqf

_veh = _this select 0;

if ((count (crew _veh)) == 0) then {
_veh removeAction Dmenu;
_veh removeAction Dtail;
_veh removeAction Delek;
_veh removeAction Dreset;

};

Damage_Elek.sqf:

_target = _this select 0;

_target removeAction Delek;
_target removeAction Dtail;
_target removeAction Dreset;


(vehicle _target) setHit ["elektronika", 1]

Dmenu = _target addAction ["<t color='#FF4000'>Damage Menu</t>", "Damage_Menu.sqf"];

Damage_Init.sqf

_veh = _this select 0;

if ((count (crew _veh)) < 2) then {
Dmenu = _veh addAction ["<t color='#FF4000'>Damage Menu</t>", "Damage_Menu.sqf"];
};

Damage_Menu.sqf

_target = _this select 0;
_id = _this select 2;

_target removeAction _id;

Dtail = _target addAction ["Tail rotor Failure", "Damage_Tail.sqf"];
Delek = _target addAction ["Destroy Electronics", "Damage_Elek.sqf"];
Dreset = _target addAction ["Reset Aircraft", "Damage_Reset.sqf"];

Damage_Reset.sqf

_target = _this select 0;

_target removeAction Delek;
_target removeAction Dtail;
_target removeAction Dreset;

(vehicle _target) setHit ["mala vrtule", 0];
(vehicle _target) setHit ["motor", 0];
(vehicle _target) setHit ["velka vrtule", 0];
(vehicle _target) setHit ["elektronika", 0];

Dmenu = _target addAction ["<t color='#FF4000'>Damage Menu</t>", "Damage_Menu.sqf"];

Damage_Tail.sqf

_target = _this select 0;

_target removeAction Dtail;
_target removeAction Delek;
_target removeAction Dreset;


(vehicle _target) setHit ["mala vrtule", 1];

Dmenu = _target addAction ["<t color='#FF4000'>Damage Menu</t>", "Damage_Menu.sqf"];

Should I maybe just delete everything that has to do with Damage_Elek and start over?

Share this post


Link to post
Share on other sites

not sure if this will help or just confuse ya.

the way I have been using addactions for a while is to give the player the addaction directly and thru the available conditions part of the addaction syntax it will only show when its told to based on your conditions you set.

example

menu = player addAction["<t color='#0457FB'>MENU</t>","menu.sqf",[],1,false,true,"","Local player && player in choppername"];   

ok, the conditions are at the end.. note the "player in choppername"... the addaction will only show if you are in the chopper. (no need for eventhandlers)

doing actions this way saves the remove action part at very least.

here is the link to the addaction command - just so you can see how to use the syntax parameters

http://community.bistudio.com/wiki/addAction

Share this post


Link to post
Share on other sites
Wut..?

its just a different method of making it work.

take this code and put it in the init field of your instructors (or the men that will be able to use the manu):

Dmenu = this addAction ["<t color='#FF4000'>Damage Menu</t>", "Damage_Menu.sqf",[],1,false,true,"","Local this && this in yourchoppername"];

Damage_Menu.sqf

_target = _this select 0;
_id = _this select 2;

_target removeAction _id;

Dtail = _target addAction ["Tail rotor Failure", "Damage_Tail.sqf",[],1,false,true,"","Local _target && _target in yourchoppername"];
Delek = _target addAction ["Destroy Electronics", "Damage_Elek.sqf",[],1,false,true,"","Local _target && _target in yourchoppername"];
Dreset = _target addAction ["Reset Aircraft", "Damage_Reset.sqf",[],1,false,true,"","Local _target && _target in yourchoppername"];

null = [_target] execVM "Damage_Close.sqf";

Damage_Tail.sqf

_target = _this select 0;

_target removeAction Dtail;
_target removeAction Delek;
_target removeAction Dreset;


(vehicle _target) setHit ["mala vrtule", 1];

Dmenu = _target addAction ["<t color='#FF4000'>Damage Menu</t>", "Damage_Menu.sqf",[],1,false,true,"","Local _target && _target in yourchoppername"];

Damage_Elek.sqf:

_target = _this select 0;

_target removeAction Delek;
_target removeAction Dtail;
_target removeAction Dreset;


(vehicle _target) setHit ["elektronika", 1]

Dmenu = _target addAction ["<t color='#FF4000'>Damage Menu</t>", "Damage_Menu.sqf",[],1,false,true,"","Local _target && _target in yourchoppername"];

Damage_Reset.sqf

_target = _this select 0;

_target removeAction Delek;
_target removeAction Dtail;
_target removeAction Dreset;

(vehicle _target) setHit ["mala vrtule", 0];
(vehicle _target) setHit ["motor", 0];
(vehicle _target) setHit ["velka vrtule", 0];
(vehicle _target) setHit ["elektronika", 0];

Dmenu = _target addAction ["<t color='#FF4000'>Damage Menu</t>", "Damage_Menu.sqf",[],1,false,true,"","Local _target && _target in yourchoppername"];

In Damage_Close.sqf

_target = _this select 0;
while {true} do {
waitUntil {vehicle _target == _target};
_target removeAction Delek;
_target removeAction Dtail;
_target removeAction Dreset;

Dmenu = _target addAction ["<t color='#FF4000'>Damage Menu</t>", "Damage_Menu.sqf",[],1,false,true,"","Local _target && _target in yourchoppername"];

you need to remove the eventhandlers from the init field of the chopper.

and dont forget to put the name of the chopper instead of "yourchoppername" on all the scripts.

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  

×