felipechapmanfromm 5 Posted February 27, 2018 I am a new to scripting so I need help running a piece of code when the player is within a 5 meter radius. The asset is Land_SatellitePhone_F. I have tried if nearestObject is equal to Land_SatellitePhone_F the run {}. Thanks, felipe. Share this post Link to post Share on other sites
pokertour 30 Posted February 27, 2018 hi, you can try with Distance or Distance2D. https://community.bistudio.com/wiki/distance https://community.bistudio.com/wiki/distance2D with waituntil or something like that https://community.bistudio.com/wiki/waitUntil waituntil { player distance2D asset <= 5 } Share this post Link to post Share on other sites
felipechapmanfromm 5 Posted February 27, 2018 Thanks, I will try this Share this post Link to post Share on other sites
felipechapmanfromm 5 Posted February 27, 2018 waituntil {_dist = player distance2D Land_SatellitePhone_F <= 5 }; if (_dist) then{ hint "It works! }; This is my code, but it doesn't do anything. Is it because it is not recognising the asset, do I need to declare it somewere else? Thanks, Felipe Share this post Link to post Share on other sites
pierremgi 4694 Posted February 27, 2018 You mix some basics for scripting codes. https://community.bistudio.com/wiki/ArmA:_Introduction_to_Scripting Read yourself. Your waitUntil has no sense (= , <=). "Land_SatellitePhone_F" is a class. Land_SatellitePhone_F can be a variable name (why not?) but your need to place it in the init field of your sat phone. "if (_dist)" is checking for a Boolean (true or false) Here _dist seems to be a number... waitUntil {player distance2D yourPhone <= 5}; Share this post Link to post Share on other sites
felipechapmanfromm 5 Posted March 3, 2018 I have been trying to get this working but I have got nowhere, could you please correct my code. private ["_player"]; _player = param[0]; _dist = player distance2D Land_SatellitePhone_F <= 5 waituntil { if (_dist)exitWith{true}; _player addAction ["Open GUI","[] spawn BIS_fnc_showTestDialog;"]; while {countDown > -1} do { hint str(countDown); }; }; 2 Share this post Link to post Share on other sites
pierremgi 4694 Posted March 3, 2018 See addAction parameters (all you need in for the condition code, 8th param). I do some effort when people take time to read the answers. Share this post Link to post Share on other sites
felipechapmanfromm 5 Posted March 3, 2018 Thanks for that, my script is now working! Share this post Link to post Share on other sites