Jump to content
Mr H.

MP Execute script only for players within a certain distance.

Recommended Posts

Hi! So here's my problem:

I want a script to execute only for players within hearing distance of a NPC
The script will be executed from another script, the latter being launched from an addaction.
I want the script to execute only on the machines of players nearby but obviously can't use a trigger area to count them.
How should I go about it?

Share this post


Link to post
Share on other sites
_list = anastasia nearEntities ["Man", 10];
{0= [] execVM "fnc\dialogue1.sqf";} forEach _list;

this doesn't work

Share this post


Link to post
Share on other sites

That's how you execute the script on all clients in MP:

{[] execVM "fnc\dialogue1.sqf"} remoteExec ["bis_fnc_call",0];

And then you put this at the top of your script:

if ( (player distance anastasia) > 10 ) exitWith {};

That way the script will be executed on ALL machines, but everything after the exitWith {}; will only be executed by the machines of players who are less than 10 meters in distance to anastasia.

  • Like 1

Share this post


Link to post
Share on other sites

I will try that immediatly thanks!

 

Share this post


Link to post
Share on other sites

It works perfectly thanks! + It's a very clever way to do it, I wouldn't have thought of it myself!

Share this post


Link to post
Share on other sites
<arguments> remoteExec ['tag_fnc_myFunction',(allPlayers select {((_x distance <center_position>) <= <radius>)})];

 

  • Like 2

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

×