Jump to content
Sign in to follow this  
domcho

2 addAction/removeAction questions

Recommended Posts

Hello. I have 2 questions regarding addAction and removeAction.

1st how can I make an action available for everyone who enters a specific vehicle. I only found out how to do it for a driver

this addAction ["Action Name","MyAction.sqf",[1],0,false,true,""," driver  _target == _this"];

Is there a code that makes the action available for everyone regardless of their position in the vehicle and is there a code for only 2 positions in the vehicle (for example an action only available to driver and gunner).

2nd I am making a mission where you have to get in a helicopter to take a map because you start with no map. But because no players start with map I was wondering how can I make an action available to all players but only usable once per player. So if I take the map the action disappears for me but not for other players who haven't taken a map yet.

This is the map script:

1st helicopter init:

this addAction ["Take Map","Map.sqf",[1],0,false,true,""," driver  _target == _this"];

and Map.sqf:

_radarObject = _this select 0;
_activatingPlayer = _this select 1;
_actionId = _this select 2;

_activatingPlayer addWeapon "ItemMap";
_radarObject removeAction _actionId;

But the last line removes the action for everyone. If I don't use this line I can use the map action more than once and I don't want that. Thank you in advance.

Share this post


Link to post
Share on other sites

This should work.

2.

_caller = _this select 1;
_Id = _this select 3;
_caller addWeapon "ItemMap";
_caller removeAction _Id;

EDIT:

i did a little testing and you can do this:

make trigger.

condition: player in vehname

on act: player addweapon "itemMap"

im not sure if this is MP compatible but you can test.

Edited by sudslv

Share this post


Link to post
Share on other sites

1. Just change "driver _target == _this" to "vehicle _this == _target".

2. You got the answer from the user above me.

Share this post


Link to post
Share on other sites

addactions are LOCAL so only the player who uses it will see the effects of the script it runs.

I rarely ever give objects the action i'm trying to do. I find it much easier to give the players all the actions from the start of the game, but only show when I want them to by the condition in the action.


// action will only show when player is in vehicle named specVeh.
vehact = player addAction ["Action Name","MyAction.sqf",[1],0,false,true,"","Local player && player in specVeh"];

// action will only show when player is in vehicle named specVeh and does not have a map.
mapact = player addAction ["Take Map","Map.sqf",[1],0,false,true,"","Local player && _target in specVeh && !_target hasWeapon 'ItemMap'"];

map script to remove an action

_unit = _this select 0;

_unit addWeapon "ItemMap";
_unit removeAction mapact;

now 1 thing I did notice was in your original map script, you have

_radarObject = _this select 0;

so if you want an action to only show when your close enough to an object you can do

// add to action conditions for distance check
(_target distance specveh) < 2

vehact = player addAction ["Action Name","MyAction.sqf",[1],0,false,true,"","Local player && (_target distance specveh) < 2"];          

and 1 last note, don't forget that since the player now has the actions they will be lost on respawn.

so just reissue them again on respawn and they still wont show until conditions are met.

Share this post


Link to post
Share on other sites

I rarely ever give objects the action i'm trying to do. I find it much easier to give the players all the actions from the start of the game, but only show when I want them to by the condition in the action.


// action will only show when player is in vehicle named specVeh.
vehact = player addAction ["Action Name","MyAction.sqf",[1],0,false,true,"","Local player && player in specVeh"];

Nimrod_Z, how does this work for you? Actions added to players are not visible in vehicles, unless you use a work around like posted in this thread:

How to make a players addAction stay visible in vehicles?

or

CBA_fnc_addPlayerAction

or any other work around...

Just curious I guess. Maybe something has changed that I missed...

Share this post


Link to post
Share on other sites
Nimrod_Z, how does this work for you? Actions added to players are not visible in vehicles, unless you use a work around like posted in this thread:

How to make a players addAction stay visible in vehicles?

or

CBA_fnc_addPlayerAction

or any other work around...

Just curious I guess. Maybe something has changed that I missed...

to be honest I just assumed the "in" command would work as normal. but after testing it like you said, sure enough it does not work in a vehicle. - mental note added : )

so to change it up a bit, if its not absolutely needed to be in the vehicle you can make the action come up when close enough to it an looking at it.

vehact = player addAction ["Action Name","MyAction.sqf",[1],0,false,true,"","Local player && cursorTarget == specVeh && (_target distance specveh) < 4"];

but would be a lot easier to simply add the map to the vehicles cargo for that matter.

Share this post


Link to post
Share on other sites

Okay I did some random stuff with triggers and action scripts and finally achieved my goal.

Since I want the action to appear only when a player who hasn't taken a map is in the vehicle and if he gets out the action to disappear I did this

Player unit name is Gastovski. Init field -

this removeWeapon "ItemMap"; Map1Taken = false; Map2Taken = false

The other unit name is Mike.

then I use 2 triggers

1st trigger set to repeatedly

Condition - Gastovski in Hawk and Gastovski == driver Hawk and not (Map1Taken)

Activation - map1 = Hawk addAction ["Take Map","Map1.sqf",[1],0,false,true,""," driver _target == _this"]

2nd trigger set to repeatedly

Condition - not (Gastovski in Hawk)

Activation - hawk removeAction map1

3rd trigger set to repeatedly

Condition - Mike in Hawk and Mike == driver Hawk and not (Map2Taken)

Activation - map2 = Hawk addAction ["Take Map","Map2.sqf",[1],0,false,true,""," driver _target == _this"]

4th trigger set to repeatedly

Condition - not (Mike in Hawk)

Activation - hawk removeAction map2

Map1.sqf:

_radarObject = _this select 0;
_activatingPlayer = _this select 1;
_actionId = _this select 2;

_activatingPlayer addWeapon "ItemMap";
_radarObject removeAction _actionId;
Map1Taken = true;

Map2.sqf:

_radarObject = _this select 0;
_activatingPlayer = _this select 1;
_actionId = _this select 2;

_activatingPlayer addWeapon "ItemMap";
_radarObject removeAction _actionId;
Map2Taken = true;

I'm pretty sure Nimrod's way is easier and I will try it next time but since I already got what I wanted it I'm too lazy to recreate this whole thing. 2nd the _radarObject = _this select 0; is just a copy-paste from an addAction tutorial I found. I am not really sure what it is and what it means :D

Edited by Domcho

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  

×