Ir para conteúdo
Banner com Efeitos

Featured Replies

Postado

Olá, boa noite TK, venho trazer para vocês um script que uso no meu servidor, que serve de missão. Acho maneiro, para RPGS.

A função do script é uma quest, o player precisa entregar um item ao NPC, no caso um pergaminho, que lhe dará acesso a clicar na arvore, porém para chegar até a arvore voce tem que procurar uma alavanca, para aparecer uma escada.

 

Vamos lá. 

 

Crie um arquivo npc/script/Wyat.lua e adicione.

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

-- OTServ event handling functions start
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
-- OTServ event handling functions 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 

--returns how many msgs he have said already 
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)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if (not npcHandler:isFocused(cid)) then
        return false
   end
              
        if msgcontains(msg, 'here') and getPlayerStorageValue(cid, 60200) == -1 then
                npcHandler:say('This is an old castle. Terrifying {beasts} used to live here.', cid)
                talk_state = 5
        elseif msgcontains(msg, 'beasts') and talk_state == 5 then
                
npcHandler:say('I can tell you more about the castle, however I will need a {favour}.', cid)
			talk_state = 6
elseif msgcontains(msg, 'favour') and talk_state == 6 then 
npcHandler:say('I heared about an {old parchment}, which contains ancient alchemists formulas.', cid) 
talk_state = 7
elseif msgcontains(msg, 'old parchment') and talk_state == 7 then  
npcHandler:say('Its the piece of paper. The legend says the necromancers from Tanami desert are keeping it in their {library}.', cid)      
             talk_state = 8
elseif msgcontains(msg, 'library') then  
npcHandler:say('The library can be found to the north of Aldruhn city. I really need this paper, but I am not strong enough to defeat necromancers. Bring it to me, and I will tell you more about beasts.', cid)
setPlayerStorageValue(cid, 60200, 1)
                talk_state = 0

              elseif (msgcontains(msg, 'parchment') or msgcontains(msg, 'alchemist') or msgcontains(msg, 'here') or msgcontains(msg, 'alchemists') or msgcontains(msg, 'formulas') or msgcontains(msg, 'done') or msgcontains(msg, 'reward')) and getPlayerItemCount(cid,9733) < 1 and getPlayerStorageValue(cid, 60202) == -1 and getPlayerStorageValue(cid, 60200) == 1 then
npcHandler:say('I need you to find it as fast as possible! Please be quick.', cid) 

            elseif getPlayerStorageValue(cid, 60200) == 1 and getPlayerStorageValue(cid, 60201) == -1 and (msgcontains(msg, 'parchment') or msgcontains(msg, 'here') or msgcontains(msg, 'alchemist') or msgcontains(msg, 'alchemists') or msgcontains(msg, 'formulas') or msgcontains(msg, 'done') or msgcontains(msg, 'reward') or msgcontains(msg, 'beast')) then 
if getPlayerItemCount(cid,9733) >= 1 then
        if doPlayerRemoveItem(cid,9733,1) then
                 local msgs={ 
            "Okay. I really appreciate it. As I promised: The beast used to terrorize the people from villages nearby. Those were horrible years, many heroes died trying to defeat the beast, but no one survived....", 
            "The name of the beas was Ortheus, this name scares me even to this day. Soon after, Telas came. He was a very brave hero, but not strong enough to kill her alone....", 
            "Luckily for him, he had more luck than cleverness. It was a few seconds separating him from death, then he saw his sword nearby which ensured him victory....", 
            "The beast was changed into a beautiful, red tree. This tree is still here. Some old lever in basement opens the way upstairs. You should start searching there. You have my blessing. Good luck, you can have glory, or die in pain." 
            } 
      doNPCTalkALot(msgs,9000) --if the 2750 is ommited, it uses 3000 always 
setPlayerStorageValue(cid, 60201, 1) 
setPlayerStorageValue(cid, 60202, 1) 
elseif msgcontains(msg, 'things') then  
npcHandler:say('The beast used to eat human bodies. Many people died here. Many heroes tried to defeat beast, but no one survived. Then {telas} came.', cid) 
talk_state = 11
elseif msgcontains(msg, 'telas') and talk_state == 11 then 
npcHandler:say('He was powerful, but not as strong as the beast. He was also very lucky, and this ensured him {victory}.', cid) 
talk_state = 12
elseif msgcontains(msg, 'victory') and talk_state == 12 then 
npcHandler:say('The beast was finally defeated. Telas changed her into a beautiful {tree}, but be aware, bad things happen near it.', cid) 
talk_state = 13
elseif msgcontains(msg, 'tree') and talk_state == 13 then 
npcHandler:say('The tree is still here. Some old lever in basement opens the way upstairs. You should start searching there. You got my blessing. Good luck, you can have glory, or die in pain.', cid) 
setPlayerSetStorageValue(cid,60201, 1) 
doSendMagicEffect(getCreaturePosition(cid), 14)

                talk_state = 0
          
  
end
end
end

        ------------------------------------------------ confirm no ------------------------------------------------
       
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end


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

crie um xml, Wyat.xml 

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Wyat" script="wyat.lua" walkinterval="2000" floorchange="0">
	<health now="150" max="150"/>
	<look type="9" corpse="6080"/>
<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|. What are you looking for {here}?"/>
	</parameters>
	
</npc>

Vamos lá, explicar o Script.

 

você vai falar com o npc, e ele te dará pistas de onde está o [iTEM] que ele quer que você entregue, assim que você entregar ele te dará acesso para passar.

 

24408.JPG

 

 

Quando ele te der o acesso, você poderá ser teleportado pela arvore. Vamos ao script dela.

 

Actions/script e crie tree.lua e adicione

function onUse(cid, item, frompos, item2, topos)
if getPlayerStorageValue(cid, 60201) == -1 then
doCreatureSay(cid, "You little worm! You dont have enough power to touch me.", TALKTYPE_ORANGE_2, getCreaturePosition(cid))
		
elseif getPlayerStorageValue(cid, 60201) == 1 then
local tppos = {x=1341, y=1094, z=8}
doSendMagicEffect(getCreaturePosition(cid), 17)
doTeleportThing(cid,tppos)
end
end

adicione essa tag em xml. 

   <action uniqueid="60200" script="new/tree.lua"/>

Sem a storage voce não conseguira ser teleportado, e com a storage será para a cords da config.

 

24409.JPG

 

Postado

Em nome da comunidade do TK, muito obrigado pela contribuição! :wow:
Seu tópico de conteúdo foi aprovado e será movido para a seção adequada. Você ganhou 1 REP+!

Se quiser sua dúvida tirada, mande PM com os links, e não com a dúvida (outros podem ter a mesma dúvida, e o fórum serve para ser usado).

 

Tópicos:


 

yNlhRVC.png

 

55px-Judo_yellow_belt.svg.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.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo