• 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 Error on getThingFromPos autoloot Cr

Rebine

New Member
Joined
Feb 10, 2010
Messages
69
Reaction score
2
Location
Chile
HellO! I have this creaturescript:
Code:
local stor = 7590
function autoloot(cid, target, pos)
    if not isPlayer(cid) then
        return
    end
 
    local function scanContainer(cid, uid, list)
        for k = (getContainerSize(uid) - 1), 0, -1 do
            local tmp = getContainerItem(uid, k)
            if (isInArray(list, tmp.itemid)) then
    local item = doCreateItemEx(tmp.itemid, tmp.type)
            doPlayerAddItemEx(cid, item, true)
                doRemoveItem(tmp.uid)
            elseif isContainer(tmp.uid) then
                scanContainer(cid, tmp.uid, list)
            end
        end
    end
    local items = {}
    for i = getTileInfo(pos).items, 1, -1 do
        pos.stackpos = i
        items[i] = getThingFromPos(pos)
    end
    if (#items == 0) then
        return
    end
    local corpse = -1
    for _, item in pairs(items) do
        if not isCreature(item.uid) then
            local name = getItemName(item.uid):lower()
            if name:find(target:lower()) then
                corpse = item.uid
                break
            end
        end
    end
    if (corpse ~= -1) and isContainer(corpse) and (getItemAttribute(corpse, "corpseowner") == getPlayerGUID(cid)) then
        scanContainer(cid, corpse, tostring(getPlayerStorageValue(cid, stor)):gsub('_', ''):explode(','))
    end
end
function onKill(cid, target, lastHit)
    if not isPlayer(target) then
        local infos = getPlayerStorageValue(cid, stor)
        if (infos == -1) then
            return true
        end
        local list = tostring(infos):explode(',')
        if (#list == 0) then
            return true
        end

local puta = getCreatureName(target)
local par = string.explode(puta, " ")
if isInArray(pokesOutland, puta) then
puta = par[2]
end

        addEvent(autoloot, 150, cid, puta, getCreaturePosition(target))
    end
    return true
end

I got sometimes these errors:
Code:
[28/6/2016 3:13:37] [Error - CreatureScript Interface]
[28/6/2016 3:13:37] In a timer event called from:
[28/6/2016 3:13:37] data/creaturescripts/scripts/autoloot.lua:onKill
[28/6/2016 3:13:37] Description:
[28/6/2016 3:13:37] (LuaInterface::luaGetThing) Thing not found

[28/6/2016 3:13:37] [Error - CreatureScript Interface]
[28/6/2016 3:13:38] In a timer event called from:
[28/6/2016 3:13:38] data/creaturescripts/scripts/autoloot.lua:onKill
[28/6/2016 3:13:38] Description:
[28/6/2016 3:13:38] data/lib/100-shortcut.lua:272: attempt to index a boolean value
[28/6/2016 3:13:38] stack traceback:
[28/6/2016 3:13:38]     data/lib/100-shortcut.lua:272: in function 'getItemName'
[28/6/2016 3:13:38]     data/creaturescripts/scripts/autoloot.lua:34: in function <data/creaturescripts/scripts/autoloot.lua:3>

What can it be?o_O
 
i assume this line gives you an error.
local name = getItemName(item.uid):lower()

use print(item.uid) before this line
 
I added the print and it prints the UID without problems, i dont know what can happen when the error appears

And..
X4mYazc.png
 
Code:
function getItemName(uid)
    return getItemDescriptions(uid).name
end

function getItemDescriptions(uid)
    local thing = getThing(uid)
    if(thing.itemid < 100) then
        return false
    end

    local item = getItemInfo(thing.itemid)
    return {
        name = getItemAttribute(uid, "name") or item.name,
        plural = getItemAttribute(uid, "pluralname") or item.plural,
        article = getItemAttribute(uid, "article") or item.article,
        special = getItemAttribute(uid, "description") or "",
        text = getItemAttribute(uid, "text") or "",
        writer = getItemAttribute(uid, "writer") or "",
        date = getItemAttribute(uid, "date") or 0
    }   
end
 
What is your TFS?
I think TFS 1.x + has function: item:getName(), instead of making the constructor
 
Back
Top