Jump to content
Sign in to follow this  
bigshot

Addaction--> Distance from object

Recommended Posts

Ok, so this one seems so simple yet I am unable to make it work they way I want...

I'm using one of those smallish green land buildings as an FOB in my mission, and I need the following addaction to appear in your action menu when you drive your vehicle within 30m of the building (its calling a repair/rearm script for vehicles the player is in).

Here's the addaction command im starting with:

if (support_veh_refit_available) then {_fob addaction ["<t color=#ff0066'>Repair/Rearm/Refuel Vehicle</t>","support\veh_refit_fob.sqf", "", 0, true, true, "", "_this == player];};

This works fine except you must drive your vehicle too close to the building before it shows up on your action menu...How should I change it so it'll show up further away so you wouldn't have to drive so close up to it?

I've tried a bunch of snippets I've found while searching around (where you change the "_this==player" with a distance argument), but I cannot get any of them to work. No matter what I try I always have to drive up close against the building before the action shows in the menu.

Any ideas what would work?

Edited by BigShot

Share this post


Link to post
Share on other sites

Try

"(Player distance buildingName) <= 30"

If that doesn't work, then keep the above and change the action to be added to the player and not the fob

Share this post


Link to post
Share on other sites

the buildings can be many, they are all created dynamically so you never know what it's name will be...each time a player creates one it is sent to an array of existing fob's list "Array_of_FOBS"). I thought if I add it to the player then it might not work since player is in a vehicle, unless I use "vehicle player"?

Share this post


Link to post
Share on other sites

why so complicated when you could make a trigger with 30m radius and create the addAction when entering remove it when exit :)

Share this post


Link to post
Share on other sites

if you have an array of names then you could just look through the array

mylist =[b1,b2,b3,b4]

player addaction ["<t color='#ff0066'>Repair/Rearm/Refuel Vehicle</t>","support\veh_refit_fob.sqf", "", 0, true, true, "", "_this distance cursortarget < 30 and cursortarget in mylist"];

when ever you get within 30 meters of any object in the array mylist you get the action.

You only ever need the one action command.

Share this post


Link to post
Share on other sites
player addaction ["<t color='#ff0066'>Repair/Rearm/Refuel Vehicle</t>","support\veh_refit_fob.sqf", "", 0, true, true, "", "_this distance cursortarget < 30"];

.

This is what worked for me (however I did not to use the " in mylist" part)...just the "player addaction" and "_this distance cursortarget < 100" worked when running inside the script that creates the fob's...and to run outside the script I was able to just add a "forEach (Array_of_FOBS)" at the end.

It's amazing how such simple tasks can get so darn confusing when you don't have a good understanding of the syntax used in the code.

Thank you for all your help gentleman, much obliged :-)

Share this post


Link to post
Share on other sites

you could use something like

({(player distance _x) < 30} count mylist) > 0

as condition in the addaction

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  

×