Jump to content
  • 0

Player Proximity Scan Script


webbie

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.

 

Link to comment
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";
};

 

Link to comment
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

Link to comment
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?

Link to comment
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!";

 

Link to comment
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";
};

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...