Jump to content
olegreyghost

Question concerning command "removeAllActions"

Recommended Posts

I am fairly new at scripting & attempted a simple AddAction script where the player group was given a choice on how to continue with the mission.


Code:
choice.sqf
_act = Talon1 addAction ["Accept", "scripts\task2.sqf"];

_act = Talon1 addAction ["Decline", "scripts\task3.sqf"];

 

This is activated when a certain task is completed.  It displays the "Accept/Decline" message onscreen plus they are now included as choices in the action menu.  The task2 & task3 scripts execute successfully when they are chosen.
My problem becomes, at other points further into the mission, the "accept/decline" message is displayed onscreen again.  To alleviate the problem I set up a trigger to clear the actions according to the biki. The repeated message popup onscreen is distracting.


Cond:    this
Act:    removeAllActions Talon1;  (the preferred method according to the biki)  


The trigger is placed, so whichever direction the group has to take it is activated.
I still get the message onscreen further into the mission & the commands are still listed in the action menu.  Plus if you click on them, they still call the appropriate script.  Nothing appears to have been removed.
I read PierreMGIs' comment as to not use Thors' hammer command above & also tried the "removeAction" command in the trigger:


Cond:    This
Act:    Talon1 removeAction 0; Talon1 removeAction 1;


This didn't work either.

Can someone please explain why these commands aren't working & point me in the right direction.  It would be greatly appreciated.......
 

Share this post


Link to post
Share on other sites

Thanks for the quick reply.

 

That was the article I read.  In other words, I can only use "removeAllActions player;"..

 

Talon1 was the name given to the player & evolved into the group name when he took charge of additional units.  That name is working with other commands & scripts.

Share this post


Link to post
Share on other sites

@olegreyghost

 

I tested this:

 

Trigger:

Activation: Any Player

OnActivation:

_dummy = player addAction ["Exec the file", "scriptFile.sqf"]

 

scriptFile.sqf:

params ["_target", "_caller", "_actionId", "_arguments"];

hint "Executed";

_caller removeAction _actionId;

 

 

Share this post


Link to post
Share on other sites

If Talon1 is now the group variable name, it won't work. The command requires a unit variable name.

 

Overwriting variables in that manner is bad practice, this being one of the reasons why.

Share this post


Link to post
Share on other sites

@ sarogahtyp 

Thanks for the reply, but that is beyond me at this time.  I really appreciate the time & effort you took.

 

@ Harzach 

The mission calls for player "Talon1" to rendevous with a (3) three man squad, called Echo.  I used the joinSilent command to attach Echo to Talon1.  From what I gathered, this now makes the name Talon1 a group name.  So I basically, shot myself in the foot.

 

The wiki article uses "removeAllActions player" for an example.  Can I just use this iteration to clear the action menu?  If not, how would I go about it??

 

Will check back later this afternoon......

Share this post


Link to post
Share on other sites

choice.sqf

_act1 = Talon1 addAction ["Accept", "scripts\task2.sqf"];

_act2 = Talon1 addAction ["Decline", "scripts\task3.sqf"];

Talon1 setVariable ["act_IDs", [ _act1, _act2 ] ];

 

beginning of task2.sqf and task3.sqf

_caller = _this select 1;

_actIDs = _caller getVariable "act_IDs";

_caller removeAction (_actIDs select 0);
_caller removeAction (_actIDs select 1);

 

  • Like 1

Share this post


Link to post
Share on other sites
14 hours ago, olegreyghost said:

I read PierreMGIs' comment as to not use Thors' hammer command above & also tried the "removeAction" command in the trigger:


Cond:    This
Act:    Talon1 removeAction 0; Talon1 removeAction 1;

 

 

addAction is well described in BIKI.

What is talon1 ?? an object , or a player?

 

First of all, you must have a clear view of what result you want to obtain: where, when , for who,...  For us, here, it's impossible to understand everything you want to do: accept/decline mission(s) once or on each object, or else.

Among all possibilities:

- you can play with the distance to the object(s) if you add an action on object(s)

- you can write some (extra) conditions for the menu to be displayed,

 

Removing actions has sense for players, i.e. permanent actions added on player himself. Because these actions are permanently checked and perhaps you don't want to check a complex condition all game long!

