Jump to content
felipechapmanfromm

Need to run code when asset is in a certain area

Recommended Posts

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
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

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

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);
};
};

 

  • Confused 2

Share this post


Link to post
Share on other sites

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×