Jump to content
Sign in to follow this  
davidoss

civilian casualties counter

Recommended Posts

Hi.

 

Have found on ARMA2 forum some code by Shuko  which can be useful for my Insurgency mission.

I don't knew for now if this is  arma 3 compatible but i wanna ask you fellows if there are any possibility to

get player kicked if he exceeds the CK limit (SHK_DeadCivilianLimit = 10;).

If not maybe someone knew different  way  how the mission  could punish the player for too many civilian casualties?

SHK_DeadCivilianCount = 0;
SHK_DeadCivilianLimit = 10;
SHK_fnc_deadCivilians = {
  hintsilent format ["Civilians dead: %1",_this];
  if (_this >= SHK_DeadCivilianLimit) then {
    player sidechat "mission end"; // end mission, do whatever
  };
};
if isserver then {
  {
    if (side _x == Civilian && _x iskindof "Man") then {
      _x addEventHandler ["killed", {
        SHK_DeadCivilianCount = SHK_DeadCivilianCount + 1;
        publicvariable "SHK_DeadCivilianCount";
        if !isdedicated then {
          SHK_DeadCivilianCount call SHK_fnc_deadCivilians;
        };
      }];
    };
  } foreach allunits;
};
if !isdedicated then {
  "SHK_DeadCivilianCount" addpublicvariableeventhandler { (_this select 1) call SHK_fnc_deadCivilians };
};

Share this post


Link to post
Share on other sites

you could set his position to somewhere off map and use disableUserInput true.

Also you could use the #kick server command. No idea if you can use it from within a script.

Back in A2 there was a function that would actually exit the game using the menu controls, no idea if this is still possible in A3.

 

Cheers

Share this post


Link to post
Share on other sites

i wanna ask you fellows if there are any possibility to get player kicked if he exceeds the CK limit (SHK_DeadCivilianLimit = 10;).

SHK_fnc_deadCivilians = {
	hintsilent format ["Civilians dead: %1",_this];
	if (_this >= SHK_DeadCivilianLimit) then {
		player sidechat "mission end";

		[] spawn {
			sleep 5;

			player endMission "LOSER";
		};
	};
};

Also you need to use database like [[<uid1>, <civKillsNum1>], ...] if your mission is for multiplayer, because you need to kick player who killed 10 civilians, not player who killed last civilian.

Share this post


Link to post
Share on other sites

 

Hi.

 

Have found on ARMA2 forum some code by Shuko  which can be useful for my Insurgency mission.

I don't knew for now if this is  arma 3 compatible but i wanna ask you guys if there are any possibility to

get player kicked if he exceeds the CK limit (SHK_DeadCivilianLimit = 10;).

If not maybe someone knew different  way  how we could punish the player for too many civilian casualties?

SHK_DeadCivilianCount = 0;
SHK_DeadCivilianLimit = 10;
SHK_fnc_deadCivilians = {
  hintsilent format ["Civilians dead: %1",_this];
  if (_this >= SHK_DeadCivilianLimit) then {
    player sidechat "mission end"; // end mission, do whatever
  };
};
if isserver then {
  {
    if (side _x == Civilian && _x iskindof "Man") then {
      _x addEventHandler ["killed", {
        SHK_DeadCivilianCount = SHK_DeadCivilianCount + 1;
        publicvariable "SHK_DeadCivilianCount";
        if !isdedicated then {
          SHK_DeadCivilianCount call SHK_fnc_deadCivilians;
        };
      }];
    };
  } foreach allunits;
};
if !isdedicated then {
  "SHK_DeadCivilianCount" addpublicvariableeventhandler { (_this select 1) call SHK_fnc_deadCivilians };
};
ac = [];
lac = [];
_la = [];
_la1 = [];
_lv = 0;
_lv1 = 0;

