Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
Superkaj

Multiplayer Kill Count

Recommended Posts

Hey Everyone!

I am quite new here, but i have already been highly impressed by the community here, very helpful!

So, i have already been scripting in my missions in Arma 2 OA. But i stumpled upon a problem...

I have been trying to find/make a script that would count the kills of a certain unit or side (The side only has one unit) so that the whole server would notice how many kills the unit has.

I have been trying with this code and it seemed to work well, that is until i tried in multiplayer with my friends and it only seemed to count my deaths and not the others at all.

Here is the code:

// Global variable to hold the death counter.
DeadOPFOR = 0;

// Function to display the death count.
fnc_showOpDeathCount = {
 hintsilent format ["Sniper Kills: %1",DeadOPFOR];
};

// Server will do all the work.
if isServer then {
 // Function to update death counter.
 fnc_countOpDeaths = {
   DeadOPFOR = DeadOPFOR + 1;

   // Send the new value to clients.
   publicvariable "DeadOPFOR";

   // This machine is the server, but if it's not dedicated, then it's a
   // listen server, which means it's also a client, who needs to see the
   // hint as well.
   if !isDedicated then {
     call fnc_showOpDeathCount;
   };
 };

 // Add killed -eventhandler to all opfor.
 {
   if (side _x == EAST) then {
     _x addEventhandler ["killed",fnc_countOpDeaths];
   };
 } foreach allUnits;

// Non-host clients.
} else {
 // PublicVariable eventhandler to catch the update sent by the server.
 "DeadOPFOR" addPublicVariableEventHandler {call fnc_showOpDeathCount};
};

The code i want to do is to count all the deaths by the Opfor, it works for me (The Host) but the others aint getting counted on death.

Any Ideas?

Share this post


Link to post
Share on other sites
Sign in to follow this  

×