Jump to content
Sign in to follow this  
Azza FHI

PVP alive unit counter/ indicator

Recommended Posts

Hello, I am making a deathmatch for our clan. was just wondering if anyone knows how to make a very simple indicator of how many alive units are in a triggers area?

doesnt have to be pretty like KOH, just a hint style number (starting at however many players there are) that counts down after each death...

cheers

Share this post


Link to post
Share on other sites
[] spawn
{
_objects = allMissionObjects "Man";
while {true} do
{
	hintSilent str ({alive _x} count _objects);
};
};

Share this post


Link to post
Share on other sites

I would add a sleep delay in the while loop to save resources.

Share this post


Link to post
Share on other sites

Thank you very much!

tweaked for what I need

[] spawn
{
   _objects = playableunits;

   while {true} do
   {

       hintSilent str ({(alive _x) AND (_x in list trig_counter)}  count _objects);

sleep 5;
   };

}; 

what about making 2 separate counters for a team DM? east and west players

Edited by Azer1234

Share this post


Link to post
Share on other sites
[] spawn
{
   _objects = playableunits;
   while {true} do
{
	hintSilent format ["West: %1\nEast: %2",{(alive _x) && {_x in list trig_counter} && {side _x == west}}  count _objects,{(alive _x) && {_x in list trig_counter} && {side _x == east}}  count _objects];
};
};

Edited by DreadedEntity

Share this post


Link to post
Share on other sites

hmm doesn't seem to work, no errors but nothing shows up. I tried with allmissionobjects "man" aswell just in case it needed units on both sides to work, but still nothing...

Share this post


Link to post
Share on other sites

The brackets look a little messed up try

hintSilent format ["West: %1\nEast: %2",{(alive _x) && (_x in list trig_counter) && (side _x == west)}  count _objects,{(alive _x) && (_x in list trig_counter) && (side _x == east)}  count _objects];

Share this post


Link to post
Share on other sites
hmm doesn't seem to work, no errors but nothing shows up. I tried with allmissionobjects "man" aswell just in case it needed units on both sides to work, but still nothing...

F2k noticed that my brackets were messed up. I forgot to close the count loop. I edited that post and it should work now

Share this post


Link to post
Share on other sites

If you want to use eventhandler(s) instead of a loop then merge the following into your mission. Cheers.

description.ext

class RscTitles 
{
#include "display.hpp"  
};

display.hpp

class RscText
{
access = 0;
type = 0;
style = 0x02;
idc = -1;
colorBackground[] = {0,0,0,0.8};
colorText[] = {1,1,1,0.8};
text = "";
fixedWidth = 0;
x = 0;
y = 0;
   h = 0;
w = 0;
shadow = 2;
font = "puristaMedium";
SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
moving = 1;	  
};

#define IDD_DM_DISPLAY  					60300
#define IDC_DM_TEXT_EAST_SOLDIER_COUNT 		70300
#define IDC_DM_TEXT_WEST_SOLDIER_COUNT		70301
#define COLORRED 							{ 0.78, 0.27, 0.27, 1 }
#define COLORBLUE 							{ 0.31, 0.395, 0.72, 1 }

class DM_HUD
{
idd = IDD_DM_DISPLAY; 
duration = 1e+1000; 
fadeIn = 0; 
fadeOut = 0; 
onLoad = "uiNamespace setVariable ['DM_Display', _this select 0];";  

controls[]=
{
	DM_TEXT_WEST_HEADER,
	DM_TEXT_EAST_HEADER,
	DM_TEXT_EAST_SOLDIER_COUNT,
	DM_TEXT_WEST_SOLDIER_COUNT
};

class DM_TEXT_WEST_HEADER: RscText
{
	text = "Blufor";
	colorBackground[] = COLORBLUE;
	x = 0.927087 * safezoneW + safezoneX;
	y = 0.220681 * safezoneH + safezoneY;
	w = 0.0741219 * safezoneW;
	h = 0.028 * safezoneH;
};
class DM_TEXT_EAST_HEADER: RscText
{
	text = "Opfor";
	colorBackground[] = COLORRED;
	x = 0.927351 * safezoneW + safezoneX;
	y = 0.346 * safezoneH + safezoneY;
	w = 0.0741219 * safezoneW;
	h = 0.028 * safezoneH;
};
class DM_TEXT_WEST_SOLDIER_COUNT: RscText
{
	idc = IDC_DM_TEXT_WEST_SOLDIER_COUNT;
	colorText[] = COLORBLUE;
	x = 0.926954 * safezoneW + safezoneX;
	y = 0.248 * safezoneH + safezoneY;
	w = 0.072927 * safezoneW;
	h = 0.098 * safezoneH;
};
class DM_TEXT_EAST_SOLDIER_COUNT: RscText
{
	idc = IDC_DM_TEXT_EAST_SOLDIER_COUNT;
	colorText[] = COLORRED;
	x = 0.927351 * safezoneW + safezoneX;
	y = 0.374 * safezoneH + safezoneY;
	w = 0.072927 * safezoneW;
	h = 0.098 * safezoneH;
};
};

