First, a correction on what I said above. The syntax for addEventHandler is
not like in rhysduk's example. I was struck by temporary (?) ;D stupidity and made a mistake. We'll get to addEventhandler below...
OK, I understand it runs only to the victim, so how can I detect who his killer was? Is there an eventhandler that will detect killed by?
The "killed" event gives you just that, so you're on the right track. Ok, how about this...
1 - Modify that "anybody trigger" and use this (can also be put this in the init.sqs if you remove the trigger)
player addEventHandler ["killed", {_this exec "killed.sqs"}]
That's the correct addEventHandler syntax. This will add a killed EH to all players.
2 - Make a "killed.sqs" like so:
; killed.sqs
?!(count _this == 2):exit
_victim = _this select 0
_shooter = _this select 1
?(_victim == _shooter): exit
?(side _victim == side _shooter): _shooter addScore -2
exit
...and see if that does what you want. There is one thing though... the
addScore command. It's quite possible that you have to run that where the unit to be affected is local. In other words, one would have to do
addScore on the shooter's machine and not on the vicim's. With the script as above, the addScore will be run on the victim's machine, since the killed EH only runs where the killed unit (i.e the victim) is local. Test it and tell me if it works. Otherwise, we have to think of a way to do the addScore on the perpetrator's machine...
(Add my vote for making the killed event be distributed to all machines, no matter how many old scripts it will break. )