• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Why some times print it all on console? LootAmulet.

luccagomes

New Member
Joined
Jul 30, 2015
Messages
153
Reaction score
1
I tried to adept this: https://otland.net/threads/mod-loot-ring.99748/ mod loot ring to make a amulet to set loot rates to 2x

Its work, but sometimes it show big erros on console like this:
Code:
[2:10:35.754] [Error - CreatureScript Interface]
[2:10:35.754] In a timer event called from:
[2:10:35.754] local t = {
[2:10:35.754] item = 11393,
[2:10:35.754] slot = CONST_SLOT_NECKLACE,
[2:10:35.754] newRate = 2
[2:10:35.754] }

[2:10:35.754] local rate = getConfigInfo('rateLoot')

[2:10:35.754] function getContentDescription(uid, comma)
[2:10:35.755] local ret, i, containers = '', 0, {}
[2:10:35.755] while i < getContainerSize(uid) do
[2:10:35.755] local v, s = getContainerItem(uid, i), ''
[2:10:35.755] local k = getItemInfo(v.itemid)
[2:10:35.756] if k.name ~= '' then
[2:10:35.757] if v.type > 1 and k.stackable and k.showCount then
[2:10:35.757] s = v.type .. ' ' .. getItemInfo(v.itemid).plural
[2:10:35.757] else
[2:10:35.757] local article = k.article
[2:10:35.757] s = (article == '' and '' or article .. ' ') .. k.name
[2:10:35.757] end
[2:10:35.757] ret = ret .. (i == 0 and not comma and '' or ', ') .. s
[2:10:35.757] if isContainer(v.uid) and getContainerSize(v.uid) > 0 then
[2:10:35.757] table.insert(containers, v.uid)
[2:10:35.757] end
[2:10:35.757] else
[2:10:35.757] ret = ret .. (i == 0 and not comma and '' or ', ') .. 'an item of type ' .. v.itemid .. ', please report it to gamemaster'
[2:10:35.766] end
[2:10:35.766] i = i + 1
[2:10:35.766] end
[2:10:35.766] for i = 1, #containers do
[2:10:35.766] ret = ret .. getContentDescription(containers[i], true)
[2:10:35.766] end
[2:10:35.766] return ret
[2:10:35.766] end

