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

TFS 1.X+ Attempt to call field 'find'

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,521
Solutions
27
Reaction score
870
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Guys for some reason this error started to appear. Didn't have it before, I suppose I moved something. Where should I start checking to fix it?
Here's the script and the error log.

1709780907659.png

Lua:
local maxChance = 100
local config = {
    [SKULL_GREEN] = {
    [1] = { -- 1 Mago
      {id = 7620, chance = 5, maxCount = 1}, -- 7620 pocion de mana
    },
    [2] = { -- 2 Druida
      {id = 7620, chance = 5, maxCount = 1}, -- 7620 pocion de mana
    },
    [3] = { -- 3 Paladino
      {id = 7618, chance = 5, maxCount = 1}, -- 7618 pocion de vida
    },
    [4] = { --  4 Caballeros
      {id = 7618, chance = 5, maxCount = 1}, -- 7618 pocion de vida
    },
    [5] = { -- 1 Mago Maestro
      {id = 7620, chance = 5, maxCount = 1}, -- 7620 pocion de mana
    },
    [6] = { -- 2 Druida Erudito
      {id = 7620, chance = 5, maxCount = 1}, -- 7620 pocion de mana
    },
    [7] = { -- 3 Paladino Real
      {id = 7618, chance = 5, maxCount = 1}, -- 7618 pocion de vida
    },
    [8] = { -- 4 Caballero Elites
      {id = 7618, chance = 5, maxCount = 1}, -- 7618 pocion de vida
    },
  },
    [SKULL_YELLOW] = {   -- amazon, ghoul, etc.
    [1] = { -- 1 Mago
      {id = 7620, chance = 10, maxCount = 3}, -- 7620 pocion de mana
      {id = 7589, chance = 5, maxCount = 1}, -- 7589 pocion fuerte de mana
      {id = 2114, chance = 5, maxCount = 1}, -- 2114 hucha
    },
    [2] = { -- 2 Druida
      {id = 7620, chance = 10, maxCount = 3}, -- 7620 pocion de mana
      {id = 7589, chance = 5, maxCount = 1}, -- 7589 pocion fuerte de mana
      {id = 2114, chance = 5, maxCount = 1}, -- 2114 hucha
    },
    [3] = { -- 3 Paladino
      {id = 7618, chance = 10, maxCount = 2}, -- 7618 pocion de vida
      {id = 7620, chance = 10, maxCount = 1}, -- 7620 pocion de mana
      {id = 7588, chance = 5, maxCount = 1}, -- 7588 pocion fuerte de vida
      {id = 2114, chance = 5, maxCount = 1}, -- 2114 hucha
    },
    [4] = { --  4 Caballeros
      {id = 7618, chance = 10, maxCount = 3}, -- 7618 pocion de vida
      {id = 7588, chance = 5, maxCount = 1}, -- 7588 pocion fuerte de vida
      {id = 2114, chance = 5, maxCount = 1}, -- 2114 hucha
    },
    [5] = { -- 1 Mago Maestro
      {id = 7620, chance = 10, maxCount = 3}, -- 7618 pocion de vida / 7620 pocion de mana
      {id = 7589, chance = 5, maxCount = 1}, -- 7589 pocion fuerte de mana
      {id = 2114, chance = 5, maxCount = 1}, -- 2114 hucha
    },
    [6] = { -- 2 Druida Erudito
      {id = 7620, chance = 10, maxCount = 3}, -- 7620 pocion de mana
      {id = 7589, chance = 5, maxCount = 1}, -- 7589 pocion fuerte de mana
      {id = 2114, chance = 5, maxCount = 1}, -- 2114 hucha
    },
    [7] = { -- 3 Paladino Real
      {id = 7618, chance = 10, maxCount = 2}, -- 7618 pocion de vida
      {id = 7620, chance = 10, maxCount = 1}, -- 7620 pocion de mana
      {id = 7588, chance = 5, maxCount = 1}, -- 7588 pocion fuerte de vida
      {id = 2114, chance = 5, maxCount = 1}, -- 2114 hucha
    },
    [8] = { -- 4 Caballero Elites
      {id = 7618, chance = 10, maxCount = 3}, -- 7618 pocion de vida
      {id = 7588, chance = 5, maxCount = 1}, -- 7588 pocion fuerte de vida
      {id = 2114, chance = 5, maxCount = 1}, -- 2114 hucha
    },
  },
    [SKULL_WHITE] = {
    [1] = { -- 1 Mago
      {id = 7589, chance = 15, maxCount = 3}, -- 7589 pocion fuerte de mana
      {id = 7590, chance = 10, maxCount = 1}, -- 7590 pocion grande de mana
      {id = 2114, chance = 20, maxCount = 1}, -- 2114 hucha
    },
    [2] = { -- 2 Druida
      {id = 7589, chance = 15, maxCount = 3}, -- 7589 pocion fuerte de mana
      {id = 7590, chance = 10, maxCount = 1}, -- 7590 pocion grande de mana
      {id = 2114, chance = 20, maxCount = 1}, -- 2114 hucha
    },
    [3] = { -- 3 Paladino
      {id = 7588, chance = 15, maxCount = 2}, -- 7588 pocion fuerte de vida
      {id = 7589, chance = 15, maxCount = 1}, -- 7589 pocion fuerte de mana
      {id = 8472, chance = 10, maxCount = 1}, -- 8472 pocion grande de espiritu
      {id = 2114, chance = 20, maxCount = 1}, -- 2114 hucha
    },
    [4] = { --  4 Caballeros
      {id = 7588, chance = 15, maxCount = 3}, -- 7588 pocion fuerte de vida
      {id = 7591, chance = 10, maxCount = 1}, -- 7591 pocion grande de vida
      {id = 2114, chance = 20, maxCount = 1}, -- 2114 hucha
    },
    [5] = { -- 1 Mago Maestro
      {id = 7589, chance = 15, maxCount = 3}, -- 7589 pocion fuerte de mana
      {id = 7590, chance = 10, maxCount = 1}, -- 7590 pocion grande de mana
      {id = 2114, chance = 20, maxCount = 1}, -- 2114 hucha
    },
    [6] = { -- 2 Druida Erudito
      {id = 7589, chance = 15, maxCount = 3}, -- 7589 pocion fuerte de mana
      {id = 7590, chance = 10, maxCount = 1}, -- 7590 pocion grande de mana
      {id = 2114, chance = 20, maxCount = 1}, -- 2114 hucha
    },
    [7] = { -- 3 Paladino Real
      {id = 7588, chance = 15, maxCount = 2}, -- 7588 pocion fuerte de vida
      {id = 7589, chance = 15, maxCount = 1}, -- 7589 pocion fuerte de mana
      {id = 8472, chance = 10, maxCount = 1}, -- 8472 pocion grande de espiritu
      {id = 2114, chance = 20, maxCount = 1}, -- 2114 hucha
    },
    [8] = { -- 4 Caballero Elites
      {id = 7588, chance = 15, maxCount = 3}, -- 7588 pocion fuerte de vida
      {id = 7591, chance = 10, maxCount = 1}, -- 7591 pocion grande de vida
      {id = 2114, chance = 20, maxCount = 1}, -- 2114 hucha
    },
  },
    [SKULL_RED] = {
    [1] = { -- 1 Mago
      {id = 7590, chance = 30, maxCount = 3}, -- 7590 pocion grande de mana
      {id = 12784, chance = 20, maxCount = 1}, -- 12784 ultimate mana rune
      {id = 2114, chance = 40, maxCount = 1}, -- 2114 hucha
    },
    [2] = { -- 2 Druida
      {id = 7590, chance = 30, maxCount = 3}, -- 7590 pocion grande de mana
      {id = 12784, chance = 20, maxCount = 1}, -- 12784 ultimate mana rune
      {id = 2114, chance = 40, maxCount = 1}, -- 2114 hucha
    },
    [3] = { -- 3 Paladino
      {id = 8472, chance = 30, maxCount = 3}, -- 8472 pocion grande de espiritu
      {id = 12786, chance = 20, maxCount = 1}, -- 12786 ultimate spirit rune
      {id = 2114, chance = 40, maxCount = 1}, -- 2114 hucha
    },
    [4] = { -- 4 Caballeros
      {id = 7591, chance = 30, maxCount = 3}, -- 7591 pocion grande de vida
      {id = 8473, chance = 20, maxCount = 1}, -- 8473 pocion ultima de vida
      {id = 2114, chance = 40, maxCount = 1}, -- 2114 hucha
    },
    [5] = { -- 1 Mago Maestro
      {id = 7590, chance = 30, maxCount = 3}, -- 7590 pocion grande de mana
      {id = 12784, chance = 20, maxCount = 1}, -- 12784 ultimate mana rune
      {id = 2114, chance = 40, maxCount = 1}, -- 2114 hucha
    },
    [6] = { -- 2 Druida Erudito
      {id = 7590, chance = 30, maxCount = 3}, -- 7590 pocion grande de mana
      {id = 12784, chance = 20, maxCount = 1}, -- 12784 ultimate mana rune
      {id = 2114, chance = 40, maxCount = 1}, -- 2114 hucha
    },
    [7] = { -- 3 Paladino Real
      {id = 8472, chance = 30, maxCount = 3}, -- 8472 pocion grande de espiritu
      {id = 12786, chance = 20, maxCount = 1}, -- 12786 ultimate spirit rune
      {id = 2114, chance = 40, maxCount = 1}, -- 2114 hucha
    },
    [8] = { -- 4 Caballero Elites
      {id = 7591, chance = 30, maxCount = 3}, -- 7591 pocion grande de vida
      {id = 8473, chance = 20, maxCount = 1}, -- 8473 pocion ultima de vida
      {id = 2114, chance = 40, maxCount = 1}, -- 2114 hucha
    },
  },
    [SKULL_BLACK] = {
    [1] = { -- 1 Mago
      {id = 12784, chance = 40, maxCount = 3}, -- 12784 ultimate mana rune
      {id = 2114, chance = 60, maxCount = 1}, --- 2114 hucha
    },
    [2] = { -- 2 Druida
      {id = 12784, chance = 40, maxCount = 3}, -- 12784 ultimate mana rune
      {id = 2114, chance = 60, maxCount = 1}, --- 2114 hucha
    },
    [3] = { -- 3 Paladino
      {id = 12786, chance = 40, maxCount = 3}, -- 12786 ultimate spirit rune
      {id = 2114, chance = 60, maxCount = 1}, --- 2114 hucha
    },
    [4] = { --  4 Caballeros
      {id = 12785, chance = 40, maxCount = 3}, -- 12785 pocion suprema de vida
      {id = 2114, chance = 60, maxCount = 1}, --- 2114 hucha
    },
    [5] = { -- 1 Mago Maestro
      {id = 12784, chance = 40, maxCount = 3}, -- 12784 ultimate mana rune
      {id = 2114, chance = 60, maxCount = 1}, --- 2114 hucha
    },
    [6] = { -- 2 Druida Erudito
      {id = 12784, chance = 40, maxCount = 3}, -- 12784 ultimate mana rune
      {id = 2114, chance = 60, maxCount = 1}, --- 2114 hucha
    },
    [7] = { -- 3 Paladino Real
      {id = 12786, chance = 40, maxCount = 3}, -- 12786 ultimate spirit rune
      {id = 2114, chance = 60, maxCount = 1}, --- 2114 hucha
    },
    [8] = { -- 4 Caballero Elites
      {id = 12785, chance = 40, maxCount = 3}, -- 12785 pocion suprema de vida
      {id = 2114, chance = 60, maxCount = 1}, --- 2114 hucha
    },
  },
}

