Ir para conteúdo
  • 0

Vendedor de itens automáticos onContainer


nelsork

Pergunta

Bom dia, estou com um problema com esse script, ele funciona corretamente, mas recebo um erro no console ao tentar vender itens dentro de contêineres

 

[7/4/2020 12:59:12] [Error - Action Interface]
[7/4/2020 12:59:12] data/actions/scripts/lootbox_novalis.lua:onUse
[7/4/2020 12:59:12] Description:
[7/4/2020 12:59:12] (luaGetThing) Thing not found

alguém pode me ajudar?

 

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

Substitui o código por esse e testa:

 

local items = { 
-- you need to set up all items here where :
[2466] = {cost = 100},
[2446] = {cost = 3000},
[2470] = {cost = 4000},
}
 
 
local basin = {x=999, y=1001, z=7, stackpos = 1} -- basin pos
 
 
 
-- // SCRIPT START \\ --
 
function getContentDescription(uid, li) -- credits to Cyko for main form of this function
    local ret, i, containers,removes, left = {}, 0, {}, {}, {}
 
    while i <= getContainerSize(uid) do
        local v = getContainerItem(uid, i)
        local k = v.uid
        local k2 = v.itemid
 
        local check = items[k2]
        if check then
            table.insert(ret, k2)
            table.insert(removes,k)
        end
        if isContainer(k) then
                table.insert(containers, k)
        end
        i = i + 1
    end
    for i = 1, #containers do
        local bah = getContentDescription(containers[i], li)
        for i = 1,#bah do
            if li == 1 then
                table.insert(removes,bah[i])
            elseif li == 2 then   
                table.insert(ret,bah[i])
            end
        end
    end
    return li== 1 and removes or ret
end
 
function getKey(t)
    local s = {}
    for k,v in pairs(t) do
        table.insert(s,k)
    end
    return s
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local exist = getThingPos(basin)
local itm = getThingFromPos(basin).itemid
 
    if isContainer(exist) then
        local t = getContentDescription(exist,2)
        local t2 = getContentDescription(exist,1)
        if #t > 0 then
            local f = {}
            for i = 1,#t do
                if not isInArray(getKey(f),t[i]) then
                    f[t[i]] = 1
                else
                    f[t[i]] = f[t[i]] + 1
                end
            end
            local str = "Sold items : "
            local money = 0
            for k,v in pairs(f) do
                str = str.."\n".."•••• "..v.."x "..getItemNameById(k).." : ".. ( tonumber(items[k].cost) * tonumber(v) ) .. " gold coins."
                money = money + tonumber(items[k].cost) * tonumber(v)
 
            end
            for i = 1,#t2 do
                doRemoveItem(t2[i])
            end
            doPlayerSendTextMessage(cid,27,str)
            doPlayerAddMoney(cid,money)
            if #t > 1 then
                doPlayerSendTextMessage(cid,19," Total money : ".. money.." gold coins.")
            end
        else
            doPlayerSendTextMessage(cid,18,"Warning : Sold nothing --> either bag is empty or items included arn't sellable here.")
            doSendMagicEffect(fromPosition,2)
 
        end
    else
        local merge = items[itm]
        if not merge then
            doPlayerSendTextMessage(cid,18,"Warning : This item isn't sellable here.")
            doSendMagicEffect(fromPosition,2)
 
        else
            doRemoveItem(exist)
            doPlayerSendTextMessage(cid,27,"Sold item : \n •••• 1x "..getItemNameById(itm).." : "..merge.cost.."." )
            doPlayerAddMoney(cid,merge.cost)
        end
 
    end
    return doTransformItem(item.uid,item.uid == 1945 and 1946 or 1945)
end

Veja se ainda continua dando erro.

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...