Ir para conteúdo

lawkzz

Membro
  • Registro em

  • Última visita

Histórico de Curtidas

  1. Gostei
    lawkzz deu reputação a GiovaniRodrigo em [Resolvido] [PEDIDO] NPC Troca Item por outro Item   
    Crie um arquivo chamado Jax.lua na pasta data/npc/scripts e cole isso
     
    local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {}   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 items = {           item1 = {2346, 2349}, -- item1 item que será pedido e que será dado na primeira troca           item2 = {2033, 15515} -- item2 item que será pedido e que será dado na segunda troca } local counts = {           count1 = {1, 1}, -- count1 quantidade que será pedido e que será dado na primeira troca           count2 = {10, 1} -- count2 quantidade que será pedido e que será dado na segunda troca }   function creatureSayCallback(cid, type, msg)           if(not npcHandler:isFocused(cid)) then                     return false           end           local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid           if msgcontains(msg, 'blue note') then                     if getPlayerItemCount(cid, items.item1[1]) >= counts.count1[1] then                               doPlayerRemoveItem(cid, items.item1[1], counts.count1[1])                               doPlayerAddItem(cid, items.item1[2], counts.count1[2])                               selfSay('You just swap '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..' for '.. counts.count1[2] ..' '.. getItemNameById(items.item1[2]) ..'.', cid)                     else                               selfSay('You need '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..'.', cid)                     end           elseif msgcontains(msg, 'bar of gold') then                     if getPlayerItemCount(cid, items.item2[1]) >= counts.count2[1] then                               doPlayerRemoveItem(cid, items.item2[1], counts.count2[1])                               doPlayerAddItem(cid, items.item2[2], counts.count2[2])                               selfSay('You just swap '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..' for '.. counts.count2[2] ..' '.. getItemNameById(items.item2[2]) ..'.', cid)                     else                               selfSay('You need '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..'.', cid)                     end           end           return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())  
    Crie um arquivo chamado Jax.xml na pasta data/npc e cole isso
     
    <?xml version="1.0" encoding="UTF-8"?> <npc name="Jax" script="Jax.lua" walkinterval="2000" floorchange="0">           <health now="150" max="150" />           <look type="134" head="57" body="59" legs="40" feet="76" corpse="2212" />           <parameters>                     <parameter key="message_greet" value="Hello |PLAYERNAME|. Do not want to make an exchange? I have {blue note} and {bar of gold}." />                     <parameter key="message_farewell" value="Bye bye!" />           </parameters> </npc>  
    Testado e está 100% funcional
     
    Att.
    Giovani Rodrigo

Informação Importante

Confirmação de Termo