Hi people. I'm trying to run a script onDeath, but it is not running properly. Could anyone help, please?
When I run this, it works fine: (verifies complete loot of monster)
When I run this, the for i, ..... doen't work...
Note: The monster say hi when die, but don't say any ID.
Thanks!
Edit: How can I put the itens inside corpse??
When I run this, it works fine: (verifies complete loot of monster)
LUA:
function onSay(cid, words, param, channel)
str = "Loot:\n"
local lootList = getMonsterLootList(param)
for i, _ in pairs(lootList) do
str = str .. getItemNameById(lootList[i].id) .. " (ID: " .. lootList[i].id .. ")\n"
end
doPlayerPopupFYI(cid, str)
end
When I run this, the for i, ..... doen't work...
LUA:
function onDeath(cid, corpse)
doCreatureSay(cid, "hi", 1)
local lootList = getMonsterLootList(getCreatureName(cid))
for i, _ in pairs(lootList) do
if lootList[i].count > 1 then
local numb = math.random(1, lootList[i].count)
doCreateItem(lootList[i].id, numb, corpse.pos)
doCreatureSay(cid, getItemNameById(lootList[i].id), 1)
else
if math.random(1,100000) <= lootList[i].chance then
doCreateItem(lootList[i].id, 1, corpse.pos)
doCreatureSay(cid, getItemNameById(lootList[i].id), 1)
end
end
end
return TRUE
end
Note: The monster say hi when die, but don't say any ID.
Thanks!
Edit: How can I put the itens inside corpse??
Last edited: