Skip to content

OnPlayerLootBody

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

Nothing has opened yet. Return false and nothing opens, without a word to the searcher; a text after the false is shown in their chat (return false, "Not your kill."). 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’s game, item by item. The list is what the server’s records say the dead player carried, and the searcher is credited only with what the dead player’s game really gave up - a victim who left or came back to life voids the search. 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 saying nothing, false, "text" refuses and tells the searcher that text; 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
if killers[victim] == pid or GetPlayerTeam(pid) == GetPlayerTeam(victim) then return true end
return false, "Not your kill."
end

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