ward1591 10 Posted November 9, 2014 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
iceman77 19 Posted November 9, 2014 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
ward1591 10 Posted November 9, 2014 pmcb1d1 and the others are gamelogics? Share this post Link to post Share on other sites
iceman77 19 Posted November 9, 2014 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
ward1591 10 Posted November 9, 2014 (edited) 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 November 9, 2014 by ward1591 Share this post Link to post Share on other sites
iceman77 19 Posted November 9, 2014 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
ward1591 10 Posted November 9, 2014 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
jshock 513 Posted November 9, 2014 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
ward1591 10 Posted November 9, 2014 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
iceman77 19 Posted November 9, 2014 (edited) _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 November 9, 2014 by Iceman77 Share this post Link to post Share on other sites