Ir para conteúdo

Featured Replies

  • Respostas 5
  • Visualizações 332
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • -- < Script by Frenesy > -- local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function

  • Criei um arquivo .xml na pasta NPC e adicione isso aí em baixo dentro dele. <?xml version="1.0"?> <npc name="NomeDoNPC" script="data/npc/scripts/NomeDoArquivo.lua" walkinterval="2000">  

Postado
-- < Script by Frenesy > --
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


function doCreatureSayWithDelay(cid,text,type,delay,e)
   if delay<=0 then
      doCreatureSay(cid,text,type)
   else
      local func=function(pars)
                    doCreatureSay(pars.cid,pars.text,pars.type)
                    pars.e.done=TRUE
                 end
      e.done=FALSE
      e.event=addEvent(func,delay,{cid=cid, text=text, type=type, e=e})
   end
end




function cancelNPCTalk(events)
  local ret=1
  for aux=1,table.getn(events) do
     if events[aux].done==FALSE then
        stopEvent(events[aux].event)
     else
        ret=ret+1
     end
  end
  events=nil
  return(ret)
end




function doNPCTalkALot(msgs,interval)
  local e={}
  local ret={}
  if interval==nil then interval=3000 end --3 seconds is default time between messages
  for aux=1,table.getn(msgs) do
      e[aux]={}
      doCreatureSayWithDelay(getNpcCid(),msgs[aux],TALKTYPE_PRIVATE_NP,(aux-1)*interval,e[aux])
      table.insert(ret,e[aux])
  end
  return(ret)
end


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, 'Trocar') or msgcontains(msg, 'changer')) then
    selfSay('Se você me der 3 Items, lhe darei um muito valioso. Quer trocar?', cid)
talkState[talkUser] = 1


elseif(msgcontains(msg, 'Yes') or msgcontains(msg, 'sim')) and talkState[talkUser] == 1 and getPlayerItemCount(cid, IDDoItem1) == 1 and getPlayerItemCount(cid, IDDoItem2) == 1 and  getPlayerItemCount(cid, IDDoItem3) == 1 then
selfSay('Legal, pega aqui seu item novo.', cid)


talkState[talkUser] = 0

doPlayerAddItem(cid,IDDoNovoItem, 1)
doPlayerRemoveItem(cid, RemoveItem1ID, 1)
doPlayerRemoveItem(cid, RemoveItem2ID, 1)
doPlayerRemoveItem(cid, RemoveItem3ID, 1)

elseif(msgcontains(msg, 'Yes') or msgcontains(msg, 'sim')) and talkState[talkUser] == 1 and getPlayerItemCount(cid, IDDoItem1) < 1 or getPlayerItemCount(cid, IDDoItem2) < 1 or  getPlayerItemCount(cid, IDDoItem3) < 1 then
selfSay('Voce ainda nao tem todos os itens.', cid)


talkState[talkUser] = 0

elseif(msgcontains(msg, 'No') or msgcontains(msg, 'nao')) and talkState[talkUser] == 1 then
selfSay('Eu nem queria mesmo.', cid)
talkState[talkUser] = 0

end 
return TRUE
end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new()) 

Editado por Frenesy (veja o histórico de edições)

cms1-pr%C3%AAmio.png

Postado

Criei um arquivo .xml na pasta NPC e adicione isso aí em baixo dentro dele.

<?xml version="1.0"?>
<npc name="NomeDoNPC" script="data/npc/scripts/NomeDoArquivo.lua" walkinterval="2000">
  <health now="200" max="200" />
<look type="131" head="38" body="38" legs="38" feet="38" addons="3"/>
  <parameters>
    <parameter key="message_greet" value="Ola, |PLAYERNAME|. Em que posso ajuda-lo?" />
  </parameters>
</npc>

Configure o nome do NPC e o Script.

cms1-pr%C3%AAmio.png

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo