Ir para conteúdo

[Npc] O Npc Nao Responde O Hi


pedrokkkk

Posts Recomendados

E aew Povo do xtibia

Galera vo explicar para que o npc iria servir antes de tudo.

seria o seguinte... um player noob sem a quest (vamos supor) numero 1 feita.

ai o noob chega no npc1 e diz: hi

Npc1: sai fora meu irmao

 

daí o tempo vai passando e o noob se evoluindo e talz... daí ele vai la e faz a quest 1... ai quando ele clicka no bau manda ele fazer: Fale Com o Npc1

ai o noob chega la com a quest numero 1 feita e fla

noob: HI!

npc: quer que eu te leve para o final da quest?

noob:Yes!

 

daí o npc leva ele...

eu fiz o script e talz mas o npc nao ta respondendo nada e nao aparece nenhum erro no exe do ot... entaum resolvi postar aki no xtibia

Script do npc:

finaldaquest = {x=854, y=1602, z=7}


local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos, cid, item, frompos, item2, topos)
end
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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
 	if focus == cid then
         selfSay('Flw.')
         focus = 0
         talk_start = 0
 	end
end


function onCreatureTurn(creature)

end
local storage = 11578 -- storage da sua quest 


function msgcontains(txt, str)
 	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
 	msg = string.lower(msg)
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
       if getPlayerStorageValue(cid, storage) <= 0 then
selfSay('Sai daqui meu irmao!.', cid)
talkState[talkUser] = 1
else
 		selfSay('fla aew noob, quer finalmente terminar a quest?.')
talkState[talkUser] = 2
 		focus = cid
 		talk_start = os.clock()
end
 	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
 		selfSay('Sorry, ' .. getCreatureName(cid) .. '! Pera noob to flando com ele')

 	elseif focus == cid then
	talk_start = os.clock()

		if msgcontains(msg, 'yes') then
                       talkState[talkUser] = (2)
				doTeleportThing(cid,finaldaquest)
   					doSendMagicEffect(finaldaquest,10)
				selfSay("Bora!")
				focus = 0
				talk_start = 0

			end

       elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
           selfSay('Vlw brother... te vejo na proxima')
           focus = 0
           talk_start = 0
   end
end

function onCreatureChangeOutfit(creature)
end

function onThink()
   doNpcSetCreatureFocus(focus)
   if (os.clock() - talk_start) > 30 then
       if focus > 0 then
           selfSay('Ta afk? Proximo noob!.')
       end
       focus = 0
       talk_start = 0
   end
   if focus ~= 0 then
       if getDistanceToCreature(focus) > 5 then
           selfSay('MAL EDUCADO VOLTA AKI E DIZ BYE')
           focus = 0
           talk_start = 0
       end
   end
endend

Npc xml:

 

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Jobson" script="data/npc/scripts/npc jobson.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="128" head="113" body="113" legs="113" feet="88" addons="3"/>
</npc>

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...