I'm not sure, adding action on player is the best solution for your aim, but that works of course.
On the other hand, the actions added on object are pre-checked by distance only. That means, you can write a complex condition on them, it will not be checked if not within a close distance (50m)

If you plan to have several locations for several different missions, i suggest you to addAction on objects (like board in a briefing room, a campfire or even the static unit...) Each time you can avoid addAction on player himself, choose this way.

 

 

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, olegreyghost said:

@ Harzach 

The mission calls for player "Talon1" to rendevous with a (3) three man squad, called Echo.  I used the joinSilent command to attach Echo to Talon1.  From what I gathered, this now makes the name Talon1 a group name.  So I basically, shot myself in the foot.

 

The wiki article uses "removeAllActions player" for an example.  Can I just use this iteration to clear the action menu?  If not, how would I go about it??

 

Will check back later this afternoon......


There's some confusion here.

 

How are you joining Echo to Talon? "Echo" can't be used as a variable, so you must be using other means. Also, the unit(s) joining a group take on the groupID of the group they are joining, so Echo should become part of Talon1, not the other way around.

Do your units all have variable names? Do your groups? Do you understand what I mean when I say "variable name?"

"Player" refers to the player that is local where the command is executed. Depending on where the command is executed, this may include all players in co-op/MP. So yes, you can use it if you know what you are doing, but it's better to be more specific. The command removeAllActions Talon1 should work, as long as the unit's variable name is indeed "Talon1." If it's just their callsign, it won't work.

TL;DR - show your work
 

Share this post


Link to post
Share on other sites

@olegreyghost,
We learned how to use removeAllActions but maybe there is a different solution.
BIS_fnc_guiMessage will create a Choice Menu from which you can run code based on the selection made,

comment "use params to transfer variables into the spawn scope";
null= [player, talon_1] spawn {

	uiSleep 0.5;
	comment "required sleep for menu to load";

	private _result= ["Menu Title", "Select", "Accept", "Decline"] call BIS_fnc_guiMessage;
	comment "menu title, subtitle, button OK, button CANCEL";

	if (_result) then {
		//accept code
	} else {
		//decline code
	}
};

Have fun!

Share this post


Link to post
Share on other sites

@sarogahtyp

Thank you for the additional effort.  This I can follow & understand.  Most examples are sometimes vague in their descriptions & I am still trying to work out the naming conventions for the variables & parameters.  The last time I worked on this mission was (4) years ago.  I have some catching up to do.  An idle brain, does not retain.


@Harzach

I apologize for the confusion.  I should not have used the term squad.  They are (3) units used to reinforce Talon1.  I used the command [Echo_Leader, Echo_mgun, Echo_rifle] joinSilent Talon1; - in a trigger activated by the player - Talon1 to complete a task named rendevous.  I realize the Echo units are a part of Talon1.  I read in a lot of old posts on Armaholic that you should always name things you create & had some of my more difficult questions answered F2skel, Grumpy Old Man & pierremgi.  It makes for more efficient code & it is easier to follow the flow.  I did not assign a  group name to anything.

I do use Talon1 to trigger radio communications, ( like when he completes a task) but did not assign that name as any callsign.  I hope this clears things up.  Thanks for cleating thing up.

 

@pierremgi

This was just a simple additional task being assigned after completing the main mission.  The player "Talon1" being given the choice of accepting/declining depending on his situation. It is doing what I want it to do, I Just should have explained it better

I know that it is constantly checked, because it keeps popping the message up on the screen, even during combat. I did not expect this.  If it just stood in the action menu, it wouldn't have made a difference.

I thank you for the additional info on how to treat more complex missions with this command.  Right now I need to KISS for me.  Again, thank you for all your assistance, especially when I first started on this mission.  Now I just have to flesh out the ending......

 

@wogz187

Thank you for the time & effort to come up with a solution.  I will keep this for future reference, just in case.....

Share this post


Link to post
Share on other sites

@sarogahtyp,

Your script worked like a charm.  It also showed me the error of my ways.

 

choice.sqf

_act = Talon1 addAction ["Accept", "scripts\task2.sqf"];

_act = Talon1 addAction ["Decline", "scripts\task3.sqf"];

 

The _act variables were given the same name & were not set as act_IDs'.  Plus it was left out of both task2 & 3.sqf.  Now I see why the removeAllActions Talon1; command did not work.   Thanks again.  I will try to be more careful in the future......

 

  • Like 2

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

×