[Help] [C#] OnPlayerKilled event

I’ve been struggling to get this event working for some time now.
While looking for an answer on how to listen for this event I came across some different solutions and I am not sure which one is good.

I need to get Killer Player and Killed Player from this event, should I do it like this:

EventHandlers["onPlayerKilled"] += new Action<Player, Player>(OnPlayerKilled);

Or like this:

EventHandlers["onPlayerKilled"] += new Action<Int, Int>(OnPlayerKilled);

Some sources stated that this should return Player, while others say that it returns playerID (int), which one is correct?
Also, I’ve seen syntax like this:

EventHandlers["baseevents:onPlayerKilled"]

What is up with baseevents, should it be there for it to work properly? If so, in which events should I include it?

I honestly wouldn’t know if it would be

EventHandlers["onPlayerKilled"] += new Action<Player, Player>(OnPlayerKilled);

or

EventHandlers["onPlayerKilled"] += new Action<Int, Int>(OnPlayerKilled);

Just try both of them out. The last one you have on their is not right at all, it would just be onPlayerKilled.

TIP:
If it is the one that uses integers, to find the player use some events to find it from the sever side using Players[id_here] on the serverside.

1 Like

Tried a lot of different variations and finally got one version working so I wanted to update this thread.
For some reason the one that is working for me includes baseevents: part. This is the server script, I am not sure what are the parameters for the client version of this event.

EventHandlers["baseevents:onPlayerKilled"] += new Action<Player, int>(OnPlayerKilled);

public void OnPlayerKilled([FromSource] Player deadPlayer, int killerID)
{
     Player killer = Players[killerID];
}

The parameter in “onPlayerKilled” event is ID of the killer, but you can also extract the victim from source.

1 Like

For me it always returns -1, dont know what to do.