SetActorLoot
What a dead actor’s or animal’s body gives the players who search it.
The list a search takes from: {class = <item>, amount = <n>, health = <0-100>}, a class by its name, id or GUID, money as the
item money in tenths of a Groschen ({class = "money", amount = 150} is 15 Groschen), at most 64 entries. Set it whenever
you like - at the creation, in OnActorDeath, later: while the body lies dead with anything on it, every player sees the
game’s own loot prompt on it and searches it the game’s way, an animal’s body too. What a search takes is the searcher’s and
the list loses it (GetActorLoot shows what is left); once it is empty the prompt goes. An empty list takes it away at once.
OnPlayerLootActor may refuse a search. The body stays until DestroyEntity. This is the actor’s own list - what it
wears and carries (SetActorInventory) is not given up unless you put it here.
Syntax
Section titled “Syntax”SetActorLoot(id, items)| Parameter | Type | |
|---|---|---|
id |
number | the actor or animal |
items |
table | a list of {class =, amount =, health =}; amount 1 and health 100 by default |
Returns
Section titled “Returns”boolean - false for anything but a server actor or animal
Example
Section titled “Example”-- every wolf of the hunt carries a pelt and some meatlocal wolf = CreateAnimal("wolf", x, y, -1, 0)SetActorLoot(wolf, {{class = "skin_wolf", amount = 1}, {class = "wolfMeat", amount = 2}})
-- a bandit's carried things and his purse are on his body when he fallsfunction OnActorDeath(id, killer) if GetEntityData(id, "role") == "bandit" then local loot = {{class = "money", amount = math.random(50, 300)}} for _, item in ipairs(GetActorInventory(id) or {}) do if not item.worn then loot[#loot + 1] = item end end SetActorLoot(id, loot) SetTimer(function() DestroyEntity(id) end, 300000) -- the body lies five minutes endendSee also
Section titled “See also”GetActorLoot · OnPlayerLootActor · CreateAnimal · OnActorDeath · SetCorpseItems · the NPC actors group of the index
