i need help this script should send text with loot of killed monsters and its does not work, no errors in console.
Lua:
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
local name = getCreatureName(cid)
local text = ""
if isPlayer(mostDamageKiller) == TRUE and isCreature(cid) == TRUE and getContainerItem(corpse.uid, 0).uid > 0 then
local loot = {}
for i = 1, getContainerSize(corpse.uid) do
loot[i] = getContainerItem(corpse.uid, i-1)
end
for i, v in pairs(loot) do
if text == "" then
text = "Loot from "..name..": "..(v.type == 0 and getItemArticle(v.uid) or v.type).." "..getItemNameById(v.uid)
else
text = text..", "..(v.type == 0 and getItemArticle(v.uid) or v.type).." "..getItemNameById(v.uid)
end
end
text = text.."."
else
text = "Loot from "..name..": Nothing."
end
doPlayerSendTextMessage(mostDamageKiller, MESSAGE_STATUS_CONSOLE_ORANGE, text)
return TRUE
end