Jump to content
Sign in to follow this  
1para{god-father}

Civilian kill Counter

Recommended Posts

Of course you haven't see it before, I wrote it just before posting it here. ;)

Share this post


Link to post
Share on other sites

Shuko, I just wanted to say thanks for the work you have done here. I love the CivDeath counter for a Dedi server, and being ALICE friendly!

Share this post


Link to post
Share on other sites

OK, I love how this script works; it's great. But suddenly, when I crank my "civ death limit" up a bit, it stops displaying the hint about the number of civs killed. When running on a dedi server, it works fine up till 6, but for a 7th civ killed, there's no message. When I ran it on a hosted server, it only went to 5 before stopping the hints. I have no clue why this would be! Here's my code:

SHK_DeadCivilianCount = 0;
SHK_DeadCivilianLimit = 20;
SHK_EndMission = false;
[] spawn {
 waituntil {SHK_EndMission};
 cuttext ["Mission Failure!.\n Your team killed too many civilians.","PLAIN",2];
 sleep 12;
 endmission "END2";
};

SHK_fnc_deadCivilians = {
 hintsilent format ["Civilians killed: %1",_this];
 if (_this >= SHK_DeadCivilianLimit) then {
   SHK_EndMission = true;
   publicvariable "SHK_EndMission";
 };
};

// Following is a version that considers whether the Civs were killed by a certain faction://////////////////
SHK_eh_killed = {
 private "_side";
 _side = side (_this select 1);
 if (_side == RESISTANCE) then {
   SHK_DeadCivilianCount = SHK_DeadCivilianCount + 1;
   publicvariable "SHK_DeadCivilianCount";
   if isdedicated then {
     if (_this >= SHK_DeadCivilianLimit) then {
       SHK_EndMission = true;
       publicvariable "SHK_EndMission";
     };
   } else {
     SHK_DeadCivilianCount call SHK_fnc_deadCivilians;
   };
 };
};
// END of Resistance Faction killer Check- //////////////////////////////////////////////////////////////////

if isserver then {
 {
   if (side _x == Civilian && _x iskindof "Man") then {
     _x addEventHandler ["killed", SHK_eh_killed];
   };
 } foreach allunits;
} else {
 "SHK_DeadCivilianCount" addpublicvariableeventhandler { (_this select 1) call SHK_fnc_deadCivilians };
};
[] spawn {
 waituntil {!isnil "BIS_alice_mainscope"};
 waituntil {!isnil "bis_fnc_variablespaceadd"};
 [bIS_alice_mainscope,"ALICE_civilianinit",[{_this addEventHandler ["killed", SHK_eh_killed]}]] call bis_fnc_variablespaceadd;
};

I've probably just screwed something up and I'm not seeing it. Has anyone had any similar experiences with the Hints cutting out?

Any help will be appreciated!

Edited by Lucky44

Share this post


Link to post
Share on other sites

There seem to be two main reasons why a question on these forums doesn't get a reply: 1. no one knows (and this is rare), and 2. the question is so dumb that no one is going to take the time to even tell you.

Is my question above Type 1 or Type 2? :)

Share this post


Link to post
Share on other sites

LOL - cannot see any changes that should not work.

I use this one all the time never had an issue so try this one and see - it is set to WEST not RESISTANCE as you one is


////////////////////////CIVI LIMIT////////////////////////////////////
SHK_DeadCivilianCount = 0;
SHK_DeadCivilianLimit =   25;    /// paramsarray select 2;
SHK_EndMission = false;
[] spawn {
 waituntil {SHK_EndMission};
 cuttext ["Game over. Unfortunately, you killed too many civilians.","PLAIN",2];
 sleep 10;
 endmission "END2";
};

SHK_fnc_deadCivilians = {
 hintsilent format ["Civilians dead: %1",_this];
 if (_this >= SHK_DeadCivilianLimit) then {
   SHK_EndMission = true;
   publicvariable "SHK_EndMission";
 };
};

SHK_eh_killed = {
 private "_side";
 _side = side (_this select 1);
 if (_side == WEST) then {
   SHK_DeadCivilianCount = SHK_DeadCivilianCount + 1;
   publicvariable "SHK_DeadCivilianCount";
   if isdedicated then {
     if (_this >= SHK_DeadCivilianLimit) then {
       SHK_EndMission = true;
       publicvariable "SHK_EndMission";
     };
   } else {
     SHK_DeadCivilianCount call SHK_fnc_deadCivilians;
   };
 };
};
if isserver then {
 {
   if (side _x == Civilian && _x iskindof "Man") then {
     _x addEventHandler ["killed", SHK_eh_killed];
   };
 } foreach allunits;
} else {
 "SHK_DeadCivilianCount" addpublicvariableeventhandler { (_this select 1) call SHK_fnc_deadCivilians };
};
[] spawn {
 waituntil {!isnil "BIS_alice_mainscope"};
 waituntil {!isnil "bis_fnc_variablespaceadd"};
 [bIS_alice_mainscope,"ALICE_civilianinit",[{_this addEventHandler ["killed", SHK_eh_killed]}]] call bis_fnc_variablespaceadd;
};

