Distro: TFS 9.63
Olá Xtibianos,
Pedido: Quero Criar um NPC que dê TRADE apenas com players que terminaram X Quest.
Tentativa: No meu Ot 8.60 funciona perfeitamente esse modelo abaixo:
if (getPlayerStorageValue(cid, storage) < 16 and msgcontains(msg, "trade")) then npcHandler:say("You are not able to negotiate with me, help me every day and then you can do it.", cid) elseif (getPlayerStorageValue(cid, storage) >= 16 and msgcontains(msg, "trade")) then local items = { {name="platinum amulet", id=2171, buy=0, sell=2500}, {name="ring of the sky", id=2123, buy=0, sell=3000}, {name="ruby necklace", id=2133, buy=0, sell=2000}, {name="scarab amulet", id=2135, buy=0, sell=200}, {name="silver brooch", id=2134, buy=0, sell=150}, {name="terra amulet", id=7887, buy=0, sell=1500}, {name="doll", id=2110, buy=0, sell=200}, {name="light shovel", id=5710, buy=0, sell=300}, {name="pirate voodo doll", id=5810, buy=0, sell=50}, {name="voodo doll", id=3955, buy=0, sell=400} } openShopWindow(cid, items, function(cid, itemid, subType, amount, ignoreCap, inBackpacks) customCallbackOnBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks, items) end, function(cid, itemid, subType, amount, ignoreCap, inBackpacks) customCallbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks, items) end ) npcHandler:say("Of course, just browse through my wares.", cid) end
Erro: Quando eu uso esse script no 9.63 não é possível comprar items que não são agrupáveis, e o seguinte erro é exibido no console:
[Error - NpcScript Interface] (Unknown script file) Description: data/lib/050-function.lua:447: bad argument #2 to 'error' (number expected, got string) stack traceback: [C]: in function 'error' data/lib/050-function.lua:447: in function 'customCallbackOnBuy' data/npc/scripts/al dee.lua:50: in function <data/npc/scripts/al dee.lua:49>
O que eu realmente quero: Ficaria muito grato se alguém conseguisse "consertar" essa função para mim, se não der por favor postem outras soluções.
Material Necessário:
function customCallbackOnBuy:
function customCallbackOnBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks, shopWindow) local shopItem, npcHandler = nil, NpcHandler for _, item in ipairs(shopWindow) do if not item.subType then item.subType = (isItemFluidContainer(item.id) == TRUE or isItemStackable(item.id) == TRUE) and 0 or 1 end if(item.id == itemid and (item.subType == subType)) then shopItem = item break end end if(shopItem == nil) then error("[shopModule.onBuy]", "Item not found on shopItems list") return false end if(shopItem.buy < 0) then error("[shopModule.onSell]", "Attempt to purchase an item which is only sellable") return false end local backpack, totalCost = 1988, amount * shopItem.buy if(inBackpacks) then totalCost = isItemStackable(itemid) == TRUE and totalCost + 20 or totalCost + (math.max(1, math.floor(amount / getContainerCapById(backpack))) * 20) end if(getPlayerMoney(cid) < totalCost) then doPlayerSendCancel(cid, npcHandler:parseMessage(npcHandler:getMessage(MESSAGE_NEEDMONEY), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = totalCost, [TAG_ITEMNAME] = shopItem.name})) return false end local subType = shopItem.subType or isItemFluidContainer(itemid) == TRUE and 0 or 1 local a, b = doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack) if(a < amount) then local msgId = MESSAGE_NEEDMORESPACE if(a == 0) then msgId = MESSAGE_NEEDSPACE end doPlayerSendCancel(cid, npcHandler:parseMessage(npcHandler:getMessage(msgId), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = totalCost, [TAG_ITEMNAME] = shopItem.name, [TAG_ITEMCOUNT] = a})) if(a > 0) then doPlayerRemoveMoney(cid, ((a * shopItem.buy) + (b * 20))) return true end return false end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, npcHandler:parseMessage(npcHandler:getMessage(MESSAGE_BOUGHT), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = totalCost, [TAG_ITEMNAME] = shopItem.name})) doPlayerRemoveMoney(cid, totalCost) return true end