• 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!

Error MOD loot

luccagomes

New Member
Joined
Jul 30, 2015
Messages
153
Reaction score
1
Why this error? How to fix?

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>
 
today again... hunting carrion worms

script working all time (i think)

but sometimes show me somethings like it on console:

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>
 
between line 118 and 119 add
print(size)
and between 129 and 130 add
print(size, cap)
and between 58 and 59 (between tmpItem = false and random < i.chance add
print(random, i)
print(i.chance)
and tell me what console prints
 
between line 118 and 119 add
print(size)
and between 129 and 130 add
print(size, cap)
and between 58 and 59 (between tmpItem = false and random < i.chance add
print(random, i)
print(i.chance)
and tell me what console prints

I dont understand you... why u just not edit XD

I made the changes, test:
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

  print(random, i)
  print(i.chance)

  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
  print(size)
  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
  print(size, cap)
  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>


I killed a rotworm and show me it on console:
Code:
0
10
21242

71760
1
10
72849

3000
1
10
15220

20000
2
10
32104

20120
2
10
30423

4000
2
10
77453

1000
2
10
51463

10000
2
10
79825

100000
4270

500
92681

500
36896

500
0


But this error not show me every time, after long time botting in carrion worm i had that...
 
so it works, but you get an error sometimes only?
change the prints to
print(size, "size")
print(size, cap, "size, cap")
print(random, i, "random, i")
print(i.chance, "i chance")
 
so it works, but you get an error sometimes only?
change the prints to
print(size, "size")
print(size, cap, "size, cap")
print(random, i, "random, i")
print(i.chance, "i chance")

I tried:
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

  print(size, "size")
  print(size, cap, "size, cap")

  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
  print(random, i, "random, i")
  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
  print(i.chance, "i chance")
  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>
 
Error when i killed the first monster
Code:
[17:39:27.341] [Error - CreatureScript Interface]
[17:39:27.341] In a timer event called from:
[17:39:27.341] local t = {
[17:39:27.341]  item = 11393,
[17:39:27.341]  slot = CONST_SLOT_NECKLACE,
[17:39:27.341]  newRate = 2
[17:39:27.341]  }

[17:39:27.342]  local rate = getConfigInfo('rateLoot')

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

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

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





[17:39:27.345]  local tmpItem = false

[17:39:27.345]  print(size, "size")
[17:39:27.345]  print(size, cap, "size, cap")

[17:39:27.345]  if random < i.chance then
[17:39:27.345]  tmpItem = doCreateItemEx(item, getItemInfo(item).stackable and random % i.count + 1 or 1)
[17:39:27.346]  end

[17:39:27.346]  if not tmpItem then
[17:39:27.346]  return false
[17:39:27.346]  end

[17:39:27.346]  if i.subType ~= -1 then
[17:39:27.346]  doItemSetAttribute(tmpItem, 'subType', i.subType)
[17:39:27.346]  end







[17:39:27.346]  if i.actionId ~= -1 then
[17:39:27.346]  doItemSetAttribute(tmpItem, 'aid', i.actionId)
[17:39:27.347]  end

[17:39:27.347]  if i.uniqueId ~= -1 then
[17:39:27.347]  doItemSetAttribute(tmpItem, 'uid', i.uniqueId)
[17:39:27.347]  end

[17:39:27.347]  if i.text ~= '' then
[17:39:27.347]  doItemSetAttribute(tmpItem, 'text', i.text)
[17:39:27.347]  end

[17:39:27.347]  return tmpItem
[17:39:27.347]  end

[17:39:27.347]  local function createChildLoot(parent, i, ext)
[17:39:27.347]  if #i == 0 then
[17:39:27.348]  return true
[17:39:27.348]  end

[17:39:27.348]  local size, cap = 0, getContainerCap(parent)
[17:39:27.348]  for k = 1, #i do
[17:39:27.348]  if size == cap then
[17:39:27.348]  break
[17:39:27.348]  end
[17:39:27.348]  local tmp = createLoot(i[k], ext)
[17:39:27.348]  if tmp then
[17:39:27.348]  if isContainer(tmp) then
[17:39:27.348]  if createChildLoot(tmp, i[k].child, ext) then
[17:39:27.348]  doAddContainerItemEx(parent, tmp)
[17:39:27.348]  size = size + 1
[17:39:27.348]  else
[17:39:27.348]  doRemoveItem(tmp)
[17:39:27.348]  end
[17:39:27.348]  else
[17:39:27.348]  doAddContainerItemEx(parent, tmp)
[17:39:27.348]  size = size + 1
[17:39:27.348]  end
[17:39:27.348]  end
[17:39:27.348]  end
[17:39:27.348]  print(random, i, "random, i")
[17:39:27.348]  return size > 0
[17:39:27.348]  end

[17:39:27.348]  local function dropLoot(pos, v, ext)
[17:39:27.348]  local corpse = getTileItemById(pos, v.lookCorpse).uid
[17:39:27.348]  if isContainer(corpse) then
[17:39:27.348]  for i = 1, getContainerSize(corpse) do
[17:39:27.348]  doRemoveItem(getContainerItem(corpse, 0).uid)
[17:39:27.348]  end
[17:39:27.348]  local size, cap = 0, getContainerCap(corpse)
[17:39:27.348]  for i = 1, #v.loot do
[17:39:27.348]  print(i.chance, "i chance")
[17:39:27.348]  if size == cap then
[17:39:27.348]  break
[17:39:27.348]  end
[17:39:27.348]  local tmp = createLoot(v.loot[i], ext)
[17:39:27.348]  if tmp then
[17:39:27.348]  if isContainer(tmp) then
[17:39:27.348]  if createChildLoot(tmp, v.loot[i].child, ext) then
[17:39:27.348]  doAddContainerItemEx(corpse, tmp)
[17:39:27.348]  size = size + 1
[17:39:27.348]  else
[17:39:27.348]  doRemoveItem(tmp)
[17:39:27.349]  end
[17:39:27.349]  else
[17:39:27.349]  doAddContainerItemEx(corpse, tmp)
[17:39:27.349]  size = size + 1
[17:39:27.349]  end
[17:39:27.349]  end
[17:39:27.349]  end
[17:39:27.349]  end
[17:39:27.349]  end

[17:39:27.349]  function onKill(cid, target, lastHit)
[17:39:27.349]  if lastHit and isMonster(target) then
[17:39:27.349]  local v = getMonsterInfo(getCreatureName(target))
[17:39:27.349]  if v.lookCorpse > 0 then
[17:39:27.349]  local master = getCreatureMaster(target)
[17:39:27.349]  if not master or master == target then
[17:39:27.349]  addEvent(dropLoot, 0, getThingPos(target), v, getPlayerSlotItem(cid, t.slot).itemid == t.item)
[17:39:27.349]  end
[17:39:27.349]  addEvent(send, 100, cid, getThingPos(target), v.lookCorpse, v.description)
[17:39:27.349]  end
[17:39:27.349]  end
[17:39:27.349]  return true
[17:39:27.349]  end
[17:39:27.349] :onKill
[17:39:27.349] Description:
[17:39:27.349] [string "LuaInterface::loadBuffer"]:130: attempt to index local 'i' (a number value)
[17:39:27.349] stack traceback:
[17:39:27.349]    [string "LuaInterface::loadBuffer"]:130: in function <[string "LuaInterface::loadBuffer"]:122>
 
Back
Top