Ir para conteúdo

Featured Replies

Postado
  • Solução
<?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>
  </parameters>
</npc>

NPC/Script:

 -- < 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, 'Hi') or msgcontains(msg, 'oi')) and getPlayerStorageValue(cid,1001) == -1 then
    selfSay('Ola, poderia me ajudar recolhendo alguns itens pra minha lojinha?', cid)
talkState[talkUser] = 1


elseif(msgcontains(msg, 'Hi') or msgcontains(msg, 'oi')) and getPlayerStorageValue(cid,1003) == 1 then
    selfSay('Ola, Em que posso ajudar?', cid)


elseif((msgcontains(msg, 'No') or msgcontains(msg, 'nao')) and talkState[talkUser] == 1) then
    selfSay('Ok entao. Bye!', cid)
talkState[talkUser] = 0


elseif((msgcontains(msg, 'Yes') or msgcontains(msg, 'sim')) and talkState[talkUser] == 1) then
selfSay('Ok, recolha para mim {13 pair of leaves} que pode ser encontrada com {snivys} e {13 Sandbags} que pode ser encontradas com {Krokoroks}. Boa Sorte!', cid)


talkState[talkUser] = 0
doSendMagicEffect(getPlayerPosition(cid), 13)
setPlayerStorageValue(cid, 1001, 1)
setPlayerStorageValue(cid, 1002, 1)


elseif(msgcontains(msg, 'Hi') or msgcontains(msg, 'oi')) and getPlayerStorageValue(cid,1002) == 1 then
selfSay('Conseguiu recolher os itens?', cid)
talkState[talkUser] = 2




elseif(msgcontains(msg, 'Yes') or msgcontains(msg, 'sim')) and talkState[talkUser] == 2 and getPlayerItemCount(cid, 12155) < 13 and getPlayerItemCount(cid, 12177) < 13 then
selfSay('Voce ainda nao tem todos os itens necessarios.', cid)
talkState[talkUser] = 0




elseif((msgcontains(msg, 'No') or msgcontains(msg, 'nao')) and talkState[talkUser] == 2) then
selfSay('Entao vai la buscar.', cid)
talkState[talkUser] = 0




elseif(msgcontains(msg, 'Yes') or msgcontains(msg, 'sim')) and getPlayerStorageValue(cid,1002) == 1 and talkState[talkUser] == 2 and getPlayerItemCount(cid, 12155) == 13 and getPlayerItemCount(cid, 12177) == 13 then
selfSay('Muito obrigado, aqui está seu premio!', cid)


doSendMagicEffect(getPlayerPosition(cid), 49)
doPlayerAddItem(cid,11441, 1)
doPlayerAddItem(cid,11451, 1)
doPlayerRemoveItem(cid, 12155, 13)
doPlayerRemoveItem(cid, 12177, 13)
setPlayerStorageValue(cid, 1002, -1)
setPlayerStorageValue(cid, 1003, 1)




end 
return TRUE
end




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

cms1-pr%C3%AAmio.png

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

Top Posters In This Topic

Most Popular Posts

  • <?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"

  • <?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"

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.7k

Informação Importante

Confirmação de Termo