luccagomes
New Member
- Joined
- Jul 30, 2015
- Messages
- 153
- Reaction score
- 1
Why this error? How to fix?
Console Error:
MOD
Console Error:
Code:
[8:3:29.872] [Error - CreatureScript Interface]
[8:3:29.872] In a timer event called from:
[8:3:29.872] local t = {
[8:3:29.872] item = 11393,
[8:3:29.872] slot = CONST_SLOT_NECKLACE,
[8:3:29.872] newRate = 2
[8:3:29.872] }
[8:3:29.872] local rate = getConfigInfo('rateLoot')
[8:3:29.873] function getContentDescription(uid, comma)
[8:3:29.873] local ret, i, containers = '', 0, {}
[8:3:29.873] while i < getContainerSize(uid) do
[8:3:29.873] local v, s = getContainerItem(uid, i), ''
[8:3:29.873] local k = getItemInfo(v.itemid)
[8:3:29.873] if k.name ~= '' then
[8:3:29.873] if v.type > 1 and k.stackable and k.showCount then
[8:3:29.874] s = v.type .. ' ' .. getItemInfo(v.itemid).plural
[8:3:29.874] else
[8:3:29.874] local article = k.article
[8:3:29.874] s = (article == '' and '' or article .. ' ') .. k.name
[8:3:29.874] end
[8:3:29.874] ret = ret .. (i == 0 and not comma and '' or ', ') .. s
[8:3:29.874] if isContainer(v.uid) and getContainerSize(v.uid) > 0 then
[8:3:29.874] table.insert(containers, v.uid)
[8:3:29.874] end
[8:3:29.874] else
[8:3:29.874] ret = ret .. (i == 0 and not comma and '' or ', ') .. 'an item of type ' .. v.itemid .. ', please report it to gamemaster'
[8:3:29.874] end
[8:3:29.874] i = i + 1
[8:3:29.874] end
[8:3:29.874] for i = 1, #containers do
[8:3:29.874] ret = ret .. getContentDescription(containers[i], true)
[8:3:29.874] end
[8:3:29.874] return ret
[8:3:29.874] end
[8:3:29.874] local lootchannelstorage = 7971
[8:3:29.874] local function send(cid, pos, corpseid, monster, party)
[8:3:29.874] local corpse = getTileItemById(pos, corpseid).uid
[8:3:29.874] local ret = isContainer(corpse) and getContentDescription(corpse)
[8:3:29.874] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing') )
[8:3:29.874] end
[8:3:29.874] local function createLoot(i, ext)
[8:3:29.874] local item = type(i.id) == 'table' and i.id[math.random(#i.id)] or i.id
[8:3:29.874] local random = math.ceil(math.random(100000) / (ext and t.newRate or rate))
[8:3:29.874] local tmpItem
[8:3:29.874] if random < i.chance then
[8:3:29.874] tmpItem = doCreateItemEx(item, getItemInfo(item).stackable and random % i.count + 1 or 1)
[8:3:29.874] end
[8:3:29.874] if not tmpItem then
[8:3:29.875] return
[8:3:29.875] end
[8:3:29.879] if i.subType ~= -1 then
[8:3:29.879] doItemSetAttribute(tmpItem, 'subType', i.subType)
[8:3:29.879] end
[8:3:29.879] if i.actionId ~= -1 then
[8:3:29.879] doItemSetAttribute(tmpItem, 'aid', i.actionId)
[8:3:29.879] end
[8:3:29.879] if i.uniqueId ~= -1 then
[8:3:29.879] doItemSetAttribute(tmpItem, 'uid', i.uniqueId)
[8:3:29.879] end
[8:3:29.879] if i.text ~= '' then
[8:3:29.879] doItemSetAttribute(tmpItem, 'text', i.text)
[8:3:29.879] end
[8:3:29.879] return tmpItem
[8:3:29.879] end
[8:3:29.879] local function createChildLoot(parent, i, ext)
[8:3:29.879] if #i == 0 then
[8:3:29.879] return true
[8:3:29.879] end
[8:3:29.879] local size, cap = 0, getContainerCap(parent)
[8:3:29.879] for k = 1, #i do
[8:3:29.879] if size == cap then
[8:3:29.879] break
[8:3:29.879] end
[8:3:29.879] local tmp = createLoot(i[k], ext)
[8:3:29.879] if tmp then
[8:3:29.879] if isContainer(tmp) then
[8:3:29.879] if createChildLoot(tmp, i[k].child, ext) then
[8:3:29.880] doAddContainerItemEx(parent, tmp)
[8:3:29.880] size = size + 1
[8:3:29.880] else
[8:3:29.880] doRemoveItem(tmp)
[8:3:29.880] end
[8:3:29.880] else
[8:3:29.880] doAddContainerItemEx(parent, tmp)
[8:3:29.880] size = size + 1
[8:3:29.880] end
[8:3:29.880] end
[8:3:29.880] end
[8:3:29.880] return size > 0
[8:3:29.880] end
[8:3:29.880] local function dropLoot(pos, v, ext)
[8:3:29.880] local corpse = getTileItemById(pos, v.lookCorpse).uid
[8:3:29.880] if isContainer(corpse) then
[8:3:29.880] for i = 1, getContainerSize(corpse) do
[8:3:29.880] doRemoveItem(getContainerItem(corpse, 0).uid)
[8:3:29.880] end
[8:3:29.880] local size, cap = 0, getContainerCap(corpse)
[8:3:29.880] for i = 1, #v.loot do
[8:3:29.880] if size == cap then
[8:3:29.880] break
[8:3:29.880] end
[8:3:29.880] local tmp = createLoot(v.loot[i], ext)
[8:3:29.880] if tmp then
[8:3:29.880] if isContainer(tmp) then
[8:3:29.880] if createChildLoot(tmp, v.loot[i].child, ext) then
[8:3:29.880] doAddContainerItemEx(corpse, tmp)
[8:3:29.880] size = size + 1
[8:3:29.880] else
[8:3:29.880] doRemoveItem(tmp)
[8:3:29.880] end
[8:3:29.880] else
[8:3:29.881] doAddContainerItemEx(corpse, tmp)
[8:3:29.881] size = size + 1
[8:3:29.881] end
[8:3:29.881] end
[8:3:29.881] end
[8:3:29.881] end
[8:3:29.881] end
[8:3:29.881] function onKill(cid, target, lastHit)
[8:3:29.881] if lastHit and isMonster(target) then
[8:3:29.881] local v = getMonsterInfo(getCreatureName(target))
[8:3:29.881] if v.lookCorpse > 0 then
[8:3:29.881] local master = getCreatureMaster(target)
[8:3:29.881] if not master or master == target then
[8:3:29.881] addEvent(dropLoot, 0, getThingPos(target), v, getPlayerSlotItem(cid, t.slot).itemid == t.item)
[8:3:29.881] end
[8:3:29.881] addEvent(send, 100, cid, getThingPos(target), v.lookCorpse, v.description)
[8:3:29.881] end
[8:3:29.881] end
[8:3:29.881] return true
[8:3:29.881] end
[8:3:29.881] :onKill
[8:3:29.881] Description:
[8:3:29.881] [string "LuaInterface::loadBuffer"]:50: attempt to index a boolean value
[8:3:29.881] stack traceback:
[8:3:29.881] [string "LuaInterface::loadBuffer"]:50: in function 'createLoot'
[8:3:29.881] [string "LuaInterface::loadBuffer"]:116: in function <[string "LuaInterface::loadBuffer"]:105>
MOD
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Loot Ring" version="1.0" author="Cykotitan" contact="otland.net" enabled="yes">
<event type="kill" name="lootring" event="script"> <![CDATA[
local t = {
item = 11393,
slot = CONST_SLOT_NECKLACE,
newRate = 2
}
local rate = getConfigInfo('rateLoot')
function getContentDescription(uid, comma)
local ret, i, containers = '', 0, {}
while i < getContainerSize(uid) do
local v, s = getContainerItem(uid, i), ''
local k = getItemInfo(v.itemid)
if k.name ~= '' then
if v.type > 1 and k.stackable and k.showCount then
s = v.type .. ' ' .. getItemInfo(v.itemid).plural
else
local article = k.article
s = (article == '' and '' or article .. ' ') .. k.name
end
ret = ret .. (i == 0 and not comma and '' or ', ') .. s
if isContainer(v.uid) and getContainerSize(v.uid) > 0 then
table.insert(containers, v.uid)
end
else
ret = ret .. (i == 0 and not comma and '' or ', ') .. 'an item of type ' .. v.itemid .. ', please report it to gamemaster'
end
i = i + 1
end
for i = 1, #containers do
ret = ret .. getContentDescription(containers[i], true)
end
return ret
end
local lootchannelstorage = 7971
local function send(cid, pos, corpseid, monster, party)
local corpse = getTileItemById(pos, corpseid).uid
local ret = isContainer(corpse) and getContentDescription(corpse)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED,'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing') )
end
local function createLoot(i, ext)
local item = type(i.id) == 'table' and i.id[math.random(#i.id)] or i.id
local random = math.ceil(math.random(100000) / (ext and t.newRate or rate))
local tmpItem
if random < i.chance then
tmpItem = doCreateItemEx(item, getItemInfo(item).stackable and random % i.count + 1 or 1)
end
if not tmpItem then
return
end
if i.subType ~= -1 then
doItemSetAttribute(tmpItem, 'subType', i.subType)
end
if i.actionId ~= -1 then
doItemSetAttribute(tmpItem, 'aid', i.actionId)
end
if i.uniqueId ~= -1 then
doItemSetAttribute(tmpItem, 'uid', i.uniqueId)
end
if i.text ~= '' then
doItemSetAttribute(tmpItem, 'text', i.text)
end
return tmpItem
end
local function createChildLoot(parent, i, ext)
if #i == 0 then
return true
end
local size, cap = 0, getContainerCap(parent)
for k = 1, #i do
if size == cap then
break
end
local tmp = createLoot(i[k], ext)
if tmp then
if isContainer(tmp) then
if createChildLoot(tmp, i[k].child, ext) then
doAddContainerItemEx(parent, tmp)
size = size + 1
else
doRemoveItem(tmp)
end
else
doAddContainerItemEx(parent, tmp)
size = size + 1
end
end
end
return size > 0
end
local function dropLoot(pos, v, ext)
local corpse = getTileItemById(pos, v.lookCorpse).uid
if isContainer(corpse) then
for i = 1, getContainerSize(corpse) do
doRemoveItem(getContainerItem(corpse, 0).uid)
end
local size, cap = 0, getContainerCap(corpse)
for i = 1, #v.loot do
if size == cap then
break
end
local tmp = createLoot(v.loot[i], ext)
if tmp then
if isContainer(tmp) then
if createChildLoot(tmp, v.loot[i].child, ext) then
doAddContainerItemEx(corpse, tmp)
size = size + 1
else
doRemoveItem(tmp)
end
else
doAddContainerItemEx(corpse, tmp)
size = size + 1
end
end
end
end
end
function onKill(cid, target, lastHit)
if lastHit and isMonster(target) then
local v = getMonsterInfo(getCreatureName(target))
if v.lookCorpse > 0 then
local master = getCreatureMaster(target)
if not master or master == target then
addEvent(dropLoot, 0, getThingPos(target), v, getPlayerSlotItem(cid, t.slot).itemid == t.item)
end
addEvent(send, 100, cid, getThingPos(target), v.lookCorpse, v.description)
end
end
return true
end
]]></event>
<event type="login" name="Loot Ring" event="buffer"><![CDATA[
registerCreatureEvent(cid, "lootring")
]]></event>
</mod>