OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: idleness on 19 Sep 2005, 03:26:01

Title: Kill Detection
Post by: idleness on 19 Sep 2005, 03:26:01
hi guys,

i was wondering if anyone has a good algorithm for kill detection, whenever someone is killed, i'd like a hint popup saying "player1 killed player2"

i've been thinking playing around with this and it works MOST of the time with like less than 10 units on the map. i'm afraid that when i have many more units, the incidence of this working would fall further. Also, i'm unable to detect kills from grenades.

can someone pls help?
Title: Re:Kill Detection
Post by: bdfy85 on 19 Sep 2005, 03:29:26
Use EventHadler
"killed" (addable to men or vehicles) :
_this select 0 : who's dead ;
_this select 1 : whodunnit (say, the killer) ;
Title: Re:Kill Detection
Post by: Triggerhappy on 19 Sep 2005, 03:48:31
so to do what you want:
trigger, covering entire map:
anybody present
on activation:
{_x addeventhandler ["killed", hint format ["%1 killed %2",(name (_this select 1)),(name (_this select 0))]} foreach units thislist

tadaaa
Title: Re:Kill Detection
Post by: idleness on 19 Sep 2005, 05:14:07
it doesn't work, do i have to add annything to the init fields of my men?

however it did work when i put:

this addeventhandler ["killed", {hint format ["%1 killed %2",(name(_this select 1)), (name(_this select 0))]}]

into all my men's init fields.

THANKS for ur help!!!
Title: Re:Kill Detection
Post by: bored_onion on 19 Sep 2005, 18:52:41
use the foreach command to attach it to every dude in a trigger. something like:

Code: [Select]
"_x" addeventhandler ["killed", {hint format ["%1 killed %2",(name(_this select 1)), (name(_this select 0))]}] foreach units thislist
stick it in the on activation of a trigger set to activate from "anybody present." syntax nowhere guaranteed and is probably wrong. you may need to fiddle.
Title: Re:Kill Detection
Post by: bdfy85 on 19 Sep 2005, 20:12:01
{_x addeventhandler ["killed", hint format ["%1 killed %2",(name (_this select 1)),(name (_this select 0))]} foreach (list trigername)
trigername - name of your triger covering map
Title: Re:Kill Detection
Post by: Triggerhappy on 20 Sep 2005, 04:30:01
lol bdfy you made the same mistake as me!

{_x addeventhandler ["killed", {hint format ["%1 killed %2",(name (_this select 1)),(name (_this select 0))}]} foreach (list trigername)

forgot the extra curly brackets on the eventhandler command (i always do :P)
Title: Re:Kill Detection
Post by: idleness on 20 Sep 2005, 10:41:16
...e (_this select 0))}]} foreach .....

and trigger forgot a "]". lol took me so long to discover y it wasn't working!!!

aniway final got it running =)

THANKS GUYS !!!!!!!!!
Title: Re:Kill Detection
Post by: Blanco on 20 Sep 2005, 11:34:22
Don't forget to solve the topic, please. (that's the green button at the bottom (left) of your screen)  ;)