Skip to content

OnPlayerLootBody

A player wants to search a dead player’s body - return false to refuse.

Nothing has opened yet. Otherwise the game’s own loot window opens on what the dead player carries ([combat] loot_bodies: everything, or everything but what they wear, and the purse) and whatever the searcher takes is gone from the dead player; the respawn waits while the search is open. victim is -1 for a body that stayed after its player respawned and left the server ([combat] corpse_seconds). With loot_bodies = "none" nobody is asked: bodies cannot be searched at all.

function OnPlayerLootBody(pid, victim)
-- ...
end
Parameter Type
pid number the searcher
victim number whose body it is; -1 = its player has left

false refuses; anything else lets them search

-- only the killer and the dead player's own team may search the body
local killers = {}
function OnPlayerDeath(pid, attacker) killers[pid] = attacker end
function OnPlayerLootBody(pid, victim)
if victim < 0 then return true end
return killers[victim] == pid or GetPlayerTeam(pid) == GetPlayerTeam(victim)
end

OnPlayerDeath · OnPlayerOpenContainer · OnPlayerCorpse · the Combat group of the index