Home   Help Search Login Register  

Author Topic: Check how many kills  (Read 1130 times)

0 Members and 2 Guests are viewing this topic.

Offline Mad Pup

  • One Who Asks A Lot.
  • Members
  • *
  • OFPEC Is Awesome
Check how many kills
« on: 10 Apr 2012, 02:32:50 »
I would like to know, how to keep track of a soldiers kills. For instance, one a soldier has 5 kills, he is able to use more weapons, and once he has 10 kills, he is able to use even more weapons.
Thanks!

-Mad Pup
"The object of war is not to die for your country, but to make the other poor bastard die for his" - General Patton
[SH]MadPup
[SH]Squad

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: Check how many kills
« Reply #1 on: 10 Apr 2012, 09:18:06 »
Ah, an age old question. There have been several solutions but the best one is the usage of 'killed' eventhandlers.

After doing some searching I came across this bit o' code:

Code: [Select]
{_x addeventhandler ["killed",{[_this select 1,player] exec "killcount.sqs"}]} forEach thislist  ;
Put that in an east trigger covering the whole map.

_this select 1 = the unit killed
player is the unit who killed the guy with the eventhandler

killcount.sqs

Code: [Select]
_killer = _this select 0
_unit = _this select 1

?(!_killer == _unit):exit

kills = kills + 1


Init.sqs

Code: [Select]

kills = 0


Syntax not guaranteed. The solution I found used a different script entirely. There is a way to track all kills made, but I'm assuming you want to track the kills of only one unit.

To check when the global variable 'kills' reaches 10,20,30 etc, I think all you need to do is make a trigger that has:

Code: [Select]
?(kills == 30)
in the condition field, and then put whatever you want in the activation field.

As I said, none of this is guaranteed, but it looked to me like the best solution. Off the top of my head though I can't see why any of this can't work, but then I haven't had a chance to test any of it.

By the way, Mad Pup, I suggest you make use of the search feature. You'd be surprised how many of your questions can be answered this way.

Regards,
Gruntage
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba