Jump to content
Sign in to follow this  
falconx1

Add action - Using Range if a player is within range.

Recommended Posts

I'm using this code below in the "Objective" Crates Init field

It works as is when i get close to the object it allows me to use the action assigned, how ever the way i want my mission played and the objective secured, don't work together

because as the code below works. it wrecks the game play aspect.

Example Problem with the current code below:

The object spawns in a building, A player can point his mouse cursor thru a window at the objective about 15 feet away, and secure the objective.

I want it to detect range better, forcing the player to have to go inside the building and secure the objective.


this allowDamage false;  this addAction ["Secure Objective", "SecureObjective.sqf"]; 

Share this post


Link to post
Share on other sites

Use the condition field of addAction.

this addEventHandler["HandleDamage", {}]; this addAction ["Secure Objective","SecureObjective.sqf",[],1,false,true,"","_this distance _target < 2"];

Share this post


Link to post
Share on other sites

do i just replace my code with all the u code wrote, in the objective crates init field? where is the condition field lol?

Share this post


Link to post
Share on other sites

Yup, replace yours. :)

The condition field is the last one there. _this = the person using the action. _target = the object that has the action. So that condition of "_this distance _target < 2" means "Don't display the action until the person trying to use it is within 2 meters.

Share this post


Link to post
Share on other sites

the code i was using the action was working in all server and dedicated. and i just noticed that now that this code below don't work on dedicated the action doesn't become available to the player, but on preview tests and on lan server it works.

lolol no idea why it wont work in dedicated. but i dont know what the thing that says false is for etc



if (side player == west) then {this addEventHandler["HandleDamage", {}]; this addAction [("<t color=""#FFFF66"">" + ("Secure Objective") + "</t>"),"SecureObjective.sqf",[],1,false,true,"","_this distance _target < 2"];  };





is it because im using this in a units init field too?

trying to find a way to deal with possible team killers too, should i replace all the eventhandler codes for making things indestructible with the other code? this allowDamage false;

if (side player == west) then {this addEventHandler["HandleDamage", {}];};

Edited by falconx1

Share this post


Link to post
Share on other sites

Eventhandlers and addaction are local, so yeah, need to be added on all clients.

AddAction has several parameters.

this addAction ["My Action", "my script.sqf", [],1,false,true,"","_this distance _target < 2"];

Name to display on action menu (String)

Script to run when activated (String)

Arguments passed to the script as _this select 3 (Array)

Priority of where it'll appear on the action menu list (Number)

Display on center of the screen? T/F (Bool)

Close the action menu when used? T/F (Bool)

Shortcut key (String)

Condition (String)

  • Like 3

Share this post


Link to post
Share on other sites

Im glad someone decided to show exactly how to fill in some of those blanks. That example would be a great example on the biki. Thanks Kylania

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  

×