[2:10:35.766] local function send(cid, pos, corpseid, monster, party)
[2:10:35.766] local corpse = getTileItemById(pos, corpseid).uid
[2:10:35.766] local ret = isContainer(corpse) and getContentDescription(corpse)
[2:10:35.766] doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'))
[2:10:35.766] if party then
[2:10:35.766] for _, pid in ipairs(getPartyMembers(party)) do
[2:10:35.766] doPlayerSendChannelMessage(pid, '', 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'), TALKTYPE_CHANNEL_W, CHANNEL_PARTY)
[2:10:35.766] end
[2:10:35.766] end
[2:10:35.766] end

[2:10:35.766] local function createLoot(i, ext)
[2:10:35.766] local item = type(i.id) == 'table' and i.id[math.random(#i.id)] or i.id
[2:10:35.767] local random = math.ceil(math.random(100000) / (ext and t.newRate or rate))





[2:10:35.767] local tmpItem = false

[2:10:35.767] if random < i.chance then
[2:10:35.767] tmpItem = doCreateItemEx(item, getItemInfo(item).stackable and random % i.count + 1 or 1)
[2:10:35.768] end

[2:10:35.768] if not tmpItem then
[2:10:35.768] return false
[2:10:35.768] end

[2:10:35.768] if i.subType ~= -1 then
[2:10:35.768] doItemSetAttribute(tmpItem, 'subType', i.subType)
[2:10:35.768] end







[2:10:35.769] if i.actionId ~= -1 then
[2:10:35.770] doItemSetAttribute(tmpItem, 'aid', i.actionId)
[2:10:35.770] end

[2:10:35.772] if i.uniqueId ~= -1 then
[2:10:35.772] doItemSetAttribute(tmpItem, 'uid', i.uniqueId)
[2:10:35.772] end

[2:10:35.772] if i.text ~= '' then
[2:10:35.772] doItemSetAttribute(tmpItem, 'text', i.text)
[2:10:35.772] end

[2:10:35.772] return tmpItem
[2:10:35.772] end

[2:10:35.772] local function createChildLoot(parent, i, ext)
[2:10:35.772] if #i == 0 then
[2:10:35.773] return true
[2:10:35.773] end

[2:10:35.773] local size, cap = 0, getContainerCap(parent)
[2:10:35.773] for k = 1, #i do
[2:10:35.773] if size == cap then
[2:10:35.773] break
[2:10:35.777] end
[2:10:35.777] local tmp = createLoot(i[k], ext)
[2:10:35.778] if tmp then
[2:10:35.778] if isContainer(tmp) then
[2:10:35.778] if createChildLoot(tmp, i[k].child, ext) then
[2:10:35.778] doAddContainerItemEx(parent, tmp)
[2:10:35.778] size = size + 1
[2:10:35.778] else
[2:10:35.778] doRemoveItem(tmp)
[2:10:35.778] end
[2:10:35.778] else
[2:10:35.778] doAddContainerItemEx(parent, tmp)
[2:10:35.778] size = size + 1
[2:10:35.778] end
[2:10:35.778] end
[2:10:35.778] end

[2:10:35.779] return size > 0
[2:10:35.779] end

[2:10:35.779] local function dropLoot(pos, v, ext)
[2:10:35.779] local corpse = getTileItemById(pos, v.lookCorpse).uid
[2:10:35.779] if isContainer(corpse) then
[2:10:35.779] for i = 1, getContainerSize(corpse) do
[2:10:35.779] doRemoveItem(getContainerItem(corpse, 0).uid)
[2:10:35.779] end
[2:10:35.779] local size, cap = 0, getContainerCap(corpse)
[2:10:35.779] for i = 1, #v.loot do
[2:10:35.779] if size == cap then
[2:10:35.779] break
[2:10:35.779] end
[2:10:35.780] local tmp = createLoot(v.loot[i], ext)
[2:10:35.780] if tmp then
[2:10:35.780] if isContainer(tmp) then
[2:10:35.780] if createChildLoot(tmp, v.loot[i].child, ext) then
[2:10:35.780] doAddContainerItemEx(corpse, tmp)
[2:10:35.780] size = size + 1
[2:10:35.780] else
[2:10:35.780] doRemoveItem(tmp)
[2:10:35.780] end
[2:10:35.780] else
[2:10:35.780] doAddContainerItemEx(corpse, tmp)
[2:10:35.780] size = size + 1
[2:10:35.780] end
[2:10:35.780] end
[2:10:35.780] end
[2:10:35.780] end
[2:10:35.780] end

[2:10:35.780] function onKill(cid, target, lastHit)
[2:10:35.780] if lastHit and isMonster(target) then
[2:10:35.780] local v = getMonsterInfo(getCreatureName(target))
[2:10:35.780] if v.lookCorpse > 0 then
[2:10:35.780] local master = getCreatureMaster(target)
[2:10:35.780] if not master or master == target then
[2:10:35.780] addEvent(dropLoot, 0, getThingPos(target), v, getPlayerSlotItem(cid, t.slot).itemid == t.item)
[2:10:35.780] end
[2:10:35.780] addEvent(send, 100, cid, getThingPos(target), v.lookCorpse, v.description)
[2:10:35.780] end
[2:10:35.780] end
[2:10:35.780] return true
[2:10:35.780] end
[2:10:35.780] :onKill
[2:10:35.780] Description:
[2:10:35.780] [string "LuaInterface::loadBuffer"]:58: attempt to index a boolean value
[2:10:35.783] stack traceback:
[2:10:35.785] [string "LuaInterface::loadBuffer"]:58: in function 'createLoot'
[2:10:35.785] [string "LuaInterface::loadBuffer"]:130: in function <[string "LuaInterface::loadBuffer"]:119>

What is it?
Why?
Could you help me to fix?
 
Mod script
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 function send(cid, pos, corpseid, monster, party)
  local corpse = getTileItemById(pos, corpseid).uid
  local ret = isContainer(corpse) and getContentDescription(corpse)
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'))
  if party then
  for _, pid in ipairs(getPartyMembers(party)) do
  doPlayerSendChannelMessage(pid, '', 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'), TALKTYPE_CHANNEL_W, CHANNEL_PARTY)
  end
  end
  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 = false

  if random < i.chance then
  tmpItem = doCreateItemEx(item, getItemInfo(item).stackable and random % i.count + 1 or 1)
  end

  if not tmpItem then
  return false
  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>
 
You have error in addevent function, that is why tfs is printing error in console.
 
Check if this works.
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 function send(cid, pos, corpseid, monster, party)
  local corpse = getTileItemById(pos, corpseid).uid
  local ret = isContainer(corpse) and getContentDescription(corpse)
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'))
  if party then
  for _, pid in ipairs(getPartyMembers(party)) do
  doPlayerSendChannelMessage(pid, '', 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'), TALKTYPE_CHANNEL_W, CHANNEL_PARTY)
  end
  end
  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 itemInfo = getItemInfo(item)
  if not itemInfo then
  return false
  end


  local tmpItem = false

  if random < i.chance then
  tmpItem = doCreateItemEx(item, itemInfo.stackable and random % i.count + 1 or 1)
  end

  if not tmpItem then
  return false
  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>
 
Check if this works.
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 function send(cid, pos, corpseid, monster, party)
  local corpse = getTileItemById(pos, corpseid).uid
  local ret = isContainer(corpse) and getContentDescription(corpse)
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'))
  if party then
  for _, pid in ipairs(getPartyMembers(party)) do
  doPlayerSendChannelMessage(pid, '', 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'), TALKTYPE_CHANNEL_W, CHANNEL_PARTY)
  end
  end
  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 itemInfo = getItemInfo(item)
  if not itemInfo then
  return false
  end


  local tmpItem = false

  if random < i.chance then
  tmpItem = doCreateItemEx(item, itemInfo.stackable and random % i.count + 1 or 1)
  end

  if not tmpItem then
  return false
  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>

looks working, ty so much!
 
Back
Top