Jump to content

[Release] Small script to count players


FragZ

Recommended Posts

Hey guys another small release from me. I got a lot of help from Zupa so most credits goes to him!

This basically make you able to right click an item (using maca right click system) to check how many players are in a X meter radius. You can also use it as an action menu option or anything making it executed like a trigger for PVP zone.

Source:

 

I believe this will also count AI. I made a post in the previous thread as to how to fix this.

 

One way of doing it is to replace

 

_playercount = count (player nearEntities ["CAManBase", _allowedDistance ]);

 

with 

 

_playercount = {isPlayer _x} count (player nearEntities ["CAManBase", _allowedDistance ]);


Just make a cp.sqf file and paste this in:

/*
Player count in area script by FragZ & Zupa
You can make this script execute over action menu or with right-click option in the extra_rc.hpp
You can also execute it over a trigger to make a pvp zone that counts participants!
*/

// Config
_allowedDistance = 1300; 
_allowedAfterTime = 300000; // 1000 = 1 sec, 5*60*1000 = 300000
// Config End

if(isNil "LastUsedCheck")then{
LastUsedCheck = 0;
};

if( LastUsedCheck == 0 || (diag_tickTime-LastUsedCheck)>_allowedAfterTime)then{

_playercount = count (player nearEntities ["CAManBase", _allowedDistance ]); // only gets people, not all vehicles, besides, i think people are not in the ALLVechicle variable xp
 
uisleep 3;

if (_playercount == 0) then {
cutText ["You are currently the only human in your area.", "PLAIN DOWN"];
};
if (_playercount = 1) then {
cutText ["There is one other human in your area.", "PLAIN DOWN"];
};
if (_playercount > 1) then {
cutText [format["There are %1 in your area!",_playercount], "PLAIN DOWN"];
};
LastUsedCheck = diag_tickTime;
}else{
cutText [format["You can not use this now. Available in %1 sec.",(_allowedAfterTime  - (diag_tickTime-LastUsedCheck))/1000], "PLAIN DOWN"];
}; 

You can then make this file exec on a right click option or whatever you want to use it for.

Enjoy!

Link to comment
Share on other sites

I believe this will also count AI. I made a post in the previous thread as to how to fix this.

 

One way of doing it is to replace

 

_playercount = count (player nearEntities ["CAManBase", _allowedDistance ]);

 

with 

 

_playercount = {isPlayer _x} count (player nearEntities ["CAManBase", _allowedDistance ]);

I wanted it to count AIs.

 

I added your quote to the OP so people can change whether they want it or not... but idk if it will indeed count AIs I do not have a server atm.

Link to comment
Share on other sites

I wanted it to count AIs.

 

I added your quote to the OP so people can change whether they want it or not... but idk if it will indeed count AIs I do not have a server atm.

I allready use this one:

DZE_CLICK_ACTIONS = [
    [
	"ItemGPS","sCan!",
	"if(isNil 'DZE_CLICK_ACTIONS_GPS_RANGE') then 
	{DZE_CLICK_ACTIONS_GPS_RANGE = 500;};
	DZE_CLICK_ACTIONS_ZOMBIE_COUNT = count 
	((position player) nearEntities 
	['zZombie_Base',DZE_CLICK_ACTIONS_GPS_RANGE]);
	DZE_CLICK_ACTIONS_MAN_COUNT = count
	((position player) nearEntities
	['CAManBase',DZE_CLICK_ACTIONS_GPS_RANGE]);
	cutText[format['Within %1 Meters: %2 AI/players, %3 zombies, %4 vehicles',
	DZE_CLICK_ACTIONS_GPS_RANGE,DZE_CLICK_ACTIONS_MAN_COUNT - DZE_CLICK_ACTIONS_ZOMBIE_COUNT,count 
	((position player) nearEntities ['zZombie_Base',DZE_CLICK_ACTIONS_GPS_RANGE]),count
	((position player) nearEntities ['allVehicles',DZE_CLICK_ACTIONS_GPS_RANGE]) - DZE_CLICK_ACTIONS_MAN_COUNT],'PLAIN DOWN'];","true"]
 
];

How can i add timer here?

And can i change this line:

cutText[format['Within %1 Meters: %2 AI/players, %3 zombies, %4 vehicles',

to:

 exitWith { systemChat 

or somehow make info write to chat not on the top of screen

 

Here is only scan for all, maybe can change to scan for players, scan for AI or scan vehicles?

Scripting not my strong size so any help be good! )

b_560_95_1.png

Link to comment
Share on other sites

Tried adding this to my extra_rc.hpp file for the gps, but it won't activate? i've tried two methods.

Notice that the script line is the only changing one. I get the option ingame, but when i press "scan area" nothing happens. What am i doing wrong? :(

 

Method1:

	class ItemGPS {
		class Playercount {
			text = "Scan Area";
			script = "[] execVM ""scripts\cp.sqf"";";
		};
	};

Method2:

	class ItemGPS {
		class Playercount {
			text = "Scan Area";
			script = "execVM 'scripts\cp.sqf'";
		};
	};
Link to comment
Share on other sites

  • 1 month later...

 

Tried adding this to my extra_rc.hpp file for the gps, but it won't activate? i've tried two methods.

Notice that the script line is the only changing one. I get the option ingame, but when i press "scan area" nothing happens. What am i doing wrong? :(

 

Method1:

	class ItemGPS {
		class Playercount {
			text = "Scan Area";
			script = "[] execVM ""scripts\cp.sqf"";";
		};
	};

Method2:

	class ItemGPS {
		class Playercount {
			text = "Scan Area";
			script = "execVM 'scripts\cp.sqf'";
		};
	};

 

I do not know what is wrong really. I use this layout for my actions so far:

 

class ExtraRc {
	class ItemKnife {
		class farmhemp {
			text = "Harvest the weed";
            script = "execVM 'scripts\hemp.sqf'";
		};
  };
	class ItemRadio {
		class GroupManagement {
			text = "Group Management";
			script = "execVM 'dzgm\loadGroupManagement.sqf'";
		};
  };
  class ItemKiloHemp {
		class smokeweed {
			text = "Smoke the shit";
			script = "execVM 'scripts\smokeweed.sqf'";
		};
	};
};
Link to comment
Share on other sites

  • 1 year later...

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