Jump to content
Sign in to follow this  
HateDread

AddAction once out of water, then action deleted from list?

Recommended Posts

Hey guys,

Trying to get some sort of diver weapon storage working, but I can't figure out how to efficiently add some sort of condition that only adds an action to the menu when the player reaches the shore. I want it to disappear once activated, to be replaced by a counter action (i.e. 'retrieve diving gear' when the first one was 'store diving gear').

Just having trouble conceptualizing how to pass back some of the stuff through an execVM to the unit (as I was calling the diver's .sqf in the init field, but that might not be preferable?)

Thanks in advance!

- HateDread.

Share this post


Link to post
Share on other sites

You probably didnt know but you can set a condition that defines when an action is shown/available.

That way you dont have to mess around with adding, removing and possibly readding the action. Much less hassle. :)

Do it like this and the action will only show up when underwater:

act = this addAction["youractionname","thescripttocall.sqf","",1,false,true,"underwater player"];

You could use something similar to only make the action show up when a certain item is in the player-iventory.

More details here:

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

Number = unitName addAction [title, filename, (arguments, priority, showWindow, hideOnUse, shortcut, condition, positionInModel, radius, radiusView, showIn3D, available, textDefault, textToolTip)]
Edited by Tajin

Share this post


Link to post
Share on other sites

I've tried "!(underwater player)", but the action is still available no matter what. I'd prefer it to not even be available while on top of the water... the player has to be on solid ground. I tried getposASL, but I screwed that up too.

Can I pass something back into the init space that forms part of the condition for the opposite action? So either the variable passed back into the unit init space is a yes for action 1, or a yes for action 2, and so the appropriate action is shown in the menu. But I feel that this would be inefficient and messy, and I'm not sure if the init space can be changed after game start? (Probably... hence the name).

Share this post


Link to post
Share on other sites

Hmm, I've tried the following;

act = this addAction["Change for land combat","Scripts\DiverGearChange.sqf",this,1,false,false," surfaceiswater [getpos this select 0, getpost this select 1]"];

But it works whether I'm in water or not. What am I doing wrong?

Also, using SetVariable, if I've got the unit named in my .sqf, i.e. _diver = _this select 0, can I do the following?

_diver setVariable ["ChangedToLand", true, true];

Just not sure if I can pass it back like this.

Share this post


Link to post
Share on other sites

You do realize that your placing the condition in the wrong part of the addaction?

act = this addAction["Change for land combat","Scripts\DiverGearChange.sqf",this,1,false ,false,"","!surfaceiswater [getpos player select 0, getpos player select 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  

×