Share this post


Link to post
Share on other sites

This script works perfectly well, but, using ambient civilians, I'm having civilians walk off of buildings (at least I assume) because the kill count goes up on its own.

Share this post


Link to post
Share on other sites

Sorry for bumping this post. I am trying to figure out why below post triggers an error:

civKia = 0;

if (isServer) then {
fnc_civkia_EH = {
	private ["_side","_kiaPos"];
	_kiaPos = getPos (_this select 0);
	_side = side (_this select 1);
	if (_side == WEST) then {
		civKia = civKia + 1;
		publicvariable "civKia";
		_m = createMarker [format ["m_civKia_%1", civKia], _kiaPos];
		_m setMarkerShape "ICON"; _m setMarkerType "mil_dot"; _m setMarkerColor "ColorGreen"; _m setMarkerText format ["%1",civKia];
		publicVariable "_m";			
	}
};{
   if ((side _x == Civilian) && (_x iskindof "Man")) then {
     _x addEventhandler ["killed",fnc_civkia_EH];
   };
} foreach allUnits;
} else {
fnc_civKiaMsg = {hintSilent parseText format ["
	<t color='#C1C3CB' align='left'>Brigade: a civilian has been killed in action!<br/><br/>The total civilian death toll is: </t>
	<t color='#FFFFFF' align='left' size='1.2'>%1 </t><br/><br/>
	<t color='#C1C3CB' align='left' size='1'>Civilians KIA are marked on the map with a </t>
	<t color='#65B418' align='left' shadow='1.2'>green dot</t>
	", civKia];
};
 "civKia" addPublicVariableEventHandler {call fnc_civKiaMsg};
};

The script runs fine, displaying the "Civilian killed" message. It also creates the markers on the map:

zje636.jpg

The error message is:

oi8z9z.jpg

The only script that is running is above script (in the init.sqf).

Thanks in advance for your help!

Share this post


Link to post
Share on other sites

My uneducated guess is this:

publicVariable "_m";

You are trying to PV a local variable?

Share this post


Link to post
Share on other sites

Nah, unfortunately that's not it. Tried it way before. The weird thing is, that the error message is actually ARMA3 code. I was testing with 1 playert, 2 civs and my script in the init. Nothing else. Oh Arma....

Share this post


Link to post
Share on other sites

Revive from the beyond, font of ancient scripting! REVIVE! :D

I found this thread by searching, before posting a new one myself. I'm curious if anyone has gotten this to work with a marker and/or trigger?

I'm working on an "insurgent" type of mission (no, not "insurgency") for A3, targeted at coop on a dedicated server. Each of my towns and villages have a named marker. I also use these markers as a spawning zone for my civilians using BangaBob's EOS script, so they cache when players aren't around. Thus it makes sense that when a player is close enough to activate the zone the civilians spawn in on that specific zone (village).

What I would like to do is find a way to keep a separate "BLU kills CIV" count for *each* marker/village and later use the count as a way to reflect the inhabitants' attitude towards blufor (positive they might produce intel, etc., negative they might produce assassins, suicide bombers and more insurgents!)

Alternatively a counter of civ deaths for each player might also be useful?

If anyone has the time to help me with this I would be MUCH appreciative, although I am really posting with the hopes that someone else has already accomplished this that wouldn't mind sharing a little copy/paste. :)

Thanks in advance!

Edited by Oktyabr

Share this post


Link to post
Share on other sites

Shuko's script seems to not work with spawned in units. Works like a charm when I kill a manually placed unit, but not when they have been spawned in by a script.

 

This is how I spawned them in:

Quote

_mrk = _this select 0;
_grp = createGroup west;
gendarme1 = _grp createUnit ["B_GEN_Commander_F", getMarkerPos _mrk, [], 0, "sergeant"];
[gendarme1] join _grp;
sleep 0.1;
gendarme2 = _grp createUnit ["B_GEN_Soldier_F", getMarkerPos _mrk, [], 0, "corporal"];
[gendarme2] join _grp;

 

Obviously I changed his script to count the deaths of west units.

Share this post


Link to post
Share on other sites

Use setVehicleInit on the units, and then processInitCommands.  They're global commands, so you may have to condition the code statement to run only on the correct machine.

Share this post


Link to post
Share on other sites

I am not sure I understand how you want me to use setVehicleInit and processInitCommands. The wiki says: 

For security reasons, the command was disabled in Arma 3.

 

I guess I have to watch some tutorials on how to use setVehicleInit.

Share this post


Link to post
Share on other sites

Ah, my bad.  It was an original A2 post and I thought you meant for A2.  Yeah, I'd agree that wouldn't work for A3.

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  

×