Jump to content
Sign in to follow this  
bull_a

Return array of all actions for a given unit

Recommended Posts

Would anyone know of a command, or a peice of code that returns all the actions attached to a given object.

For example:

_actions = allActions player;
{
if (_x == someVar) then {player removeAction _x} else {doSomethingElse};
} forEach _actions

Preferably this command or code would return an array of NUMBER types

Kind Regards,

Bull

Share this post


Link to post
Share on other sites

Not trying to remove all the actions, im only trying to remove a select few whose ID's are unknown.

The plan was to look at the action text by using the action id to return this, then based on the action text remove actions associated with healing for example. You are right though, there is no command 'allActions' but I think there needs to be one

Bull

Share this post


Link to post
Share on other sites

I think the reason there isn't one is because BI is protecting the native actions (repair, heal, defuse, etc.), as an allActions type command would inherently return those action IDs as well.

Share this post


Link to post
Share on other sites

Its a shame if this is the case. I will post a ticket about this and see what I can get out of it

Share this post


Link to post
Share on other sites

If you have indices of known actions you can figure out those that are unknown.

[color="#FF8040"]KK_fnc_removeUnknownUserActions [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
[color="#191970"][b]for[/b][/color] [color="#7A7A7A"]"_i"[/color] [color="#191970"][b]from[/b][/color] [color="#FF0000"]0[/color] [color="#191970"][b]to[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#000000"]player[/color] [color="#191970"][b]addAction[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]""[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]""[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]do[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
	[color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]![/b][/color][color="#8B3E2F"][b]([/b][/color][color="#1874CD"]_i[/color] [color="#191970"][b]in[/b][/color] [color="#000000"]_this[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
		[color="#000000"]player[/color] [color="#191970"][b]removeAction[/b][/color] [color="#1874CD"]_i[/color][color="#8B3E2F"][b];[/b][/color]
	[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color][/color]

Made with KK's SQF to BBCode Converter

test

[color="#FF8040"][color="#191970"][b]for[/b][/color] [color="#7A7A7A"]"_i"[/color] [color="#191970"][b]from[/b][/color] [color="#FF0000"]0[/color] [color="#191970"][b]to[/b][/color] [color="#FF0000"]9[/color] [color="#191970"][b]do[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
[color="#000000"]player[/color] [color="#191970"][b]addAction[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"Action #"[/color] [color="#8B3E2F"][b]+[/b][/color] [color="#191970"][b]str[/b][/color] [color="#1874CD"]_i[/color][color="#8B3E2F"][b],[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
	[color="#8B3E2F"][b][[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]5[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]6[/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] KK_fnc_removeUnknownUserActions[color="#8B3E2F"][b];[/b][/color] 
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color][/color]

Made with KK's SQF to BBCode Converter

clicking any action removes all actions but 0, 5 and 6

Edited by Killzone_Kid
removed extra spawn

Share this post


Link to post
Share on other sites

Thanks Killzone, hopefully they add a scripting command. Would make my life a lot easier :) I'll give this a try

Thanks,

Bull

Share this post


Link to post
Share on other sites
Thanks Killzone, hopefully they add a scripting command. Would make my life a lot easier :) I'll give this a try

Thanks,

Bull

There is no point, action ids are sequential, to find the range you can just add and remove an action. So the range will be from 0 to last_added_id -1

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  

×