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

attempt to call global 'getItemNameById' when say trade with NPC

Joined
Mar 14, 2020
Messages
139
Solutions
3
Reaction score
11
Hello, i'm doing a NPC that sell things for another coin. So, i got this error on my console:
distro.png

Code:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)        npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                npcHandler:onThink()                    end

local talkState = {}

function creatureSayCallback(cid, type, msg)

    if not npcHandler:isFocused(cid) then
        return false
    end
    
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local itemid = 10169 -- Novos points
local shopWindow = {}

local t = { -- [ID do item] e o preço que ele irá custar em points.
 [2260] = {price = 1}, -- blank rune
 [21394] = {price = 10}, -- explode hearth
 [6574] = {price = 100}, -- chocolate bar
 [36460] = {price = 150} -- infinity backpack
 }

 
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
    if  t[item] and getPlayerItemCount(cid, itemid) < t[item].price then
        selfSay("you do not have "..t[item].price.." Crystal Tokens.", cid)
    else
        doPlayerAddItem(cid, item)
        doPlayerRemoveItem(cid, itemid, (t[item].price))
        selfSay("Here you item", cid)
    end
    
return true
end

if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then
    for var, ret in pairs(t) do
        table.insert(shopWindow, {itemId = var, subType = 0, buy = ret.quant, sell = 0, name = getItemNameById(var)})
    end
    openShopWindow(cid, shopWindow, onBuy, onSell)
end
    
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Need help with this pls!!
 
Top