OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started 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?
-
Use EventHadler
"killed" (addable to men or vehicles) :
_this select 0 : who's dead ;
_this select 1 : whodunnit (say, the killer) ;
-
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
-
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!!!
-
use the foreach command to attach it to every dude in a trigger. something like:
"_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.
-
{_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
-
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)
-
...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 !!!!!!!!!
-
Don't forget to solve the topic, please. (that's the green button at the bottom (left) of your screen) ;)