Postado Julho 10, 2014 10 anos Ae galera beleza? Eu gostaria de uma pequena ajuda, um NPC que só vai abrir o trade se tiver a storage 9899, se não tiver ele manda uma mensagem 'nao posso negociar com voce.' up
Postado Julho 10, 2014 10 anos Tenta aí: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 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 function greetCallback(cid) talkState[talkUser] = 0 return true end function creatureSayCallback(cid, type, msg) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(not npcHandler:isFocused(cid)) then return false end local trade = { {id=7589, buy=80, sell=10, name="strong mana potion"}, {id=7591, buy=190, sell=10, name="great health potion"}, } local items = {} for _, item in ipairs(trade) do items[item.id] = {storage = item.storage, item_id = item.id, buyPrice = item.buy, sellPrice = item.sell, subType = 0, realName = item.name} end local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks) if items[item].buyPrice ~= 0 then doPlayerRemoveMoney(cid, amount * items[item].buyPrice) for i = 1, amount do doPlayerAddItem(cid, items[item].item_id, amount) end end end local onSell = function(cid, item, subType, amount, ignoreCap, inBackpacks) if items[item].sellPrice ~= 0 then doPlayerAddMoney(cid, items[item].sellPrice * amount) doPlayerRemoveItem(cid, items[item].item_id, amount) doNPCTalkALot(cid, 200, {"You sell "..amount.." "..items[item].realName.." for "..items[item].sellPrice * amount.." gold coins."}) end end if msgcontains(msg, 'trade') or msgcontains(msg, 'offer') then if (getPlayerStorageValue(cid, 9899) ~= 1) then selfSay("I won't trade with you", cid) else openShopWindow(cid, trade, onBuy, onSell) selfSay("It's my offer.", cid) end end return 1 end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Qualquer dúvida é só dizer.. Editado Julho 10, 2014 10 anos por Rusherzin (veja o histórico de edições) Ajudei? De nada \o/ Att Rusherzin
Postado Julho 11, 2014 10 anos Autor Obrigado cara funcionou Porem tem um problema se eu compro mais de um potion vem em dobro por exemplo, se compro 2 vem quatro, se compro 100, vem 100 montinhos de 100 como arrumo isso ? e da esse erro na hora de vender [11:19:19.344] [Error - NpcScript Interface] [11:19:19.345] (Unknown script file) [11:19:19.347] Description: [11:19:19.348] data/npc/scripts/runes.lua:45: attempt to call global 'doNPCTalkA Lot' (a nil value) [11:19:19.350] stack traceback: [11:19:19.352] data/npc/scripts/runes.lua:45: in function <data/npc/scripts/run es.lua:41> Editado Julho 11, 2014 10 anos por nari (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.