• 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 appears this error lua script? In function getitemattribute

Rebine

New Member
Joined
Feb 10, 2010
Messages
69
Reaction score
2
Location
Chile
I want to undestood why appears this message:
Code:
[8/6/2016 22:25:44] [Error - Action Interface]
[8/6/2016 22:25:44] In a timer event called from:
[8/6/2016 22:25:44] data/actions/scripts/Testing.lua:onUse
[8/6/2016 22:25:44] Description:
[8/6/2016 22:25:44] (LuaInterface::luaGetItemAttribute) Item not found

If i use this script "X" and this function "X"

testing.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

if getPlayerSlotItem(cid, 8).uid ~= 0 then
addEvent(doPene,500,cid,getPlayerSlotItem(cid, 8).uid)
end


return true
end

function
Code:
function doPene(cid, iten)
if not isCreature(cid) then return true end
if getItemAttribute(iten, "poke") then
local confuse = getItemAttribute(iten, "poke")
if iten ~= 0 then
doCreatureSay(cid,confuse,TALKTYPE_SAY)
end
end
end

I released what if instead the addevent of testing.lua i just use
doPene(cid,getPlayerSlotItem(cid, 8).uid) it dont show any error message.

Why?

Thanks!
 
getItemAttribute returns an attribute assigned to the item, poke isn't an attribute of the item in slot 8.
Code:
function doPene(cid, item)
    local x = getItemAttribute(item, "poke")
    doCreatureSay(cid, x or "not an attribute.", TALKTYPE_SAY)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local slotItem = getPlayerSlotItem(cid, 8).uid
    if slotItem ~= 0 then
        addEvent(doPene, 500, cid, slotItem)
    end
    return true
end

You can also use this as a reference.
Code:
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
 
Last edited:
you send item.uid to doPene function, but getItemAttribute requires item userdata table, which can be gotten with Item(item.uid)
 
Look, If i USE THIS:
Code:
local function doPene(cid, item)
    local x = getItemAttribute(item, "poke")
    doCreatureSay(cid, x or "not an attribute.", TALKTYPE_SAY)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local slotItem = getPlayerSlotItem(cid, 8).uid
    if slotItem ~= 0 then
        addEvent(doPene, 1, cid, slotItem)
    end
    return true
end

The Item HAVE the attribute "poke" and it show: not an attribute and the error
[9/6/2016 16:58:15] [Error - Action Interface]
[9/6/2016 16:58:15] In a timer event called from:
[9/6/2016 16:58:15] data/actions/scripts/Testing.lua:eek:nUse
[9/6/2016 16:58:15] Description:
[9/6/2016 16:58:15] (LuaInterface::luaGetItemAttribute) Item not found

But if i use the same but without addEvent like this
Code:
local function doPene(cid, slotItem)
    local x = getItemAttribute(slotItem, "poke")
    doCreatureSay(cid, x or "not an attribute.", TALKTYPE_SAY)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local slotItem = getPlayerSlotItem(cid, 8).uid
    if slotItem ~= 0 then
        doPene(cid, slotItem)
    end
    return true
end

It works and without error.
WHY??????
 
you send item.uid to doPene function, but getItemAttribute requires item userdata table, which can be gotten with Item(item.uid)
meh this aint no 1.x distro from the scripting functions, so he certainly wont have userdata on anything :p
 
meh this aint no 1.x distro from the scripting functions, so he certainly wont have userdata on anything :p
oh shit, shouldve spent more time reading the post and not just the error... :(

you could just move everything to doPene, and just send cid, and getplayerslotitem etc in the ufunction, should work fine

try this
Code:
local function doPene(cid)
    local slotItem = getPlayerSlotItem(cid, 8).uid
    if slotItem ~= 0 then
        local x = getItemAttribute(item, "poke")
        doCreatureSay(cid, x or "not an attribute.", TALKTYPE_SAY)
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    addEvent(doPene, 1, cid)
    return true
end
 
But why is not possible to send the item.uid in a timer function ://///// My console shows this errores 100 times and lags the server i cant undestand where is produced xD !!
 
the code without addevent, does it say the attribute correctly etc? if so then theres probably something broken with addevent for some reason, you can try getting slotitem inside doPene function instead of before and sending it to it
 
Back
Top