Postado Junho 15, 2014 11 anos Galera estou com este erro em meu server, acontece com o npc Pompan mas só ao tentar comprar itens que não são agrupáveis, qdo compro meat, bread, eu recebo o item normalmente, ao tentar comprar uma backpack ou um crowbar, eu não recebo o item na bp e aparece esta mensagem de erro no servidor: [20:25:09.148] [Error - NpcScript Interface] [20:25:09.148] (Unknown script file) [20:25:09.148] Description: [20:25:09.148] data/lib/050-function.lua:493:bad argument #2 to 'error' (number expected, got string) [20:25:09.148] stack traceback: [20:25:09.148] [C]: in function 'error' [20:25:09.158] data/lib/050-function.lua:493: in function 'customCallbackOnBuy' [20:05:09.158] data/npc/scripts/Pompan.lua: in function <data/npc/scripts/Po mpan.lua:76> por favor alguém me ajude!
Postado Junho 16, 2014 11 anos É só no Pompan? Por favor poste o pompan.lua para que a galera possa ver o erro no script '-' Entenda tudo sobre VPS, DEDICADOS & HOSPEDAGENS. => Clique aqui Global Full Download 10.9x - TFS 1.2/FERUMBRAS/KRAILOS. => Clique aqui Muitos querem aquilo que você tem, mas vão desistir quando souberem o preço que você pagou. lu.lukinha [email protected]
Postado Junho 16, 2014 11 anos Autor não é só no Pompan, tem tb o Cael e o Esrik que estao com o mesmo problema e os 3 npc usam storage para poder abrir o trade LEMBRANDO: o erro nao aparece nos itens agrupaveis como arrows, spears, food etc Obrigado por tentar me ajudar. aqui o npc Pompan.lua local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local Topic = {} 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 shopModule = ShopModule:new() function creatureSayCallback(cid, type, msg) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) then npcHandler:say("Hello.", cid, TRUE) npcHandler:addFocus(cid) elseif(not npcHandler:isFocused(cid)) then return false elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then npcHandler:say("It was a pleasure to help you, "..getCreatureName(cid)..".", cid, TRUE) npcHandler:releaseFocus(cid) elseif msgcontains(msg, "trade") then local items = { {name="arrow", id=2544, buy=3}, {name="bag", id=1987, buy=5}, {name="basket", id=1989, buy=6}, {name="bolt", id=2543, buy=4}, {name="bow", id=2456, buy=400, sell=100}, {name="bucket", id=2005, buy=4}, {name="candlestick", id=2047, buy=2}, {name="crossbow", id=2455, buy=500, sell=120}, {name="crowbar", id=2416, buy=260, sell=50}, {name="earth arrow", id=7850, buy=5}, {name="expedition backpack", id=11235, buy=100}, {name="expedition bag", id=11236, buy=50}, {name="fishing rod", id=2580, buy=150, sell=40}, {name="flaming arrow", id=7840, buy=5}, {name="flash arrow", id=7838, buy=5}, {name="inkwell", id=2600, sell=8}, {name="lamp", id=2044, buy=8}, {name="mirror", id=2560, sell=10}, {name="onyx arrow", id=7365, buy=7}, {name="pick", id=2553, buy=50, sell=15}, {name="piercing bolt", id=7363, buy=5}, {name="power bolt", id=2547, buy=7}, {name="rope", id=2120, buy=50, sell=15}, {name="royal spear", id=7378, buy=15}, {name="scythe", id=2550, buy=50, sell=10}, {name="shiver arrow", id=7839, buy=5}, {name="shovel", id=2554, buy=50, sell=8}, {name="sickle", id=2405, sell=3}, {name="sniper arrow", id=7364, buy=5}, {name="spear", id=2389, buy=10, sell=3}, {name="throwing star", id=2399, buy=42}, {name="closed trap", id=2578, buy=280, sell=75}, {name="worm", id=3976, buy=1} } if getPlayerStorageValue(cid, 85300) >= 1 then table.insert(items, {name="dragon tapestry", id=11258, buy=80}) end if getPlayerStorageValue(cid, 85300) >= 2 then table.insert(items, {name="minotaur backpack", id=11238, buy=200}) table.insert(items, {name="corrupted flag", id=11320, sell=700}) table.insert(items, {name="high guard flag", id=11326, sell=550}) table.insert(items, {name="legionnaire flags", id=11328, sell=500}) table.insert(items, {name="zaogun flag", id=11324, sell=600}) end if getPlayerStorageValue(cid, 85300) >= 5 then table.insert(items, {name="dragon backpack", id=11237, buy=200}) end 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) -- buy fix 7gp Topic[talkUser] = 0 end return TRUE end npcHandler:setMessage(MESSAGE_WALKAWAY, "Bye.") npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) eu adicionei esta funçao no arquivo 050-function.lua que fica dentro da pasta data\lib porque em principio os npcs nem respondiam ao meu pedido de trade, agora funcionou mas com estes bugs aqui a funçao que eu adicionei: function customCallbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks, shopWindow) local shopItem, npcHandler, subType = nil, NpcHandler, subType or 0 for _, item in ipairs(shopWindow) do item.subType = not item.subType and 0 or item.subType if(item.id == itemid and (isItemFluidContainer(itemid) == FALSE or isItemFluidContainer(itemid) == TRUE 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.sell < 0) then error("[shopModule.onSell]", "Attempt to sell an item which is only buyable") return false end if(doPlayerRemoveItem(cid, itemid, amount, isItemFluidContainer(itemid) == TRUE and subType or isItemStackable(itemid) == TRUE and amount or 1) == TRUE) then doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, npcHandler:parseMessage(npcHandler:getMessage(MESSAGE_SOLD), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = amount * shopItem.sell, [TAG_ITEMNAME] = shopItem.name})) doPlayerAddMoney(cid, amount * shopItem.sell) return true end doPlayerSendCancel(cid, npcHandler:parseMessage(npcHandler:getMessage(MESSAGE_NEEDITEM), {[TAG_PLAYERNAME] = getPlayerName(cid), [TAG_ITEMCOUNT] = amount, [TAG_TOTALCOST] = amount * shopItem.sell, [TAG_ITEMNAME] = shopItem.name})) return false end Editado Junho 16, 2014 11 anos por onix (veja o histórico de edições)
Postado Junho 16, 2014 11 anos Teste este: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local Topic = {} 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 function getTable(player) local itemsList = { {name="backpack", id=1988, buy=20}, {name="bag", id=1987, buy=5}, {name="basket", id=1989, buy=6}, {name="bucket", id=2005, buy=4}, {name="candlestick", id=2047, buy=2}, {name="closed trap", id=2578, buy=280, sell=75}, {name="crowbar", id=2416, buy=260, sell=50}, {name="expedition backpack", id=11241, buy=100}, {name="expedition bag", id=11242, buy=50}, {name="fishing rod", id=2580, buy=150, sell=40}, {name="lamp", id=2044, buy=8}, {name="pick", id=2553, buy=50, sell=15}, {name="rope", id=2120, buy=50, sell=15}, {name="scythe", id=2550, buy=50, sell=10}, {name="shovel", id=2554, buy=50, sell=8}, {name="torch", id=2050, buy=2}, {name="watch", id=2036, buy=20, sell=6}, {name="worm", id=3976, buy=1}, {name="inkwell", id=2600, sell=8}, {name="mirror", id=2560, sell=10}, {name="sickle", id=2405, sell=3} } -- 1 tome local tomes = { { {name="arrow", id=2544, buy=3}, {name="bolt", id=2543, buy=4}, {name="bow", id=2456, buy=400, sell=100}, {name="crossbow", id=2455, buy=500, sell=120}, {name="crystalline arrow", id=18304, buy=20}, {name="dragon tapestry", id=11264, buy=80}, {name="drill bolt", id=18436, buy=12}, {name="earth arrow", id=7850, buy=5}, {name="envenomed arrow", id=18437, buy=12}, {name="flaming arrow", id=7840, buy=5}, {name="flash arrow", id=7838, buy=5}, {name="onyx arrow", id=7365, buy=7}, {name="piercing bolt", id=7363, buy=5}, {name="power bolt", id=2547, buy=7}, {name="prismatic bolt", id=18435, buy=20}, {name="royal spear", id=7378, buy=15}, {name="shiver arrow", id=7839, buy=5}, {name="sniper arrow", id=7364, buy=5}, {name="spear", id=2389, buy=9, sell=3}, {name="tarsal arrow", id=15648, buy=6}, {name="throwing star", id=2399, buy=42}, {name="vortex bolt", id=15649, buy=6}, {name="corrupted flag", id=11326, sell=700}, {name="high guard flag", id=11332, sell=550}, {name="legionnaire flags", id=11334, sell=500}, {name="zaogun flag", id=11330, sell=600} }, { -- 2 tomes {name="minotaur backpack", id=11244, buy=200} }, { -- 5 tomes {name="dragon backpack", id=11243, buy=200} }, } if player:getStorageValue(85300) >= 1 then -- 1 tome for i = 1, #tomes[1] do table.insert(itemsList, tomes[1][i]) end end if player:getStorageValue(85300) >= 2 then -- 2 tomes for i = 1, #tomes[2] do table.insert(itemsList, tomes[2][i]) end end if player:getStorageValue(85300) >= 5 then -- 5 tomes for i = 1, #tomes[3] do table.insert(itemsList, tomes[3][i]) end end return itemsList end local function setNewTradeTable(table) local items = {} for _, v in ipairs(table) do items[v.id] = {itemId = v.id, buyPrice = v.buy, sellPrice = v.sell, subType = 0, realName = v.name} end return items end function creatureSayCallback(cid, type, msg) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local player = Player(cid) if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) then npcHandler:say("Hello.", cid, TRUE) npcHandler:addFocus(cid) elseif(not npcHandler:isFocused(cid)) then return false elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then npcHandler:say("It was a pleasure to help you, "..getCreatureName(cid)..".", cid, TRUE) npcHandler:releaseFocus(cid) elseif msgcontains(msg, "trade") then local player = Player(cid) local items = setNewTradeTable(getTable(player)) local function onBuy(cid, item, subType, amount, ignoreCap, inBackpacks) if (ignoreCap == false and (player:getFreeCapacity() < getItemWeight(items[item].itemId, amount) or inBackpacks and player:getFreeCapacity() < (getItemWeight(items[item].itemId, amount) + getItemWeight(1988, 1)))) then return player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You don\'t have enough cap.') end if items[item].buyPrice <= player:getMoney() then if inBackpacks then local container = Game.createItem(1988, 1) local bp = player:addItemEx(container) if(bp ~= 1) then return player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You don\'t have enough container.') end for i = 1, amount do container:addItem(items[item].itemId, items[item]) end else return player:addItem(items[item].itemId, amount, false, items[item]) and player:removeMoney(amount * items[item].buyPrice) and player:sendTextMessage(MESSAGE_INFO_DESCR, 'You bought '..amount..'x '..items[item].realName..' for '..items[item].buyPrice * amount..' gold coins.') end player:sendTextMessage(MESSAGE_INFO_DESCR, 'You bought '..amount..'x '..items[item].realName..' for '..items[item].buyPrice * amount..' gold coins.') player:removeMoney(amount * items[item].buyPrice) else player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You do not have enough money.') end return true end local function onSell(cid, item, subType, amount, ignoreEquipped) if items[item].sellPrice then return player:removeItem(items[item].itemId, amount, -1, ignoreEquipped) and player:addMoney(items[item].sellPrice * amount) and player:sendTextMessage(MESSAGE_INFO_DESCR, 'You sold '..amount..'x '..items[item].realName..' for '..items[item].sellPrice * amount..' gold coins.') end return true end openShopWindow(cid, getTable(player), onBuy, onSell) npcHandler:say("Keep in mind you won't find better offers here. Just browse through my wares.", cid) end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) Entenda tudo sobre VPS, DEDICADOS & HOSPEDAGENS. => Clique aqui Global Full Download 10.9x - TFS 1.2/FERUMBRAS/KRAILOS. => Clique aqui Muitos querem aquilo que você tem, mas vão desistir quando souberem o preço que você pagou. lu.lukinha [email protected]
Postado Junho 16, 2014 11 anos Autor Absolute com seu script o npc Pompan não me responde mais nem ao "hi" e aparece este erro no server [21:29:48.721] [Error - NpcScript Interface] [21:29:48.721] data/npc/scripts/Pompan.lua:onCreatureSay [21:29:48.721] Description: [21:29:48.721] data/npc/scripts/Pompan.lua:109: attempt to call global 'Player' (a nil value) [21:29:48.731] stack traceback: [21:29:48.731] data/npc/scripts/Pompan.lua:109: in function 'callback' [21:29:48.731] data/npc/lib/npcsystem/npchandler.lua:455: in function 'onCreatu reSay' [21:29:48.731] data/npc/scripts/Pompan.lua:8: in function <data/npc/scripts/Pom pan.lua:8> meu OT é 8.60 eu axo que o erro é no arquivo 050-function.lua se vc puder postar este arquivo pra mim testar ou entao falta alterar algo em outra tabela para reconhecer essa funçao customCallbackOnBuy Editado Junho 16, 2014 11 anos por onix (veja o histórico de edições)
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.