• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

error timer event creaturescript onDeath tfs 0.3

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
923
Location
Chile
Hello guys, im having this recurrent error in console, idk why, i have checked my creaturescript but i don't see anything suspicios, could you help me fix this plz?? im tfs 0.3

Code:
[24/5/2017 18:27:28] [Error - CreatureScript Interface]
[24/5/2017 18:27:28] In a timer event called from:
[24/5/2017 18:27:28] domodlib('Loot_func')
[24/5/2017 18:27:28]         function onDeath(cid, corpse, deathList)
[24/5/2017 18:27:28]         local killer,pos = deathList[1],getCreaturePosition(cid)
[24/5/2017 18:27:29]         addEvent(corpseRetireItems,1,killer,pos)
[24/5/2017 18:27:29] return true
[24/5/2017 18:27:29] end:onDeath
[24/5/2017 18:27:29] Description:
[24/5/2017 18:27:29] (LuaInterface::luaGetCreatureStorage) Creature not found
 
Solution
LUA:
<event type="death" name="LootEventDeath" event="script"><![CDATA[
    domodlib('Loot_func')
    function onDeath(cid, corpse, deathList)
        if not isCreature(cid) then
            return false
        end
        local creature = nil
         for _, x in pairs(deathList) do
             if isCreature(x) then
                 creature = x
                 break
             end
         end
         if creature then
            addEvent(corpseRetireItems, 1, creature, getCreaturePosition(cid))
        end
        return true
    end
]]></event>
Post the code, use notepad++ and press ctrl+f (serach in files)
Serach after: local killer,pos = deathList[1],getCreaturePosition(cid)
Folder: (navigate to your server folder)
Then hit serach all
 
Post the code, use notepad++ and press ctrl+f (serach in files)
Serach after: local killer,pos = deathList[1],getCreaturePosition(cid)
Folder: (navigate to your server folder)
Then hit serach all
wait what?? I don't know what code is generating this problem, and i search and i get no results, where is search all? it's possible to seach a piece of code among all the files?
gTDwyUu.png
 
File called "loot_func" (probably)

In function onDeath, it couldnt find the creature that is the script about
 
File called "loot_func" (probably)

In function onDeath, it couldnt find the creature that is the script about

In 99% of the cases with mods the "loadlib" could be an internal function in the script, the file name could be X but loot_func could be called in that script :p

Best is to use NOTEPAD++ :D (or any other search programs) and find the script, the search function in (atleast) with windows 7 won't find things in XML files for some reason.
But if you don't have notepad++ or something like it and don't wanna download it, go to server path/mods and serach in each of the files till you find that function.
 
mBH9Jih.png


that's all i got



WibbenZ i do have notepad++ but i don't understand how to use the search you said

Then post that script, best would be to serach for the function I posted, diffrent functions could have the same name and give false positives (I can only see 1 result in the pic so should be the correct script in this case)
 
