Jump to content
Sign in to follow this  
ward1591

Would this work?

Recommended Posts

Okay so i have a action here i want to set only if player is near objects in a array stated in another script which is run in the init.sqf when the player joins.

here is the action sorry if its formatted wrong this is my first try with this thing...

["Lock Door","client\clientEvents\D_lock.sqf",0,0,false,false,"","player distance basedoors < 5"],

Below is the array which lists every object i want to use in this action...

basedoors =
[
   pmcb1d1, // PMC Building 1 Door 1 
   pmcb2d1, // PMC Building 2 Door 1  
   pmcb2d2 // PMC Building 2 Door 2   
];

Share this post


Link to post
Share on other sites

Didn't really take a lok at the action's syntax. Your condition looks like it would not work. Something like this may work. Assuming the action's (_target is the player) is added to the player and depending on what these pmcb1d1 objects are.

["Lock Door","client\clientEvents\D_lock.sqf",0,0,false,false,"","cursorTarget in baseDoors && {_target distance cursorTarget <=5}"],

Share this post


Link to post
Share on other sites

Ahh, well your condition wont work in any case. Try this.

// Again.. assuming the action was added to the player (_target), else just use player variable
["Lock Door","client\clientEvents\D_lock.sqf",0,0,false,false,"","{_target distance _x <= 5} count baseDoors > 0"], 

Share this post


Link to post
Share on other sites
Ahh, well your condition wont work in any case. Try this.

// Again.. assuming the action was added to the player (_target), else just use player variable
["Lock Door","client\clientEvents\D_lock.sqf",0,0,false,false,"","{_target distance _x <= 5} count baseDoors > 0"], 

The action is added to the player so i would just use player instead of _target?

---------- Post added at 03:54 ---------- Previous post was at 03:20 ----------

Ahh, well your condition wont work in any case. Try this.

// Again.. assuming the action was added to the player (_target), else just use player variable
["Lock Door","client\clientEvents\D_lock.sqf",0,0,false,false,"","{_target distance _x <= 5} count baseDoors > 0"], 

Okay so that didn't work is it because i'm using a gamelogic? Is there anyway i can get this action to work only when the player is near a door?

Edited by ward1591

Share this post


Link to post
Share on other sites

Hmm. Seems to work fine for me with gamelogics. I created a blank mission. Put down 3 gamelogics named bd1, bd2, and bd3. Created an init.sqf and put the following in it. Get the action when I'm close to any of the logics.

init.sqf

basedoors =
[
   bd1, 
   bd2, 
   bd3  
];  

player addAction [
"ACTION", 
{player sideChat "ACTION";},
[], 
0, 
false, 
true, 
"", 
"{_target distance _x <= 5} count baseDoors > 0"
];

Share this post


Link to post
Share on other sites
Hmm. Seems to work fine for me with gamelogics. I created a blank mission. Put down 3 gamelogics named bd1, bd2, and bd3. Created an init.sqf and put the following in it. Get the action when I'm close to any of the logics.

init.sqf

basedoors =
[
   bd1, 
   bd2, 
   bd3  
];  

player addAction [
"ACTION", 
{player sideChat "ACTION";},
[], 
0, 
false, 
true, 
"", 
"{_target distance _x <= 5} count baseDoors > 0"
];

Okay got it thank ICEMAN!!! One more question its off topic. How do i force players to be near a object for them to able to see a addAction on it?

Share this post


Link to post
Share on other sites

You add a condition in the last argument of the addAction command array (look up the addAction wiki page for more details), but an example for it would be this (player must be 3m from target):

"_this distance _target < 3"

In the example code Iceman gave, you must be at least 5m from any of the target objects (or gamelogics in your case) before the action will show. The default distance for an action to show up is 15m.

Share this post


Link to post
Share on other sites
You add a condition in the last argument of the addAction command array (look up the addAction wiki page for more details), but an example for it would be this (player must be 3m from target):

"_this distance _target < 3"

In the example code Iceman gave, you must be at least 5m from any of the target objects (or gamelogics in your case) before the action will show. The default distance for an action to show up is 15m.

Okay i tested this out on a object in editor

this addAction ["kill","kill.sqf","player distance this < 3"];

didnt seem to work?

Share this post


Link to post
Share on other sites

_target and _this are special variables. _target is the object the action is assigned to. _this is the unit that used the action.

Addaction condition parameter

(optional): String - script code that must return true for the action to be shown. Special variables passed to the script code are _target (unit to which action is attached to) and _this (caller/executing unit). Default value: "true"

NOTE: condition is evaluated on each frame in non-scheduled environment. If action is added to some object and not to player, condition will only get evaluated IF player is closer than 15m to the object AND is looking at the object. If action is added to player, the condition is evaluated all the time.

Edited by Iceman77

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  

×