Jump to content
  • 0
webbie

Player Proximity Scan Script

Question

Hi all,

I have created a player scan script however when I load into the server it does not work.
Wondering if I am missing something or I need to add something to epoch to make it run.

Ive tried it in the editor with epoch, SP and MP and it works.

I feel like it might have something to do with using player/playableUnits  as the variable. Tried both.
I use infi as well. I dont think its an issue. Ive checked idd's etc

init.sqf and initplayerlocal.sqf

[] execVM "PlayerScan5sinitplayerlocal.sqf";

PlayerScan5sinitplayerlocal.sqf

GOM_fnc_scan = {
params [["_scanObject",objNull],["_scanRadius",250],["_duration",5],["_debug",false]];

	_scanObject setVariable ["GOM_fnc_scanActive",true,true];
	if (_debug) then {systemChat "Scanning for Players!"};
	hint "Scanning for Players!";
	sleep 1;
	_stopTime = time + _duration;
	waitUntil {

		_nearPlayers = (_scanObject nearEntities _scanRadius) - [player] select {isPlayer _x};
		hintsilent format ["Scanning: %1\nPlayers detected: %2",[-(time - _stopTime),"HH:MM"] call BIS_fnc_timeToString,count _nearPlayers];
		time > _stopTime
	};
	if (_debug) then {systemChat "Scanning Complete!"};
	_scanObject setVariable ["GOM_fnc_scanActive",false,true];

	hint "Scanning Complete!";

};

//add scan action to object
player addAction ["Scan for Players",{
	params ["_object","_caller","_ID"];

	_scan = [_object,15,5] spawn GOM_fnc_scan;

},[],0,true,true,"","_this isEqualTo vehicle _this AND !(_this getVariable ['GOM_fnc_scanActive',false])",5];

Thx in Advance.

 

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Thx for the reply @He-Man.

Ill give this a shot. 

Do I add this to cfgactionmenu_sef.hpp and then make the action the script?

what do I set the condition as if nothings reqd?

EDIT:
 

class Playerscan
{
    condition = "true";
    action = "custom\playerscan.sqf";
            icon = "x\addons\a3_epoch_code\Data\UI\buttons\geiger_alarmon.paa";
    tooltip = "Player Scan";
};

 

Share this post


Link to post
Share on other sites
  • 0

You can use the same settings as in your addaction:

class Playerscan
{
    condition = "player isEqualTo vehicle player && !(player getVariable ['GOM_fnc_scanActive',false])";
    action = "[player,15,5] spawn GOM_fnc_scan";
    icon = "x\addons\a3_epoch_code\Data\UI\buttons\geiger_alarmon.paa";
    tooltip = "Player Scan";
};

I think this should work

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, He-Man said:

You can use the same settings as in your addaction:

class Playerscan
{
    condition = "player isEqualTo vehicle player && !(player getVariable ['GOM_fnc_scanActive',false])";
    action = "[player,15,5] spawn GOM_fnc_scan";
    icon = "x\addons\a3_epoch_code\Data\UI\buttons\geiger_alarmon.paa";
    tooltip = "Player Scan";
};

I think this should work

For the action does the referenced script just go into the root folder? Im unsure how the calls are located?

Share this post


Link to post
Share on other sites
  • 0

Hey, sorry for my late reply. Was a bit busy...
To spawn the function, you have to predefine it.

I would put this in your Init:

Ich (hasinterface) then {
   GOM_fnc_scan = compilefinal preprocessfilelinenumbers "GOM_fnc_scan.sqf";
};

Create a file in your mission root called "GOM_fnc_scan.sqf"

and put your code into this file:

params [["_scanObject",objNull],["_scanRadius",250],["_duration",5],["_debug",false]];

_scanObject setVariable ["GOM_fnc_scanActive",true,true];
if (_debug) then {systemChat "Scanning for Players!"};
hint "Scanning for Players!";
sleep 1;
_stopTime = time + _duration;
waitUntil {

	_nearPlayers = (_scanObject nearEntities _scanRadius) - [player] select {isPlayer _x};
	hintsilent format ["Scanning: %1\nPlayers detected: %2",[-(time - _stopTime),"HH:MM"] call BIS_fnc_timeToString,count _nearPlayers];
	time > _stopTime
};
if (_debug) then {systemChat "Scanning Complete!"};
_scanObject setVariable ["GOM_fnc_scanActive",false,true];

hint "Scanning Complete!";

 

Share this post


Link to post
Share on other sites
  • 0

Actually I think the distance check is wrong i have it as 250 shouldnt that mean 250m???
eg. scanRadius, 250?

EDIT: nevermind I had it set to 15m in the dyna cfg>

 

class Playerscan
{
    condition = "player isEqualTo vehicle player && !(player getVariable ['GOM_fnc_scanActive',false])";
    action = "[player,250,5] spawn GOM_fnc_scan";
    icon = "x\addons\a3_epoch_code\Data\UI\buttons\geiger_alarmon.paa";
    tooltip = "Player Scan";
};

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...