Then post that script, best would be to serach for the function I posted, diffrent functions could have the same name and give false positives (I can only see 1 result in the pic so should be the correct script in this case)
Ok here it is :D actually it was edited recently in this support section but didn't work as expected, now i guess this error is because of that editing
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Loot System" version="1.0" author="Vodkart And Mkalo" contact="none.com" enabled="yes">
<config name="Loot_func"><![CDATA[
                info = {
                        -- OnlyPremium = true, -- not going to use this at all
                        AutomaticDeposit = true,
                        BlockMonsters = {},
                        BlockItemsList = {2123,2515}
                        }
function setPlayerStorageTable(cid, storage, tab)
    local tabstr = "&"
    for i,x in pairs(tab) do
            tabstr = tabstr .. i .. "," .. x .. ";"
    end
    setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
end
function getPlayerStorageTable(cid, storage)
    local tabstr = getPlayerStorageValue(cid, storage)
    local tab = {}
    if type(tabstr) ~= "string" then
            return {}
    end
    if tabstr:sub(1,1) ~= "&" then
            return {}
    end
    local tabstr = tabstr:sub(2, #tabstr)
    local a = string.explode(tabstr, ";")
    for i,x in pairs(a) do
            local b = string.explode(x, ",")
            tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
    end
    return tab
end
function ExistItemByName(name) -- by vodka
    local items = io.open("data/items/items.xml", "r"):read("*all")
    local get = items:match('name="' .. name ..'"')
    if get == nil or get == "" then
        return false
    end
return true
end
function isInTable(cid, item)
         for _,i in pairs(getPlayerStorageTable(cid, 27000))do
             if tonumber(i) == tonumber(item) then
                return true
             end
         end
return false
end
function addItemTable(cid, item)
         local x = {}
               for i = 1,#getPlayerStorageTable(cid, 27000) do
                   table.insert(x,getPlayerStorageTable(cid, 27000)[i])
               end
               if x ~= 0 then
                  table.insert(x,tonumber(item))
                  setPlayerStorageTable(cid, 27000, x)
               else
                   setPlayerStorageTable(cid, 27000, {item})
               end
end
function removeItemTable(cid, item)
         local x = {}
               for i = 1,#getPlayerStorageTable(cid, 27000) do
                   table.insert(x,getPlayerStorageTable(cid, 27000)[i])
               end
               for i,v in ipairs(x) do
                   if tonumber(v) == tonumber(item) then
                   table.remove(x,i)
               end
               end
         return setPlayerStorageTable(cid, 27000, x)
end
function ShowItemsTabble(cid)
local str,n = "-- My Loot List --\n\n",0
for i = 1,#getPlayerStorageTable(cid, 27000) do
n = n + 1
str = str..""..n.." - "..getItemNameById(getPlayerStorageTable(cid, 27000)[i]).."\n"
end
return doShowTextDialog(cid, 2529, str)
end
function getContainerItems(containeruid)
    local items = {}
    local containers = {}
    if type(getContainerSize(containeruid)) ~= "number" then
            return false
    end
    for slot = 0, getContainerSize(containeruid)-1 do
            local item = getContainerItem(containeruid, slot)
            if item.itemid == 0 then
                    break
            end
            if isContainer(item.uid) then
                    table.insert(containers, item.uid)
            end
            table.insert(items, item)
    end
    if #containers > 0 then
            for i,x in ipairs(getContainerItems(containers[1])) do
                    table.insert(items, x)
            end
            table.remove(containers, 1)
    end
    return items
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
            local items = {}
            if isContainer(container) and getContainerSize(container) > 0 then
                            for slot=0, (getContainerSize(container)-1) do
                                            local item = getContainerItem(container, slot)
                                            if isContainer(item.uid) then
                                                            local itemsbag = getItemsInContainerById(item.uid, itemid)
                                                            for i=0, #itemsbag do
                                                                            table.insert(items, itemsbag[i])
                                                            end
                                            else
                                                            if itemid == item.itemid then
                                                                            table.insert(items, item.uid)
                                                            end
                                            end
                            end
            end
            return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
    local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
    local piles = 0
    if #item > 0 then
            for i,x in pairs(item) do
                    if getThing(x).type < 100 then
                            local it = getThing(x)
                            doTransformItem(it.uid, itemid, it.type+quant)
                            if it.type+quant > 100 then
                                    doPlayerAddItem(cid, itemid, it.type+quant-100)
                            end
                    else
                           piles = piles+1
                    end
            end
    else
            return doPlayerAddItem(cid, itemid, quant)
    end
    if piles == #item then
            doPlayerAddItem(cid, itemid, quant)
    end
end
function AutomaticDeposit(cid,item,n)
local deposit = item == tonumber(2160) and (n*10000) or tonumber(item) == 2152 and (n*100) or (n*1)
return doPlayerDepositMoney(cid, deposit)
end
function corpseRetireItems(cid, pos)
        local check = false
        for i = 0, 255 do
        pos.stackpos = i
        tile = getTileThingByPos(pos)
                if tile.uid > 0 and isCorpse(tile.uid) then
                        check = true break
                end
end
                if check == true then
                local items = getContainerItems(tile.uid)
                        for i,x in pairs(items) do
                                if isInArray(getPlayerStorageTable(cid, 27000), tonumber(x.itemid)) then
                                        if isItemStackable(x.itemid) then
                                                doPlayerAddItemStacking(cid, x.itemid, x.type)
                                                if info.AutomaticDeposit == true and isInArray({"2148","2152","2160"},tonumber(x.itemid)) then
                                                AutomaticDeposit(cid,x.itemid,x.type)
                                                end
                                        else
                                                doPlayerAddItem(cid, x.itemid)
                                        end
                                                doRemoveItem(x.uid)
                                end
                        end
                end
end
]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "MonsterAttack")
return true
end]]></event>
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
        function onDeath(cid, corpse, deathList)
        local killer,pos = deathList[1],getCreaturePosition(cid)
        addEvent(corpseRetireItems,1,killer,pos)
