Home   Help Search Login Register  

Author Topic: Counting kills  (Read 758 times)

0 Members and 1 Guest are viewing this topic.

Hfarl

  • Guest
Counting kills
« on: 15 Jul 2006, 19:40:04 »
This is probably a rather simple question, but how do I keep track of how many of a given side the player has killed?
I want to add numerical values to different variables when the player whacks people.
Like, "if player killed 1 east, then add 1 to variable x"
Thanks in advance!

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: Counting kills
« Reply #1 on: 15 Jul 2006, 21:26:52 »
For multiplayer this would require

a) Use of a killed eventhandler on each unit on the map
b) The killed eventhandler would need to broadcasting the killer's identitiy to all clients
c) a receiving script on the client would check if the killer was himself and then increment a count to a variable
(Use of CoC_Ns would help here, although it is doable without)

For single player, this would be easier, no need for networking


When a unit dies that has a killed event handler attached too it, the eventhandler passes 2 variables to for example a script

this addEventHandler ["killed", {_this exec "unitkilled.sqs"}]


unitkilled.sqs
_u = _this select 0     (the unit that got killed)
_killer = _this select 1    (the killer unit)

then to broadcast it

tx_Killer = _killer
Publicvariable "tx_killer"


the receiving script would look something like the following


#start
@ !isnull tx_killer
? (tx_killer == player): goto "I_AM_KILLER"
tx_Killer = objnull
goto "START"

#I_AM_KILLER
tx_myscore = tx_myscore + 1
tx_Killer = objnull
goto "START"


Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123