init.sqf

/*

-- FOR AI PRESENT ON THE MAP @ MISSION START
-- IF THE AI ARE CREATED DURING THE MISSION, YOU'LL NEED TO READD THE KILLE EH TO THE SAID UNIT(S)
-- DELETE IF IT'S PURE PVP 

*/

if ( isServer ) then {
{
	if ( !( isPlayer _x ) ) then {
		_x addEventHandler ["killed", { 
				_nul = [ "DMCount.sqf" , "BIS_fnc_execVM", true ] call BIS_fnc_MP;
		}];
	};
} forEach allUnits;
};

/* PLAYERS */
if ( !( isDedicated ) ) then {
waitUntil { !( isNull player ) && ( player == player ) }; 

IDD_DM_DISPLAY  					=	60300;
IDC_DM_TEXT_EAST_SOLDIER_COUNT 		=	70300;
IDC_DM_TEXT_WEST_SOLDIER_COUNT		=	70301;
( "DM_HUD_LAYER" call BIS_fnc_rscLayer ) cutRsc [ "DM_HUD","PLAIN" ];
_nul = execVM "DMCount.sqf";	

player addEventHandler ["killed", { 
	_nul = [ "DMCount.sqf", "BIS_fnc_execVM", true ] call BIS_fnc_MP;
}];
};

DMCount.sqf

#define 	DMDisplay 		(uiNamespace getVariable "DM_DISPLAY") 
#define 	DMctrl(ctrl) 		((uiNamespace getVariable "DM_DISPLAY") displayCtrl ctrl)
#define 	EASTCOUNT 		{ alive _x && { ( side _x ) == east } } count playableUnits
#define 	WESTCOUNT 		{ alive _x && { ( side _x ) == west } } count playableUnits

waitUntil { !( isNull DMDisplay ) };	
DMctrl(IDC_DM_TEXT_WEST_SOLDIER_COUNT) ctrlSettext format ["%1", WESTCOUNT ];
DMctrl(IDC_DM_TEXT_EAST_SOLDIER_COUNT) ctrlSetText format [ "%1", EASTCOUNT ];

if ( true ) exitWith {};

Edited by Iceman77

Share this post


Link to post
Share on other sites

Trying this with this mission I built.

Setup what you have there Iceman77 and i got this error apon hitting preview in the editor and got a cdt:

ErrorMessage: File C:\Users\Gunter Severloh\Documents\Arma 3\missions\OPS-Kill_Ratio.Stratis\display.hpp, line 0: '/RscTitles.': '-' encountered instead of '='

the display.hpp is a notepad document right? as there is no option for hpp creation in armaedit.

my display.hpp via notepad

------------------------------------------------------------------
ReadMe text file
Created by: TODO: Author Name
------------------------------------------------------------------

class RscText
{
   access = 0;
   type = 0;
   style = 0x02;
   idc = -1;
   colorBackground[] = {0,0,0,0.8};
   colorText[] = {1,1,1,0.8};
   text = "";
   fixedWidth = 0;
   x = 0;
   y = 0;
   h = 0;
   w = 0;
   shadow = 2;
   font = "puristaMedium";
   SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
   moving = 1;      
};

#define IDD_DM_DISPLAY                      60300
#define IDC_DM_TEXT_EAST_SOLDIER_COUNT         70300
#define IDC_DM_TEXT_WEST_SOLDIER_COUNT        70301
#define COLORRED                             { 0.78, 0.27, 0.27, 1 }
#define COLORBLUE                             { 0.31, 0.395, 0.72, 1 }

class DM_HUD
{
   idd = IDD_DM_DISPLAY; 
   duration = 1e+1000; 
   fadeIn = 0; 
   fadeOut = 0; 
   onLoad = "uiNamespace setVariable ['DM_Display', _this select 0];";  

   controls[]=
   {
       DM_TEXT_WEST_HEADER,
       DM_TEXT_EAST_HEADER,
       DM_TEXT_EAST_SOLDIER_COUNT,
       DM_TEXT_WEST_SOLDIER_COUNT
   };

   class DM_TEXT_WEST_HEADER: RscText
   {
       text = "Blufor";
       colorBackground[] = COLORBLUE;
       x = 0.927087 * safezoneW + safezoneX;
       y = 0.220681 * safezoneH + safezoneY;
       w = 0.0741219 * safezoneW;
       h = 0.028 * safezoneH;
   };
   class DM_TEXT_EAST_HEADER: RscText
   {
       text = "Opfor";
       colorBackground[] = COLORRED;
       x = 0.927351 * safezoneW + safezoneX;
       y = 0.346 * safezoneH + safezoneY;
       w = 0.0741219 * safezoneW;
       h = 0.028 * safezoneH;
   };
   class DM_TEXT_WEST_SOLDIER_COUNT: RscText
   {
       idc = IDC_DM_TEXT_WEST_SOLDIER_COUNT;
       colorText[] = COLORBLUE;
       x = 0.926954 * safezoneW + safezoneX;
       y = 0.248 * safezoneH + safezoneY;
       w = 0.072927 * safezoneW;
       h = 0.098 * safezoneH;
   };
   class DM_TEXT_EAST_SOLDIER_COUNT: RscText
   {
       idc = IDC_DM_TEXT_EAST_SOLDIER_COUNT;
       colorText[] = COLORRED;
       x = 0.927351 * safezoneW + safezoneX;
       y = 0.374 * safezoneH + safezoneY;
       w = 0.072927 * safezoneW;
       h = 0.098 * safezoneH;
   };
};  

Share this post


Link to post
Share on other sites

the display.hpp is a notepad document right? as there is no option for hpp creation in armaedit.

The .hpp is just a file extension (similar to the header files in C++), so yes you can edit and such in notepad as long as you save the file as: fileName.hpp

Share this post


Link to post
Share on other sites
Trying this with this mission I built.

Setup what you have there Iceman77 and i got this error apon hitting preview in the editor and got a cdt:

You're getting CTD because of the comment you added at the top ( line 0 ) isn't properly commented.

/* ------------------------------------------------------------------

ReadMe text file

Created by: TODO: Author Name

------------------------------------------------------------------ */

Edited by Iceman77

Share this post


Link to post
Share on other sites

Ah ok, I created the hpp with armaedit and saved it as a txt doc, armedit adds that automatically, think i will just remove that comment part as its not needed, thanks.

Share this post


Link to post
Share on other sites
Ah ok, I created the hpp with armaedit and saved it as a txt doc, armedit adds that automatically, think i will just remove that comment part as its not needed, thanks.

In ArmaEdit, you can edit the headers by clicking on Tools -> Edit Auto Header Data. That's what I use :)

If you want an updated list of commands, I can PM mine to you. (weapon/ammo classnames haven't been updated, just commands)

Share this post


Link to post
Share on other sites

Still cant get this to work, im getting this error at start of the mission

Warning Message: Resource title DM_HUD not found

heres my description:

class Header
{
 gameType = Coop;
 minPlayers = 1;
 maxPlayers = 2;
};

onLoadName = "Ops-Kill Ratio2"; 
author = "Gunter Severloh"; 
respawn = "INSTANT";
respawndelay = 5;
disabledAI = true;

//// Respawn Script - Start ////
#include "INS_revive\description.hpp"
//// Respawn Script - End   ////

class Params
{
 //// Respawn Script - Start ////
 #include "INS_revive\params.hpp"
 //// Respawn Script - End   ////
};

class RscTitles
{
 //// Respawn Script - Start ////
 #include "INS_revive\rsctitles.hpp"
 //// Respawn Script - End   ////
 #include "display.hpp"  
};  

class cfgFunctions {
 //// Respawn Script - Start ////
 #include "INS_revive\cfgfunctions.hpp"
 //// Respawn Script - End   ////
};

init.sqf

if (!isServer && isNull player) then {isJIP=true;} else {isJIP=false;};

// Wait until player is initialized
if (!isDedicated) then {waitUntil {!isNull player && isPlayer player};};

// INS_revive initialize
[] execVM "INS_revive\revive_init.sqf";
////////////////////////////////////////////////////////////////////////
[] execVM "cleanup.sqf";

[] spawn 
{
while {true} do
	{
	sleep 10;

		{
		_x setSkill ["aimingspeed", 0.1];
		_x setSkill ["spotdistance", 0.2];
		_x setSkill ["aimingaccuracy", 0.2];
		_x setSkill ["aimingshake", 0.1];
		_x setSkill ["spottime", 0.1];
		_x setSkill ["spotdistance", 0.5];
		_x setSkill ["commanding", 0.2];
		_x setSkill ["general", 0.5];
		} 
	forEach allUnits;
	}
};
/*

-- FOR AI PRESENT ON THE MAP @ MISSION START
-- IF THE AI ARE CREATED DURING THE MISSION, YOU'LL NEED TO READD THE KILLE EH TO THE SAID UNIT(S)
-- DELETE IF IT'S PURE PVP 

*/

if ( isServer ) then {
   {
       if ( !( isPlayer _x ) ) then {
           _x addEventHandler ["killed", { 
                   _nul = [ "DMCount.sqf" , "BIS_fnc_execVM", true ] call BIS_fnc_MP;
           }];
       };
   } forEach allUnits;
};

/* PLAYERS */
if ( !( isDedicated ) ) then {
   waitUntil { !( isNull player ) && ( player == player ) }; 

   IDD_DM_DISPLAY                      =    60300;
   IDC_DM_TEXT_EAST_SOLDIER_COUNT         =    70300;
   IDC_DM_TEXT_WEST_SOLDIER_COUNT        =    70301;
   ( "DM_HUD_LAYER" call BIS_fnc_rscLayer ) cutRsc [ "DM_HUD","PLAIN" ];
   _nul = execVM "DMCount.sqf";    

   player addEventHandler ["killed", { 
       _nul = [ "DMCount.sqf", "BIS_fnc_execVM", true ] call BIS_fnc_MP;
   }];
};  

Something has to be wrong in either one of those, maybe wrong location and repeat of something?

Share this post


Link to post
Share on other sites

Post the display.hpp. Also post the directory / path that it's in. Thanks.

Share this post


Link to post
Share on other sites

Ok heres the display.hpp

class RscText
{
   access = 0;
   type = 0;
   style = 0x02;
   idc = -1;
   colorBackground[] = {0,0,0,0.8};
   colorText[] = {1,1,1,0.8};
   text = "";
   fixedWidth = 0;
   x = 0;
   y = 0;
   h = 0;
   w = 0;
   shadow = 2;
   font = "puristaMedium";
   SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
   moving = 1;      
};

#define IDD_DM_DISPLAY                      60300
#define IDC_DM_TEXT_EAST_SOLDIER_COUNT         70300
#define IDC_DM_TEXT_WEST_SOLDIER_COUNT        70301
#define COLORRED                             { 0.78, 0.27, 0.27, 1 }
#define COLORBLUE                             { 0.31, 0.395, 0.72, 1 }

class DM_HUD
{
   idd = IDD_DM_DISPLAY; 
   duration = 1e+1000; 
   fadeIn = 0; 
   fadeOut = 0; 
   onLoad = "uiNamespace setVariable ['DM_Display', _this select 0];";  

   controls[]=
   {
       DM_TEXT_WEST_HEADER,
       DM_TEXT_EAST_HEADER,
       DM_TEXT_EAST_SOLDIER_COUNT,
       DM_TEXT_WEST_SOLDIER_COUNT
   };

   class DM_TEXT_WEST_HEADER: RscText
   {
       text = "Blufor";
       colorBackground[] = COLORBLUE;
       x = 0.927087 * safezoneW + safezoneX;
       y = 0.220681 * safezoneH + safezoneY;
       w = 0.0741219 * safezoneW;
       h = 0.028 * safezoneH;
   };
   class DM_TEXT_EAST_HEADER: RscText
   {
       text = "Opfor";
       colorBackground[] = COLORRED;
       x = 0.927351 * safezoneW + safezoneX;
       y = 0.346 * safezoneH + safezoneY;
       w = 0.0741219 * safezoneW;
       h = 0.028 * safezoneH;
   };
   class DM_TEXT_WEST_SOLDIER_COUNT: RscText
   {
       idc = IDC_DM_TEXT_WEST_SOLDIER_COUNT;
       colorText[] = COLORBLUE;
       x = 0.926954 * safezoneW + safezoneX;
       y = 0.248 * safezoneH + safezoneY;
       w = 0.072927 * safezoneW;
       h = 0.098 * safezoneH;
   };
   class DM_TEXT_EAST_SOLDIER_COUNT: RscText
   {
       idc = IDC_DM_TEXT_EAST_SOLDIER_COUNT;
       colorText[] = COLORRED;
       x = 0.927351 * safezoneW + safezoneX;
       y = 0.374 * safezoneH + safezoneY;
       w = 0.072927 * safezoneW;
       h = 0.098 * safezoneH;
   };
};  

Its basically in the mission folder the only other folder in the mission folder itself is the

INS_revive folder thats it, everything else is loose.

Share this post


Link to post
Share on other sites

Post a link to DL your mission (pref. DB or github).

Note: What I posted does work as I tested it.

Share this post


Link to post
Share on other sites

Sure, Drop box link:

https://www.dropbox.com/s/0zp80stxlrvlm0c/OPS-Kill_Ratio2%20Mission.zip?dl=0

its zipped but the mission isn't pbo'd.

only requirements the mission has is The Iraqi Warfare Mod http://www.armaholic.com/page.php?id=26758

and theres nothing special about the mission just a bunch of ISIS groups thrown on the map in the one town and 2 players in front of

an ammo box with arsenal be used, then it uses ins_revive for respawn so its best to test in mp to get a respawn, aside that you could prob

mimic the mission by throwing a player down and then some csat units and see if the scripts work that way for the counter.

But all the files are as is theres no other folders aside the Ins_revive.

Mission is sp/coop btw sp only has 1 life, so preferably coop and use it mp for the respawn, all that works np just not the counter.

Share this post


Link to post
Share on other sites

Ahh mods =/. Hmm. Idk why it wouldn't work from looking at your mission folder. Maybe someone else can pinpoint the issue :p

Share this post


Link to post
Share on other sites

The counter scripts arn't specific to vanilla units are they?

If they are then thats the problem.

Share this post


Link to post
Share on other sites

Okay I downloaded the mod and loaded your mission up in the MP editor. Previewed it and the counter HUD shows. No error regarding that. There was one error regarding some INS function being undefined. INS_REV_FNCT_respawnBlock

.rpt

Fresnel k must be >0, given n=1.4,k=0
Error in expression <CFG_loadout_on_respawn) then {
[] spawn INS_REV_FNCT_respawnBlock;
};


INS_REV_>
 Error position: <INS_REV_FNCT_respawnBlock;
};


INS_REV_>
 Error Undefined variable in expression: ins_rev_fnct_respawnblock
File C:\Users\David\Documents\Arma 3 - Other Profiles\Iceman77\mpmissions\OPS-Kill_Ratio2.Stratis\INS_revive\revive\init_vanilla.sqf, line 81
Fresnel k must be >0, given n=2.51,k=0

---------- Post added at 06:15 ---------- Previous post was at 06:10 ----------

I would also like to add that the HUD counts playable units. Switch playableUnits to allUnits to count all AI.

Share this post


Link to post
Share on other sites

Oh! that might explain it then as when i was testing the mission i was testing it in sp editor not mp.

so it does work then, i didn't test it mp as i had the 10 sec delay seen on this

thread which I have actually to test again as i removed the workshop content I had, anyways thats another story

as for the other error I have no idea thats not my work, thats from this http://www.armaholic.com/page.php?id=20196

Share this post


Link to post
Share on other sites

See my edit Gunter. Go into DMCount.sqf and at the top change playableUnits to allUnits. This will include non-playable AI. Cheers.

Share this post


Link to post
Share on other sites

Like this correct for East:

#define     DMDisplay         (uiNamespace getVariable "DM_DISPLAY") 
#define     DMctrl(ctrl)         ((uiNamespace getVariable "DM_DISPLAY") displayCtrl ctrl)
#define     EASTCOUNT         { alive _x && { ( side _x ) == east } } count [color="#FF0000"][b]allUnits[/b][/color]
#define     WESTCOUNT         { alive _x && { ( side _x ) == west } } count playableUnits

waitUntil { !( isNull DMDisplay ) };    
DMctrl(IDC_DM_TEXT_WEST_SOLDIER_COUNT) ctrlSettext format ["%1", WESTCOUNT ];
DMctrl(IDC_DM_TEXT_EAST_SOLDIER_COUNT) ctrlSetText format [ "%1", EASTCOUNT ];

if ( true ) exitWith {};

Mission is just a fun run and gun mission, i use it for testing and just messing around, part of a series of missions I like

to build I call OPS missions which i never released.

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
Sign in to follow this  

×