return true
end]]></event>
<event type="combat" name="MonsterAttack" event="script"><![CDATA[
domodlib('Loot_func')
                if isPlayer(cid) and isMonster(target) and not isInArray(info.BlockMonsters,string.lower(getCreatureName(target))) then
                        registerCreatureEvent(target, "LootEventDeath")
                                end
return true]]></event>
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
local t = string.explode(string.lower(param), ",")
-- lets just check to see if the player is premium, vip
if getPlayerStatus(cid) then
    doPlayerSendCancel(cid, "you must be a premium account.") return true
elseif not t[1] then
    ShowItemsTabble(cid) return true
elseif tonumber(t[1]) or tonumber(t[2]) then
    doPlayerSendCancel(cid, "enter!autoloot add,name or !autoloot remove,name") return true
elseif isInArray({"add","remove"}, tostring(t[1])) then
    local func,check = tostring(t[1]) == "add" and addItemTable or removeItemTable, tostring(t[1]) == "add" and true or false
    local item = ExistItemByName(tostring(t[2]))
    if not item then
        doPlayerSendCancel(cid, "This item does not exist.") return true
    end
    local itemlist = getItemIdByName(tostring(t[2]))
    if check == true and isInArray(info.BlockItemsList, itemlist) then
        doPlayerSendCancel(cid, "You can not add this item in the list!") return true
    elseif isInTable(cid, itemlist) == check then
        doPlayerSendCancel(cid, "This Item "..(check == true and "already" or "is not").." in your list.") return true
    end
    func(cid, itemlist)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "you added the item "..t[2].." in the list" or "you removed the item "..t[2].." from the list") return true
end
return true]]></talkaction>
</mod>
 
Ok here it is :D actually it was edited recently in this support section but didn't work as expected, now i guess this error is because of that editing
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Loot System" version="1.0" author="Vodkart And Mkalo" contact="none.com" enabled="yes">
<config name="Loot_func"><![CDATA[
                info = {
                        -- OnlyPremium = true, -- not going to use this at all
                        AutomaticDeposit = true,
                        BlockMonsters = {},
                        BlockItemsList = {2123,2515}
                        }
function setPlayerStorageTable(cid, storage, tab)
    local tabstr = "&"
    for i,x in pairs(tab) do
            tabstr = tabstr .. i .. "," .. x .. ";"
    end
    setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
end
function getPlayerStorageTable(cid, storage)
    local tabstr = getPlayerStorageValue(cid, storage)
    local tab = {}
    if type(tabstr) ~= "string" then
            return {}
    end
    if tabstr:sub(1,1) ~= "&" then
            return {}
    end
    local tabstr = tabstr:sub(2, #tabstr)
    local a = string.explode(tabstr, ";")
    for i,x in pairs(a) do
            local b = string.explode(x, ",")
            tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
    end
    return tab
end
function ExistItemByName(name) -- by vodka
    local items = io.open("data/items/items.xml", "r"):read("*all")
    local get = items:match('name="' .. name ..'"')
    if get == nil or get == "" then
        return false
    end
return true
end
function isInTable(cid, item)
         for _,i in pairs(getPlayerStorageTable(cid, 27000))do
             if tonumber(i) == tonumber(item) then
                return true
             end
         end
return false
end
function addItemTable(cid, item)
         local x = {}
               for i = 1,#getPlayerStorageTable(cid, 27000) do
                   table.insert(x,getPlayerStorageTable(cid, 27000)[i])
               end
               if x ~= 0 then
                  table.insert(x,tonumber(item))
                  setPlayerStorageTable(cid, 27000, x)
               else
                   setPlayerStorageTable(cid, 27000, {item})
               end
end
function removeItemTable(cid, item)
         local x = {}
               for i = 1,#getPlayerStorageTable(cid, 27000) do
                   table.insert(x,getPlayerStorageTable(cid, 27000)[i])
               end
               for i,v in ipairs(x) do
                   if tonumber(v) == tonumber(item) then
                   table.remove(x,i)
               end
               end
         return setPlayerStorageTable(cid, 27000, x)
end
function ShowItemsTabble(cid)
local str,n = "-- My Loot List --\n\n",0
for i = 1,#getPlayerStorageTable(cid, 27000) do
n = n + 1
str = str..""..n.." - "..getItemNameById(getPlayerStorageTable(cid, 27000)[i]).."\n"
end
return doShowTextDialog(cid, 2529, str)
end
function getContainerItems(containeruid)
    local items = {}
    local containers = {}
    if type(getContainerSize(containeruid)) ~= "number" then
            return false
    end
    for slot = 0, getContainerSize(containeruid)-1 do
            local item = getContainerItem(containeruid, slot)
            if item.itemid == 0 then
                    break
            end
            if isContainer(item.uid) then
                    table.insert(containers, item.uid)
            end
            table.insert(items, item)
    end
    if #containers > 0 then
            for i,x in ipairs(getContainerItems(containers[1])) do
                    table.insert(items, x)
            end
            table.remove(containers, 1)
    end
    return items
end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
            local items = {}
            if isContainer(container) and getContainerSize(container) > 0 then
                            for slot=0, (getContainerSize(container)-1) do
                                            local item = getContainerItem(container, slot)
                                            if isContainer(item.uid) then
                                                            local itemsbag = getItemsInContainerById(item.uid, itemid)
                                                            for i=0, #itemsbag do
                                                                            table.insert(items, itemsbag[i])
                                                            end
                                            else
                                                            if itemid == item.itemid then
                                                                            table.insert(items, item.uid)
                                                            end
                                            end
                            end
            end
            return items
end
function doPlayerAddItemStacking(cid, itemid, quant) -- by mkalo
    local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
    local piles = 0
    if #item > 0 then
            for i,x in pairs(item) do
                    if getThing(x).type < 100 then
                            local it = getThing(x)
                            doTransformItem(it.uid, itemid, it.type+quant)
                            if it.type+quant > 100 then
                                    doPlayerAddItem(cid, itemid, it.type+quant-100)
                            end
                    else
                           piles = piles+1
                    end
            end
    else
            return doPlayerAddItem(cid, itemid, quant)
    end
    if piles == #item then
            doPlayerAddItem(cid, itemid, quant)
    end
end
function AutomaticDeposit(cid,item,n)
local deposit = item == tonumber(2160) and (n*10000) or tonumber(item) == 2152 and (n*100) or (n*1)
return doPlayerDepositMoney(cid, deposit)
end
function corpseRetireItems(cid, pos)
        local check = false
        for i = 0, 255 do
        pos.stackpos = i
        tile = getTileThingByPos(pos)
                if tile.uid > 0 and isCorpse(tile.uid) then
                        check = true break
                end
end
                if check == true then
                local items = getContainerItems(tile.uid)
                        for i,x in pairs(items) do
                                if isInArray(getPlayerStorageTable(cid, 27000), tonumber(x.itemid)) then
                                        if isItemStackable(x.itemid) then
                                                doPlayerAddItemStacking(cid, x.itemid, x.type)
                                                if info.AutomaticDeposit == true and isInArray({"2148","2152","2160"},tonumber(x.itemid)) then
                                                AutomaticDeposit(cid,x.itemid,x.type)
                                                end
                                        else
                                                doPlayerAddItem(cid, x.itemid)
                                        end
                                                doRemoveItem(x.uid)
                                end
                        end
                end
end
]]></config>
<event type="login" name="LootLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "MonsterAttack")
return true
end]]></event>
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
        function onDeath(cid, corpse, deathList)
        local killer,pos = deathList[1],getCreaturePosition(cid)
        addEvent(corpseRetireItems,1,killer,pos)
return true
end]]></event>
<event type="combat" name="MonsterAttack" event="script"><![CDATA[
domodlib('Loot_func')
                if isPlayer(cid) and isMonster(target) and not isInArray(info.BlockMonsters,string.lower(getCreatureName(target))) then
                        registerCreatureEvent(target, "LootEventDeath")
                                end
return true]]></event>
<talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
domodlib('Loot_func')
local t = string.explode(string.lower(param), ",")
-- lets just check to see if the player is premium, vip
if getPlayerStatus(cid) then
    doPlayerSendCancel(cid, "you must be a premium account.") return true
elseif not t[1] then
    ShowItemsTabble(cid) return true
elseif tonumber(t[1]) or tonumber(t[2]) then
    doPlayerSendCancel(cid, "enter!autoloot add,name or !autoloot remove,name") return true
elseif isInArray({"add","remove"}, tostring(t[1])) then
    local func,check = tostring(t[1]) == "add" and addItemTable or removeItemTable, tostring(t[1]) == "add" and true or false
    local item = ExistItemByName(tostring(t[2]))
    if not item then
        doPlayerSendCancel(cid, "This item does not exist.") return true
    end
    local itemlist = getItemIdByName(tostring(t[2]))
    if check == true and isInArray(info.BlockItemsList, itemlist) then
        doPlayerSendCancel(cid, "You can not add this item in the list!") return true
    elseif isInTable(cid, itemlist) == check then
        doPlayerSendCancel(cid, "This Item "..(check == true and "already" or "is not").." in your list.") return true
    end
    func(cid, itemlist)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,check == true and "you added the item "..t[2].." in the list" or "you removed the item "..t[2].." from the list") return true
end
return true]]></talkaction>
</mod>

LUA:
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
        function onDeath(cid, corpse, deathList)
        local killer,pos = deathList[1],getCreaturePosition(cid)
        addEvent(corpseRetireItems,1,killer,pos)
return true
end]]></event>

Try to add an isCreature(cid) if statment after function onDeath, if it's false return false.
 
LUA:
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
        function onDeath(cid, corpse, deathList)
        local killer,pos = deathList[1],getCreaturePosition(cid)
        addEvent(corpseRetireItems,1,killer,pos)
return true
end]]></event>

Try to add an isCreature(cid) if statment after function onDeath, if it's false return false.
you are testing me sir D: cos i abrely know how to code
like this?
LUA:
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
        function onDeath(cid, corpse, deathList)
isCreature(cid) if false
return true
        local killer,pos = deathList[1],getCreaturePosition(cid)
        addEvent(corpseRetireItems,1,killer,pos)
return true
end]]></event>
 
you are testing me sir D: cos i abrely know how to code
like this?
LUA:
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
        function onDeath(cid, corpse, deathList)
isCreature(cid) if false
return true
        local killer,pos = deathList[1],getCreaturePosition(cid)
        addEvent(corpseRetireItems,1,killer,pos)
return true
end]]></event>

Well you are getting there :)
LUA:
if not statment then
     return boolean
end

rest of our code (should only be called if there is a creature)

Our statment is isCreature(cid)
Our boolean(a true of false value) is in this case false
 
Well you are getting there :)
LUA:
if not statment then
     return boolean
end

rest of our code (should only be called if there is a creature)

Our statment is isCreature(cid)
Our boolean(a true of false value) is in this case false
Ok i'm sorry you lost me man :(
 
LUA:
function onX(a)
     if not isCreature(a) then
          return false
     end

     doCreatureSomethingSomething(a)
     return true
end
Ok so like this??
LUA:
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
        function onDeath(cid, corpse, deathList)
[LIST=1]
[*]function onX(a)
[*]     if not isCreature(a) then
[*]          return false
[*]     end
[*]

[*]     doCreatureSomethingSomething(a)
[*]     return true
[*]end
[/LIST]
        local killer,pos = deathList[1],getCreaturePosition(cid)
        addEvent(corpseRetireItems,1,killer,pos)
return true
end]]></event>

without the numbers ofc
 
Ok so like this??
LUA:
<event type="death" name="LootEventDeath" event="script"><![CDATA[
domodlib('Loot_func')
        function onDeath(cid, corpse, deathList)
[LIST=1]
[*]function onX(a)
[*]     if not isCreature(a) then
[*]          return false
[*]     end
[*]

[*]     doCreatureSomethingSomething(a)
[*]     return true
[*]end
[/LIST]
        local killer,pos = deathList[1],getCreaturePosition(cid)
        addEvent(corpseRetireItems,1,killer,pos)
return true
end]]></event>

without the numbers ofc

No that was an example of how you should do it :P
Compare the code you wrote to this;
LUA:
<event type="death" name="LootEventDeath" event="script"><![CDATA[
    domodlib('Loot_func')
    function onDeath(cid, corpse, deathList)
        if not isCreature(cid) then
            return false
        end

        addEvent(corpseRetireItems, 1, deathList[1], getCreaturePosition(cid))
        return true
    end
]]></event>
 
No that was an example of how you should do it :p
Compare the code you wrote to this;
LUA:
<event type="death" name="LootEventDeath" event="script"><![CDATA[
    domodlib('Loot_func')
    function onDeath(cid, corpse, deathList)
        if not isCreature(cid) then
            return false
        end

        addEvent(corpseRetireItems, 1, deathList[1], getCreaturePosition(cid))
        return true
    end
]]></event>

And if this does not work I would probably say that deathList[1] does not exist? But I'm only guessing here, not sure what happens in lua when you try to access out of bounds index of an array.
 
LUA:
<event type="death" name="LootEventDeath" event="script"><![CDATA[
    domodlib('Loot_func')
    function onDeath(cid, corpse, deathList)
        if not isCreature(cid) then
            return false
        end
        local creature = nil
         for _, x in pairs(deathList) do
             if isCreature(x) then
                 creature = x
                 break
             end
         end
         if creature then
            addEvent(corpseRetireItems, 1, creature, getCreaturePosition(cid))
        end
        return true
    end
]]></event>
 
Solution
And if this does not work I would probably say that deathList[1] does not exist? But I'm only guessing here, not sure what happens in lua when you try to access out of bounds index of an array.

Nice catch ;)
Didn't even notice that haha
 
Back
Top