while {true} do {
	{ if ((side _x) == civilian) then {
	_la = [_x];
	_lv = ac find _x;
	if (_lv == -1) then {
		_x addMPeventhandler ["MPkilled", {
			//(if you want counting only players) can add: if (_this select 1 == player) then {
			_la2 = [(_this select 1)];
			_lv1 = lac find (_this select 1);
			if (_lv1 == -1) then {
				_pn = 0;
				_this select 1 setVariable ["_p",_pn];
				lac = lac + _la2;
			} else {
				_la2 = [_this];
				_pn = (_this select 1) getVariable "_p";
				_pn = _pn + 1;
				_this select 1 setVariable ["_p",_pn];
				if (_pn > 2) then { //How muh cicilians killed by the unit, can add any number of levels: after 2 kills, after 3 kills... by repiting the section;
					hint format ["%1 is under invastigation",_this select 1]; //replase this on what you want to do with unit;
					//_pn = 0;				|
					//_this select 1 setVariable ["_p",_pn];|if you want to restart counting kills;
					//lac = lac - _la2; if after punishment unit will not exist use to remove him from counting (for clearing);
				};
			};
			_la1 = [_this select 0];
			ac = ac - _la1;
			//};
		}];
		ac = ac + _la;
	};
} forEach allUnits;
sleep 10;
};
That will work for all civilians even if they added after mission start

Share this post


Link to post
Share on other sites

Again, your code is nonsensical.

Those weirdly named variables make it a pain to look through aswell.

 

Cheers

I do not care about opinions, this is best functionality code is possible to create for the situation

you writing like dictionary page trying to explain variables, i using 3 leters to know what type of the variable, where is it and what mean

Share this post


Link to post
Share on other sites

I do not care about opinions, this is best functionality code is possible to create for the situation

You are greatly mistaken.

  • Like 1

Share this post


Link to post
Share on other sites

A good start would be to not use a while true loop, then replace slow, deprecated commands with their faster counterparts.

If then else will always be slower than multiple if then checks as an example.

Then there's the new param and params commands (which are a godsend in many ways).

 

Cheers

Share this post


Link to post
Share on other sites

Ilias38rus, the most rational solution is to add Killed event handlers to civilians after its creation once as I and others suggested you on arma3.ru.

Share this post


Link to post
Share on other sites

Ilias38rus, the most rational solution is to add Killed event handlers to civilians after its creation once as I and others suggested you on arma3.ru.

How to detect they creation?

Share this post


Link to post
Share on other sites

How to detect they creation?

_unit = _group createUnit [...];

_unit addEventHandler ["Killed", {...}];

Share this post


Link to post
Share on other sites
_unit = _group createUnit [...];

_unit addEventHandler ["Killed", {...}];

Units in the mission can be created by zeus, by mcc, by skripts and not even shure what thats all

Share this post


Link to post
Share on other sites

you could set his position to somewhere off map and use disableUserInput true.

Also you could use the #kick server command. No idea if you can use it from within a script.

Back in A2 there was a function that would actually exit the game using the menu controls, no idea if this is still possible in A3.

 

Cheers

 

Nice ideas i will look into this.

 

SHK_fnc_deadCivilians = {
	hintsilent format ["Civilians dead: %1",_this];
	if (_this >= SHK_DeadCivilianLimit) then {
		player sidechat "mission end";

		[] spawn {
			sleep 5;

			player endMission "LOSER";
		};
	};
};

Also you need to use database like [[<uid1>, <civKillsNum1>], ...] if your mission is for multiplayer, because you need to kick player who killed 10 civilians, not player who killed last civilian.

 

This is little too complicated i think.

Share this post


Link to post
Share on other sites

A good start would be to not use a while true loop, then replace slow, deprecated commands with their faster counterparts.

If then else will always be slower than multiple if then checks as an example.

Then there's the new param and params commands (which are a godsend in many ways).

 

Cheers

 

whats wrong with a while true loop?

  • Like 1

Share this post


Link to post
Share on other sites

This is little too complicated i think.

How are you going to determine who killed 10 civilians? Without DB you can't determine this. E.g. player1 killed 9 civilians, player2 killed 1 civilian. In your current implementation player2 will be kicked, because SHK_DeadCivilianLimit will be 10 after killing civilian by player2.

 

Units in the mission can be created by zeus, by mcc, by skripts and not even shure what thats all

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#CuratorObjectPlaced

 

whats wrong with a while true loop?

https://community.bistudio.com/wiki/Code_Optimisation#Loops

Share this post


Link to post
Share on other sites

How are you going to determine who killed 10 civilians? Without DB you can't determine this. E.g. player1 killed 9 civilians, player2 killed 1 civilian. In your current implementation player2 will be kicked, because SHK_DeadCivilianLimit will be 10 after killing civilian by player2.

Ah understand. Thanks for explanation.

 

Jst use mine and no problems)

 

Can you please at least say how to execute this ?

Share this post


Link to post
Share on other sites

Ah understand. Thanks for explanation.

 

 

Can you please at least say how to execute this ?

 

just put in any file and Write in init.sqf execVM "_filename.sqf_"

Share this post


Link to post
Share on other sites

Ok maybe something easier.

 

I can add eventhandler to each civilian unit on the mission by Extended_Init_EventHandlers .

 

And i need just a  chat message on system chat who killed a civilian person.

 

How do i get that?

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  

×