Jump to content
Sign in to follow this  
jw custom

How to make a players addAction stay visible in vehicles?

Recommended Posts

Was a little unsure how to title this thread!

When i add a action to a player like this...

_action = player addAction ["Status", "status.sqf",[],-1,false];

...the action dissapear when entering a vehicle. If i then also add the action to the vehicle i got 2 "Status" actions in the action menu when standing next to the vehicle.

How do i keep the players "Status" action visible/accessable when entering a vehicle?

Share this post


Link to post
Share on other sites
[] spawn {
 waituntil {!isnull player};
 private ["_id","_veh"];
 while {true} do {
   waituntil {vehicle player == player};
   if (!isnil "_veh") then { _veh removeaction _id };
   _id = player addAction ["Action text here", "scriptname.sqf"];
   waituntil {vehicle player != player};
   player removeaction _id;
   _veh = vehicle player;
   _id = _veh addAction ["Action text here", "scriptname.sqf"];
 };
};

Share this post


Link to post
Share on other sites

There is now a much easier way in Arma 2, although you have to do it for every vehicle.

Use the last condition param in addAction to detect whether you are in the vehicle or not.

Eg: add both actions with a condition for the vehicle action.

Use whatever condition you deem suitable. Eg: "vehicle player != player" or "player in _target", etc.

player addAction ["Options...", "script.sqf", [], 1, false, true, "", ""];
_vehicle addAction ["Options...", "script.sqf", [], 1, false, true, "", "vehicle player != player"];

Share this post


Link to post
Share on other sites

"Easier" is debatable as you said you have to do that to every single vehicle. The spawn you can just paste into init.sqf and be done with it. :)

Share this post


Link to post
Share on other sites

Thanks for the replies. I know i found another solution for my problem just can't remember what it was hehe :p

But thanks for the info :cool:

Share this post


Link to post
Share on other sites

My suggestion:

while {true} do {
   sleep 0.1;
   _vehicle = (vehicle player);
   _action = _vehicle addAction ["Status", "status.sqf",[],-1,false];
   waitUntil {not ((vehicle player) == _vehicle)};
   _vehicle removeaction _action;
};

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  

×