baseevents:onPlayerKilled
The reviewed baseevents provider emits (killerID, deathData) locally and to the server. When available, killerID is a server player ID, not a client player index. It can be -1 when the provider cannot resolve a player. Do not feed it directly into a client native that expects a player index.
Actual emitted field names
| Field | Meaning in the reviewed source |
|---|---|
killertype | Ped type reported for the killer. |
weaponhash | Reported weapon hash. |
killerinveh | Provider’s reported vehicle-presence flag. |
killervehseat | Reported vehicle seat. |
killervehname | Vehicle display label. |
killerpos | Despite the name, the source fills this with the victim ped’s coordinates. |
Keys are case-sensitive. The emitted keys are lowercase, not killerType, weaponHash or killerPos. This table describes the provider’s payload, not a guarantee that all reported fields are authoritative or correct under every game condition.
Read only what the feature needs
For local client.lua presentation:
AddEventHandler('baseevents:onPlayerKilled', function(killerID, data)
if type(data) ~= 'table' or type(data.weaponhash) ~= 'number' then return end
print(('[Death observation] Reported weapon hash: %s'):format(data.weaponhash))
end)Start baseevents before the consumer. A server listener instead captures implicit source as the reporting victim session. Do not pay killerID, remove inventory, ban an attacker or publish the coordinate array solely from this client report. Resolve current identities and validate server-owned gameplay state for consequential actions.
Test player-caused and non-player-caused deaths, vehicle-related cases and an unknown killer. Use network/local ID conversion deliberately. The pinned source is linked so future provider changes can be reviewed rather than silently inheriting this snapshot. Related: onPlayerDied and stock contracts.