Jump to content
voidbyte

removeAllActions without extra script?

Recommended Posts

Hello,

 

atm I use this to teleport around:
 

private ["_telePorter", "_caller", "_telPos", "_playerrank"];

_telPort =_this select 0;
_caller = _this select 1;
_playerrank = [0] call isBoss;
if (_playerrank == 1) then {
    removeAllActions _caller;
    _caller addAction ["Kontrollraum", { _this select 0 setPosASL (getPosASL (tele_porter_Hauptquartier));} ];
    _caller addAction ["Turm 1", { _this select 0 setPosASL (getPosASL (telPort_Parkour_tower1));} ];
    _caller addAction ["Turm 2", { _this select 0 setPosASL (getPosASL (telPort_Parkour_tower2));} ];
    _caller addAction ["Turm 3", { _this select 0 setPosASL (getPosASL (telPort_Parkour_tower3));} ];
    _caller addAction ["Turm 4", { _this select 0 setPosASL (getPosASL (telPort_Parkour_tower4));} ];
    _caller addAction ["Turm 5", { _this select 0 setPosASL (getPosASL (telPort_Parkour_tower5));} ];
    _caller addAction ["Turm 6", { _this select 0 setPosASL (getPosASL (telPort_Parkour_tower6));} ];
    _caller addAction ["Turm 7", { _this select 0 setPosASL (getPosASL (telPort_Parkour_tower7));} ];

    } else { hint "Dieser Teleporter ist leider nicht für dich!" };

 

Now, the Problem is, that this action menu wont dissapear.
I know, i could write 8 indipendent Scripts for each teleport location. And after every line "removeAllActions _caller;"
but that is a bit... ugly. Also i could make trigger areas in the target location and perform an removeAllAction on Enter. But thats also .. ugly.
Is there no elegant way to just do something like:

 

    _caller addAction ["Turm 1", { _this select 0 setPosASL (getPosASL (telPort_Parkour_tower1)) && removeAllAction this select 0;} ];

 

or any type of:

if (_caller choose option x) then {removeAllAction _caller};

or any sort of timer, like a self delete after 2 seconds after choose has been made?

 

Thank you for your answers.

Share this post


Link to post
Share on other sites

You're actually pretty close:

 

removeAllActions
 

 _caller addAction ["Turm 1",{(_this select 0) setPosASL getPosASL telPort_Parkour_tower1; removeAllActions (this select 0);}];

 

  • Thanks 1

Share this post


Link to post
Share on other sites

The problem is you addAction on player(s) (_caller). Then you delete all actions on him (them) to let the menu clean.

You should consider teleport action on object(s). If the player can initiate an action on some _telport, there is no reason to add the further actions on player instead of this object.... except if you absolutely want a kind of "superpower" acquired by player for a one shot teleportation when he wants...

Share this post


Link to post
Share on other sites
5 hours ago, Sgt. Dennenboom said:

You're actually pretty close:

 

removeAllActions
 


 _caller addAction ["Turm 1",{(_this select 0) setPosASL getPosASL telPort_Parkour_tower1; removeAllActions (this select 0);}];

 

 

damnit... i tried that a hundret times.. an now i just copy your line and it works.. Thank you man! (Whatever I did wrong, now it is solved :D )

 

 

3 minutes ago, pierremgi said:

The problem is you addAction on player(s) (_caller). Then you delete all actions on him (them) to let the menu clean.

You should consider teleport action on object(s). If the player can initiate an action on some _telport, there is no reason to add the further actions on player instead of this object.... except if you absolutely want a kind of "superpower" acquired by player for a one shot teleportation when he wants...

 

There is indeed a reason for this. The person is some kind of spectator and get this actionmenu from a special item (phonebox.. because.. TELE-Port.. you get it? :D ). But those boxes not hanging around everywhere. Whenever the team on sea level pass a trigger (to compensate their progression) a new phonebox popping up and allow the spectator to jump to the next part of the parcour. So I prevent that the Spectator is giving spoilers to the team and be able to reuse the system for further missions. Sure they would be other methods.. or more elegant. But this is in my (SQF rookie state) the easiest.

Share this post


Link to post
Share on other sites

It's not advisable to use removeAllActions unless you're debugging or trying out stuff in the editor, this script command has no place in a mission, unless you want to risk breaking other mods/addons/scripts that use addAction.

 

If it absolutely has to be on a player simply track those addAction IDs (that's what return values are there for, and handle the removal in a dedicated function.

You can also streamline the addActions into a single line, use forEach and the arguments parameter.

Also don't write the code you want to happen upon activation inside the addAction, but put it into a function for easier editing and overview, like this:

 

TAG_fnc_spectatorTeleport = {
	params ["_object","_caller","_ID","_teleportDestination"];
	_caller setPosASL (getPosASL _teleportDestination);
	_caller call TAG_fnc_removeTeleportActions;
	true
};

TAG_fnc_removeTeleportActions = {
	params ["_caller"];
	_actions = _caller getVariable ["TAG_fnc_teleportActionIDs",[]];
	{
		_caller removeAction _x;
	} forEach _actions;
	true
};

_actionIDs = [];
_teleports = [["Kontrollraum",tele_porter_Hauptquartier],["Turm 1",telPort_Parkour_tower1],["Turm 2",telPort_Parkour_tower2],["Turm 3",telPort_Parkour_tower3],["Turm 4",telPort_Parkour_tower4],["Turm 5",telPort_Parkour_tower5],["Turm 6",telPort_Parkour_tower6],["Turm 7",telPort_Parkour_tower7]];
{
	_actionIDs pushBack (_caller addAction [_x#0, {_this call TAG_fnc_spectatorTeleport},_x#1]);
} forEach _teleports;

//now _actionIDs holds all actions for further control by the "remove" function above
_caller setVariable ["TAG_fnc_teleportActionIDs",_actionIDs];

Not tested but I don't see how this wouldn't work, if your goal is to remove all actions when any of them is being activated, judging from your post.

 

Cheers

Share this post


Link to post
Share on other sites

Cheers grumpy... 

yeah.. thats pretty straight foreward. Give me some time to understand what I see. Because for 80% of this.. I have NO Idea what it is doing. Or more specific: Why is it doing..

As I sayed.. im a beginner in SQF and just work with the command-reference from bohemia

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, voidbyte said:

Cheers grumpy... 

yeah.. thats pretty straight foreward. Give me some time to understand what I see. Because for 80% of this.. I have NO Idea what it is doing. Or more specific: Why is it doing..

As I sayed.. im a beginner in SQF and just work with the command-reference from bohemia

Most likely the best way to go about it, try out and look at a commands wiki entry, alternate syntax and most importantly the comments below can be easily missed, usually provides all the clarification that's needed, otherwise just ask, that's what the forum is there for.

 

Cheers

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

×