Jump to content
Sign in to follow this  
padarom

Creating a custom action in scroll menu

Recommended Posts

Hello,

I found several threads about creating own action menu items, but none of them were useful for my purposes.

I'm pretty new in scripting for mission editing: All I've done so far are a few if-statements as a condition for triggers, or moving units into vehicles. I'd like to get into mission scripting a bit, so I thought this could be useful for learning, as well as for my newest co-op mission. The first task is to seize a camp where a BLUFOR squad was once stationed, but now eliminated by OPFOR units. The next task is to search the BLUFOR bodies for any information about their last objective.

To do that I want to create a custom action in my action menu, as soon as I'm in the range of a friendly body. This action should be named "Search body for information" or so.

In the camp I spawned a few BLUFOR units (as well as a OPFOR site module), which results in OPFOR killing the BLUFOR units pretty quickly. So there are around 5 bodies in the camp and only one should have the information.

As soon as the right body is searched (he's already choosen, so it's not random) the task should be set to succeeded and a new task should be created.

The other threads I've found about this topic were all about creating a permanent new action, I just want this action to pop up in the range of bodies.

I hope anyone is able to help me with it and can give me a good explanation or examples on how to do it.

Thanks in advance

Padarom

Share this post


Link to post
Share on other sites

addAction can pass arguments so this might be a good approach:

bodies without info:

this addAction ["Search body","search.sqf",false];

body with info:

this addAction ["Search body","search.sqf",true];

search.sqf:

_body = _this select 0;
_id = _this select 2;
_body removeAction _id;

_hasInfo = _this select 3;
// _hasInfo is the true or false that we passed from addAction

if (not _hasInfo) exitWith {hint "You did not find anything useful."};
// if we did not exit the script above you may add code to finish the task below, as it is the body with info.

Share this post


Link to post
Share on other sites

Thanks for the help :)

As I mentioned, I'm pretty new to SQF, so just a little question to my modification of your code: Is it important to execute the "exitWith" function, or can I also just show the hint (or trigger a new mission) instead? When doing it with if/else I get the error "Error Missing ;" when using exitWith at the same time. So I just left it.

_body = _this select 0;
_id = _this select 2;
_body removeAction _id;

_hasInfo = _this select 3;

if (not _hasInfo) then {
hint "You did not find anything useful.";
} else {
hint "You found the information you were looking for.";
}

Another question: I want to turn down the radius of the action menu. So I figured out there's a parameter in the addAction function that does that. Can I simply skip some parameters with underscorce (_) or something to leave all the other parameters at their default value (like so: addAction ["Search body", "search.sqf", true, _, _, _, _, _, _, 2];)?

Share this post


Link to post
Share on other sites

_unit addAction ["[u]MyAction[/u]", "[u]Myscript[/u].sqf/[u]MyCode[/u]", [], 0, false, true, "", "(_target distance _this) < [u]myDistance[/u]"];


There you go.

Edited by mantls

Share this post


Link to post
Share on other sites

ArmA3 allows code as the second argument of addAction now so if you have tiny script no need for it to be an external file.

Share this post


Link to post
Share on other sites

Once again you're right. Just too used to scripts and i believe it minimizes traffic, not sure though.

Share this post


Link to post
Share on other sites

Wasn't trying to correct you, just mentioning the awesome new stuff. :)

Share this post


Link to post
Share on other sites

Thank you all :)

The script works and I'm able to search all the bodies. I'll link this to a new task later and I'm one step further with my mission.

Share this post


Link to post
Share on other sites

hello

i'm trying to use this, but how do i make this a task? (i am using the arma 3 task module)

if You know what i mean?

my english is not that good:(

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  

×