Home   Help Search Login Register  

Author Topic: Detect a teamkill  (Read 1515 times)

0 Members and 1 Guest are viewing this topic.

Offline dr. seltsam

  • Members
  • *
Detect a teamkill
« on: 28 Nov 2008, 04:19:35 »
Hi,

i am working on a little mission. I have a problem with a script that runs from a "killed" eventhandler in multiplayer:

plane addEventHandler ["killed",{_this exec "Event.sqs"}]

Now we have the Event.sqs:

Code: [Select]

_object = _this select 0
_killer = _this select 1

; insert code here



# Regular
hint "this was a regular kill"
exit


# Teamkill
hint "this was a teamkill"
exit


My question is:

Is there a reliable way for the computer that runs that script to find out, if the _killer did a teamkill, i mean, if the _object was friendly to him?
The problem here is, that every killed object (planes, soldiers, tanks, etc.) are considered to be an object of the civilian side. Only sometimes (mostly with vehicles) the eventhandler has the correct side of the object present, but a fraction of a second later, not anymore, and in MP we have to add effects of lag to the whole thing...

 ???
« Last Edit: 28 Nov 2008, 04:44:53 by dr. seltsam »

Walter_E_Kurtz

  • Guest
Re: Detect a teamkill
« Reply #1 on: 28 Nov 2008, 16:11:37 »
We could do with a bit more info on how this is supposed to fit together. Surely you should only be worried about team-kills caused by human players, though the whole thing would be complicated if humans are on more than one side (ie. US and Resistance).

I'd create Event scripts for each side, and include an array of players that are friendly to that side, eg. Init.sqs
Code: [Select]
WestFriends = [west1, west2, west3 ...]
exit

EventWest.sqs
Code: [Select]
_object = _this select 0
_killer = _this select 1

_noWestFriends = count WestFriends
_i = -1
#LoopStart
_i = _i + 1
? (_killer == (WestFriends select _i)): goto "Teamkill"
? (_i != _noWestFriends): goto "LoopStart"

# Regular
hint "this was a regular kill"
exit

# Teamkill
hint "this was a teamkill"
exit

Create EventEast.sqs if necessary and make sure objects run the correct script from their event handler.

Players could also have killed eventHandlers to remove them from the arrays once they're dead.

I'm uncertain if respawns would have any implications for this.

Offline dr. seltsam

  • Members
  • *
Re: Detect a teamkill
« Reply #2 on: 28 Nov 2008, 17:26:21 »
That Event.sqs is only a part of a project that will give certain playable units score rewards for kills, and minus score punishment for killing friendly units. The script will be a commissional work for another mission. In this mission everything will get spawned and respawned. But i know how to deal with that.

If noone is able to detect a teamkill independently from a "killed" eventhandler, i will go with your suggestion and make arrays for west and east. That way the script usage is maybe limited to the above mentioned mission only.