Jump to content
Sign in to follow this  
Mokey II

removeAllActions Upon Selection

Recommended Posts

Currently I'm working on a teleportation Script. But my issue is when a player selects to use the object to teleport it keeps duplicating actions and will not remove.

 

How do I remove all actions if the object isn't being looked at OR an option is selected? 
Is there another way to have a sub menu rather than callign another sqf/function??

teleporterMainAction.sqf
 

_teleporterArray = [teleporterAirfield, teleporterAirfieldRunway];

{
        _x addAction ["<t color='#FF0000'>USE TELEPORTER</t>", "client\teleporter\teleporterSubActions.sqf"];
} forEach _teleporterArray;
removeAllActions player;

teleporterSubActions.sqf
 

_x = player;

_x addAction ["<t color='#FF0000'>Teleport To Airport Terminal</t>", {hint "Terminal Working" _this select 0 removeAllActions};];
_x addAction ["<t color='#FF0000'>Teleport To Airport Runway</t>", {hint "Runway Working"} _this select 0 removeAllActions};];
_x addAction ["<t color='#FF0000'>Teleport To Militart Base</t>", {hint "Military Base Working" _this select 0 removeAllActions};];

 

Share this post


Link to post
Share on other sites

Your syntax is wrong:

_this select 0 removeAllActions

https://community.bistudio.com/wiki/removeAllActions

// should be:
removeAllActions player;
// or:
// removeAllActions (_this select 0);

Use this instead:

player removeAction (_this select 2)

Read the arguments here:

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

Quote

Parameters array passed to the script upon activation in _this variable is: [target, caller, ID, arguments]

target (_this select 0): Object - the object which the action is assigned to

caller (_this select 1): Object - the unit that activated the action

ID (_this select 2): Number - ID of the activated action (same as ID returned by addAction)

arguments (_this select 3): Anything - arguments given to the script if you are using the extended syntax

I also recommend you don't use _x as it is MAGIC.

https://community.bistudio.com/wiki/Magic_Variables

  • 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
Sign in to follow this  

×