BUMP !!
NE
Vendedor de itens automáticos onContainer
Por nelsork, 07 de abr. de 2020 em Scripts
8.6
0.4
vender
script
3
1.7k
08 de abril de 2020 às 20:42
info
Grupo: Lorde
Registrado: 05/06/12
Posts: 2.2k
Reputação: +215
Gênero: Masculino

14 de abril de 2020 às 16:17
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.



info
Grupo: Campones
Registrado: 26/01/17
Posts: 3
Reputação: 0
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
alguém pode me ajudar?