Ir para conteúdo
  • 0

Pergunta

Ola galera, preciso de ajuda nesse script aqui, eu precisava que o npc quando fosse dar o addon, desse o addon 1 do hunter male e o 2 do hunter female com 1 item só, e nao dar o addon 1 do male e 1 do female como de costume.

 

Aqui vai:

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)


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

npcHandler:setMessage(MESSAGE_GREET, "Ola |PLAYERNAME|. Com uma sniper gloves lhe fa\ço o {addon} 1 do hunter male e o addon 2 do hunter female.")

function playerBuyAddonNPC(cid, message, keywords, parameters, node)
   if(not npcHandler:isFocused(cid)) then
       return false
   end
   if (parameters.confirm ~= true) and (parameters.decline ~= true) then
       if(getPlayerPremiumDays(cid) == 0) and (parameters.premium == true) then
           npcHandler:say('Desculpe, mas este addon e apenas para jogadores premium!', cid)
           npcHandler:resetNpc()
           return true
       end
       if (getPlayerStorageValue(cid, parameters.storageID) ~= -1) then
           npcHandler:say('Voce ja tem esse addon!', cid)
           npcHandler:resetNpc()
           return true
       end
       local itemsTable = parameters.items
       local items_list = ''
       if table.maxn(itemsTable) > 0 then
           for i = 1, table.maxn(itemsTable) do
               local item = itemsTable[i]
               items_list = items_list .. item[2] .. ' ' .. getItemNameById(item[1])
               if i ~= table.maxn(itemsTable) then
                   items_list = items_list .. ', '
               end
           end
       end
       local text = ''
       if (parameters.cost > 0) and table.maxn(parameters.items) then
           text = items_list .. ' and ' .. parameters.cost .. ' gp'
       elseif (parameters.cost > 0) then
           text = parameters.cost .. ' gp'
       elseif table.maxn(parameters.items) then
           text = items_list
       end
       npcHandler:say('Voc\ê trouxe a sniper gloves?', cid)
       return true
   elseif (parameters.confirm == true) then
       local addonNode = node:getParent()
       local addoninfo = addonNode:getParameters()
       local items_number = 0
       if table.maxn(addoninfo.items) > 0 then
           for i = 1, table.maxn(addoninfo.items) do
               local item = addoninfo.items[i]
               if (getPlayerItemCount(cid,item[1]) >= item[2]) then
                   items_number = items_number + 1
               end
           end
       end
       if(getPlayerMoney(cid) >= addoninfo.cost) and (items_number == table.maxn(addoninfo.items)) then
           doPlayerRemoveMoney(cid, addoninfo.cost)
           if table.maxn(addoninfo.items) > 0 then
               for i = 1, table.maxn(addoninfo.items) do
                   local item = addoninfo.items[i]
                   doPlayerRemoveItem(cid,item[1],item[2])
               end
           end
           doPlayerAddOutfit(cid, addoninfo.outfit_male, addoninfo.addon)
           doPlayerAddOutfit(cid, addoninfo.outfit_female, addoninfo.addon)
           setPlayerStorageValue(cid,addoninfo.storageID,1)
           npcHandler:say('Ficou lindo em voce!', cid)
       else
           npcHandler:say('Voc\ê n\ão tem o item!', cid)
       end
       npcHandler:resetNpc()
       return true
   elseif (parameters.decline == true) then
       npcHandler:say('Se nao lhe agrada, va embora!', cid)
       npcHandler:resetNpc()
       return true
   end
   return false
end

local noNode = KeywordNode:new({'no'}, playerBuyAddonNPC, {decline = true})
local yesNode = KeywordNode:new({'yes'}, playerBuyAddonNPC, {confirm = true})

local outfit_node = keywordHandler:addKeyword({'addon'}, playerBuyAddonNPC, {premium = false, cost = 0, items = {{5875,1}}, outfit_female = 137, outfit_male = 129, addon = 1, storageID = 10040})
   outfit_node:addChildKeywordNode(yesNode)
   outfit_node:addChildKeywordNode(noNode)


npcHandler:addModule(FocusModule:new())

Link para o comentário
https://xtibia.com/forum/topic/186032-npc-de-addon/
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...