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

Solved Attempt to index itemType on NPC

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,557
Solutions
28
Reaction score
881
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi! I don't know what i'm doing wrong here. I already managed to add atributes to items from chests (onUse), and other NPCs too, but in this case, it doesn't let me add the roll atribute that comes from other system (oen's upgrade system). For this I tried:

Lua:
local function addFocus(cid)
    choice[cid] = nil
    return true
end

local function releaseFocus(cid)
    choice[cid] = nil
    return true
end

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    local price_vortex = 500
    if msgcontains(msg, "vortice") or msgcontains(msg, "vortex") then
        npcHandler:say("Puedo hacer una varita de vortice. ¿Quieres comerciar?", cid)
        npcHandler.topic[cid] = 1
    elseif msgcontains(msg, "yes") or msgcontains(msg, "si") and npcHandler.topic[cid] == 1 then
        if player:removeMoney(price_vortex) then
            npcHandler:say("Aquí tienes.", cid)
            --player:addItem(6529, 6)
            local vortexItem = player:addItem(2190,1)
            vortexItem:setItemLevel(8, false)
            vortexItem:setRarity(COMMON)
            vortexItem:rollAttribute(player, itemType, weaponType, true)
        else
            npcHandler:say("No tienes suficiente dinero contigo.", cid)
        end
        npcHandler.topic[cid] = 0
    end
    return true
end

And for some reason, this line
Lua:
vortexItem:rollAttribute(player, itemType, weaponType, true)
is returning me a nil value on itemType. Why is that happening? Tried to define itemType as local variable but couldn't make it work.

1714190725595.png

Thanks in advance!
Post automatically merged:

Solved with
Lua:
vortexItem:rollAttribute(player, vortexItem:getType(), vortexItem:getType():getWeaponType(), true)

Or commenting this from oen's system (I don't use upgradable or unique items, so, I think this line can be gone)
Lua:
  if not itemType:isUpgradable() or self:isUnique() then
        return false
    end
 
Last edited:
Back
Top