local function getRandomItem(list)
  for e, entry in pairs(list) do
    if math.random(maxChance) <= entry.chance then
      return entry
    end
  end
end

local ignore_list = {
  'Morgarot','Ghazbaran','Orshabaal','Ferumbras'
}
 
local ec = EventCallback
 
function ec.onDropLoot(monster, corpse)
  if not corpse or not corpse:getType():isContainer() or corpse:getEmptySlots() < 1 then
    return true
  end
  -- ignore list
  if table.find(ignore_list,monster:getName(),true) then return true end
  -- get mob skull and voc list
  local skull = monster:getSkull()
  local vocations = config[skull]
  if not vocations then return true end
  -- get corpse owner
  local player = Player(corpse:getCorpseOwner())
  if not player then return true end
  -- get owner vocation
  local pVoc = player:getVocation():getId()
  -- get possible items
  local items = vocations[pVoc]
  if not items then return true end
  -- get a random item in the list
  local item = getRandomItem(items)
  if not item then return true end
  -- get random amount
  local count = item.maxCount and math.random(item.maxCount) or 1
  -- add item in corpse
  corpse:addItem(item.id, count)
  monster:say("Has encontrado algo.", TALKTYPE_MONSTER_SAY)
  --print("Added extra loot.")
  -- the end
  return true
end
 
ec:register(666)
 
Solution
I've never seen table.find before..

Why not just use table.contains ?

if table.contains(ignore_list, monster:getName()) then return true end
I've never seen table.find before..

Why not just use table.contains ?

if table.contains(ignore_list, monster:getName()) then return true end
Thanks! It started to work again. So weird that I had this script running like this for so long and just now started to throw an error. xD
 
Back
Top