Ir para conteúdo
  • 0

Npc de quest


WExpert

Pergunta

Posts Recomendados

  • 0

Vá em data/npc, crie um arquivo chamado Changer.xml, e adicione isso dentro;

 

<?xml version="1.0"?>

<npc name="Quest Changer" script="data/npc/scripts/qstchanger.lua" access="3" lookdir="1" autowalk="200" speed="200">
       <health now="1" max="1"/>
       <look type="120" head="38" body="79" legs="107" feet="114"/>
</npc>

 

Agora em data/npc/scripts, crie um arquivo chamado qstchanger.lua e adicione isso dentro:

 

 

local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false

local addon_state = 0

 

function onThingMove(creature, thing, oldpos, oldstackpos)

end

 

function onCreatureAppear(creature)

end

 

function onCreatureDisappear(cid, pos)

if focus == cid then

selfSay('Good bye then.')

focus = 0

talk_start = 0

end

end

 

function onCreatureTurn(creature)

end

 

function msgcontains(txt, str)

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

end

 

local item1 = 2133 -- ID DO ITEM QUE O PLAYER VAI RECEBER

local item2 = 2134 -- ID DO ITEM QUE O PLAYER TEM Q DAR

 

function onCreatureSay(cid, type, msg)

msg = string.lower(msg)

 

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then

selfSay('Olá, sou o NPC da Quest, tem o item necessário?')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

 

elseif focus == cid then

talk_start = os.clock()

if msgcontains(msg, 'yes') or msgcontains(msg, 'sim') or msgcontains(msg, 'quest') then then

if doPlayerRemoveItem(cid,item2,1) == TRUE then

selfSay('Obrigado, aqui está sua recompensa!')

doPlayerAddItem(cid,item1,1)

addon_state = 0

else

selfSay('Você não tem o item necessário!')

talk_start = 0

end

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye, ' .. getCreatureName(cid) .. '! Come back soon..')

focus = 0

talk_start = 0

end

end

end

 

function onCreatureChangeOutfit(creature)

end

 

function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 30 then

if focus > 0 then

selfSay('Next Please...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Good bye then.')

focus = 0

end

end

end

 

Link para o comentário
Compartilhar em outros sites

  • 0

kra,n funfou e o npc desaparece qundo ponho essa script, mais eu queria saber se da pra mi dar uma ajudinha aki numas libs --

 

quero faser uma lib de DoPlayerRemoveItem (cid,itemid,count)

quero que ela cheque se o player tem o item, tem como faser isso ?

Editado por WExpert
Link para o comentário
Compartilhar em outros sites

  • 0

Essa função ai não vai checar se o player tem o item, vai remover!

ACHEI O ERRO, TESTA AE ;]

 

 

local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false

local addon_state = 0

 

function onThingMove(creature, thing, oldpos, oldstackpos)

end

 

function onCreatureAppear(creature)

end

 

function onCreatureDisappear(cid, pos)

if focus == cid then

selfSay('Good bye then.')

focus = 0

talk_start = 0

end

end

 

function onCreatureTurn(creature)

end

 

function msgcontains(txt, str)

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

end

 

local item1 = 2133 -- ID DO ITEM QUE O PLAYER VAI RECEBER

local item2 = 2134 -- ID DO ITEM QUE O PLAYER TEM Q DAR

 

function onCreatureSay(cid, type, msg)

msg = string.lower(msg)

 

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then

selfSay('Olá, sou o NPC da Quest, tem o item necessário?')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

 

elseif focus == cid then

talk_start = os.clock()

if msgcontains(msg, 'yes') or msgcontains(msg, 'quest') then

if doPlayerRemoveItem(cid,item2,1) == TRUE then

selfSay('Obrigado, aqui está sua recompensa!')

doPlayerAddItem(cid,item1,1)

addon_state = 0

else

selfSay('Você não tem o item necessário!')

talk_start = 0

end

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye, ' .. getCreatureName(cid) .. '! Come back soon..')

focus = 0

talk_start = 0

end

end

end

 

function onCreatureChangeOutfit(creature)

end

 

function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 30 then

if focus > 0 then

selfSay('Next Please...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Good bye then.')

focus = 0

end

end

end

 

Editado por Roksas
Link para o comentário
Compartilhar em outros sites

  • 0

Ok, quanto a sua dúvida de checar se o plaayer tem o item, tem essa function:

getPlayerItemCount(cid, itemid)

 

Ou seja,

if getPlayerItemCount(cid, 2148) >= 99 then

Se o player tiver 99 ou mais moedas, faça :))

Link para o comentário
Compartilhar em outros sites

  • 0

tinha colocado 2 then so num canto xD , mais como faço pra o player so conseguir faser a quest 1 vez ? tipo mudar o storage o player pra so faser 1 ves.

 

e olha aki esse meu script de npc, q ta dando errado, pq msm o kra tando sem o item ele da a recompença:

 

 

 

local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false

 

function onThingMove(creature, thing, oldpos, oldstackpos)

 

end

 

 

function onCreatureAppear(creature)

 

end

 

 

function onCreatureDisappear(cid, pos)

if focus == cid then

selfSay('Good bye then.')

focus = 0

talk_start = 0

end

end

 

 

function onCreatureTurn(creature)

 

end

 

 

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') then

 

selfSay('Hey I am very hungry, Can you give me 30 dragon tails?.')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

 

elseif focus == cid then

talk_start = os.clock()

 

 

 

if msgcontains(msg, 'yes') then

if getPlayerStorageValue(cid,6000) == 1 then

 

selfSay('Sorry You Cant Do this quest.')

elseif msgcontains(msg, 'yes') then

if doPlayerRemoveItem(cid,2672,30) == 0 then

selfSay('Sorry Dont have that items.')

 

else

if doPlayerAddItem(cid,2264,1) then

 

setPlayerStorageValue(cid,6000,1)

selfSay('Thanks take this')

focus = 0

talk_start = 0

 

 

end

end

end

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye, ' .. getCreatureName(cid) .. '!')

focus = 0

talk_start = 0

end

end

 

end

function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 45 then

if focus > 0 then

selfSay('Next Please...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Good bye then.')

focus = 0

end

end

end

 

 

se puder mi ajudar nesse npc acima ajudaria mais doq ajeitando akele seu npc, pq fiz muitos desse jeito ae e tao com o msms erro.

Editado por WExpert
Link para o comentário
Compartilhar em outros sites

  • 0

Pera, deixa eu entenderr. Você quer que arrume o NPC acima, e use de base para o outro. Ou oque? Eu arrumei uns erros que achei nesse de cima, concertei a storage e tals:

 

 

local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false

 

function onThingMove(creature, thing, oldpos, oldstackpos)

 

end

 

 

function onCreatureAppear(creature)

 

end

 

 

function onCreatureDisappear(cid, pos)

if focus == cid then

selfSay('Good bye then.')

focus = 0

talk_start = 0

end

end

 

 

function onCreatureTurn(creature)

 

end

 

 

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') then

 

selfSay('Hey I am very hungry, Can you give me 30 dragon tails?.')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

 

elseif focus == cid then

talk_start = os.clock()

 

 

 

if msgcontains(msg, 'yes') then

if getPlayerStorageValue(cid,6000) ~= 1 then

 

selfSay('Sorry You Cant Do this quest.')

elseif msgcontains(msg, 'yes') and doPlayerRemoveItem(cid,2672,30) == FALSE then

selfSay('Sorry Dont have that items.')

 

else

if doPlayerAddItem(cid,2264,1) then

setPlayerStorageValue(cid,6000,1)

selfSay('Thanks take this')

focus = 0

talk_start = 0

 

end

end

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye, ' .. getCreatureName(cid) .. '!')

focus = 0

talk_start = 0

end

end

 

end

function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 45 then

if focus > 0 then

selfSay('Next Please...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Good bye then.')

focus = 0

end

end

end

 

 

EDIT --

 

AQUELE PRIMEIRÃO, COLOQUEI PRA FAZER SÓ 1X Q NEM VC PEDIU

 

 

local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false

local addon_state = 0

 

function onThingMove(creature, thing, oldpos, oldstackpos)

end

 

function onCreatureAppear(creature)

end

 

function onCreatureDisappear(cid, pos)

if focus == cid then

selfSay('Good bye then.')

focus = 0

talk_start = 0

end

end

 

function onCreatureTurn(creature)

end

 

function msgcontains(txt, str)

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

end

 

local item1 = 2133 -- ID DO ITEM QUE O PLAYER VAI RECEBER

local item2 = 2134 -- ID DO ITEM QUE O PLAYER TEM Q DAR

 

function onCreatureSay(cid, type, msg)

msg = string.lower(msg)

 

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then

selfSay('Olá, sou o NPC da Quest, tem o item necessário?')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

 

elseif focus == cid then

talk_start = os.clock()

if msgcontains(msg, 'yes') or msgcontains(msg, 'quest') then

if getPlayerStorageValue(cid,3211) ~= 1 then

if doPlayerRemoveItem(cid,item2,1) == TRUE then

selfSay('Obrigado, aqui está sua recompensa!')

doPlayerAddItem(cid,item1,1)

setPlayerStorageValue(cid,3211,1)

addon_state = 0

else

selfSay('Você não tem o item necessário!')

talk_start = 0

end

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye, ' .. getCreatureName(cid) .. '! Come back soon..')

focus = 0

talk_start = 0

end

end

end

end

 

function onCreatureChangeOutfit(creature)

end

 

function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 30 then

if focus > 0 then

selfSay('Next Please...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Good bye then.')

focus = 0

end

end

end

 

Editado por Roksas
Link para o comentário
Compartilhar em outros sites

  • 0

eu quero q vc so ajeite akele q te mandei ;) , e testei ele e n deu serto, ele fika falando q vc ja fez a quest sendo q vc n fez(obs a storage tava serta, mais so n tava pedindo o item tipo vc podia n ter o item msm assim ele dava o premio.

 

(testei o npc q te mandei e vc consertou e deu esse bug no storage, so precisa ajeitar pra ele so dar o premio se tiver o item da quest)

Link para o comentário
Compartilhar em outros sites

  • 0

Aqui, tirei a storage e mudei uma coisa. Acho que vai funcionar:

 

 

local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false

local addon_state = 0

 

function onThingMove(creature, thing, oldpos, oldstackpos)

end

 

function onCreatureAppear(creature)

end

 

function onCreatureDisappear(cid, pos)

if focus == cid then

selfSay('Good bye then.')

focus = 0

talk_start = 0

end

end

 

function onCreatureTurn(creature)

end

 

function msgcontains(txt, str)

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

end

 

local item1 = 2133 -- ID DO ITEM QUE O PLAYER VAI RECEBER

local item2 = 2134 -- ID DO ITEM QUE O PLAYER TEM Q DAR

 

function onCreatureSay(cid, type, msg)

msg = string.lower(msg)

 

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then

selfSay('Olá, sou o NPC da Quest, tem o item necessário?')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

 

elseif focus == cid then

talk_start = os.clock()

if msgcontains(msg, 'yes') or msgcontains(msg, 'quest') then

if doPlayerRemoveItem(cid,item1,1) == TRUE then

selfSay('Obrigado, aqui está sua recompensa!')

doPlayerAddItem(cid,item2,1)

addon_state = 0

else

selfSay('Você não tem o item necessário!')

talk_start = 0

end

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye, ' .. getCreatureName(cid) .. '! Come back soon..')

focus = 0

talk_start = 0

end

end

end

 

function onCreatureChangeOutfit(creature)

end

 

function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 30 then

if focus > 0 then

selfSay('Next Please...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Good bye then.')

focus = 0

end

end

end

 

Link para o comentário
Compartilhar em outros sites

  • 0

funfou, mais o player fika fasendo a quest quantas veses quiser, tem como vc ajeitar dnv ?

 

ei, perae, o seu q vc mandou com a storage tava dando serto, oq deu errado foi o q mandei pra vc ajeitar e vc mi mandou com a storage errada tendeu ? ele n ta pedindo o item como eu disse, tenta ajeitar ele ae

 

 

local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false

 

function onThingMove(creature, thing, oldpos, oldstackpos)

 

end

 

 

function onCreatureAppear(creature)

 

end

 

 

function onCreatureDisappear(cid, pos)

if focus == cid then

selfSay('Good bye then.')

focus = 0

talk_start = 0

end

end

 

 

function onCreatureTurn(creature)

 

end

 

 

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') then

 

selfSay('Hey I am very hungry, Can you give me 30 dragon tails?.')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

 

elseif focus == cid then

talk_start = os.clock()

 

 

 

if msgcontains(msg, 'yes') then

if getPlayerStorageValue(cid,6000) == 1 then

 

selfSay('Sorry You Cant Do this quest.')

elseif msgcontains(msg, 'yes') then

if doPlayerRemoveItem(cid,2672,30) == 0 then

selfSay('Sorry Dont have that items.')

 

else

if doPlayerAddItem(cid,2264,1) then

 

setPlayerStorageValue(cid,6000,1)

selfSay('Thanks take this')

focus = 0

talk_start = 0

 

 

end

end

end

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye, ' .. getCreatureName(cid) .. '!')

focus = 0

talk_start = 0

end

end

 

end

function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 45 then

if focus > 0 then

selfSay('Next Please...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Good bye then.')

focus = 0

end

end

end

 

Link para o comentário
Compartilhar em outros sites

  • 0

Prontinho, boa sorte com o sv ;]

 

 

local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false

local addon_state = 0

 

function onThingMove(creature, thing, oldpos, oldstackpos)

end

 

function onCreatureAppear(creature)

end

 

function onCreatureDisappear(cid, pos)

if focus == cid then

selfSay('Good bye then.')

focus = 0

talk_start = 0

end

end

 

function onCreatureTurn(creature)

end

 

function msgcontains(txt, str)

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

end

 

local item1 = 2133 -- ID DO ITEM QUE O PLAYER VAI RECEBER

local item2 = 2134 -- ID DO ITEM QUE O PLAYER TEM Q DAR

 

function onCreatureSay(cid, type, msg)

msg = string.lower(msg)

 

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then

selfSay('Olá, sou o NPC da Quest, tem o item necessário?')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

 

elseif focus == cid then

talk_start = os.clock()

if msgcontains(msg, 'yes') or msgcontains(msg, 'quest') then

if doPlayerRemoveItem(cid,item1,1) == TRUE and getPlayerStorageValue(cid,12139) ~= 1 then

selfSay('Obrigado, aqui está sua recompensa!')

doPlayerAddItem(cid,item2,1)

setPlayerStorageValue(cid,12139,1)

addon_state = 0

else

selfSay('Você não tem o item necessário!')

talk_start = 0

end

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye, ' .. getCreatureName(cid) .. '! Come back soon..')

focus = 0

talk_start = 0

end

end

end

 

function onCreatureChangeOutfit(creature)

end

 

function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 30 then

if focus > 0 then

selfSay('Next Please...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Good bye then.')

focus = 0

end

end

end

 

Link para o comentário
Compartilhar em outros sites

  • 0

esse ae eh akele meu? esse q mandei agora ?

 

tenta descobrir onde ta o erro desse q te agradeço (como eu disse o player n tem o item e ele da a recompensa)

 

 

local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false

 

function onThingMove(creature, thing, oldpos, oldstackpos)

 

end

 

 

function onCreatureAppear(creature)

 

end

 

 

function onCreatureDisappear(cid, pos)

if focus == cid then

selfSay('Good bye then.')

focus = 0

talk_start = 0

end

end

 

 

function onCreatureTurn(creature)

 

end

 

 

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') then

 

selfSay('Hey I am very hungry, Can you give me 30 dragon tails?.')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

 

elseif focus == cid then

talk_start = os.clock()

 

 

 

if msgcontains(msg, 'yes') then

if getPlayerStorageValue(cid,6000) == 1 then

 

selfSay('Sorry You Cant Do this quest.')

elseif msgcontains(msg, 'yes') then

if doPlayerRemoveItem(cid,2672,30) == 0 then

selfSay('Sorry Dont have that items.')

 

else

if doPlayerAddItem(cid,2264,1) then

 

setPlayerStorageValue(cid,6000,1)

selfSay('Thanks take this')

focus = 0

talk_start = 0

 

 

end

end

end

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye, ' .. getCreatureName(cid) .. '!')

focus = 0

talk_start = 0

end

end

 

end

function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 45 then

if focus > 0 then

selfSay('Next Please...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Good bye then.')

focus = 0

end

end

end

 

Editado por WExpert
Link para o comentário
Compartilhar em outros sites

  • 0

Vejamos:

 

 

local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false

 

function onThingMove(creature, thing, oldpos, oldstackpos)

 

end

 

 

function onCreatureAppear(creature)

 

end

 

 

function onCreatureDisappear(cid, pos)

if focus == cid then

selfSay('Good bye then.')

focus = 0

talk_start = 0

end

end

 

 

function onCreatureTurn(creature)

 

end

 

 

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') then

 

selfSay('Hey I am very hungry, Can you give me 30 dragon tails?.')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

 

elseif focus == cid then

talk_start = os.clock()

 

 

 

if msgcontains(msg, 'yes') and getPlayerStorageValue(cid,6001) == 1 then

 

selfSay('Sorry You Cant Do this quest.')

elseif msgcontains(msg, 'yes') and doPlayerRemoveItem(cid,2672,30) == FALSE then

selfSay('Sorry Dont have that items.')

 

elseif getPlayerStorageValue(cid,6001) >= 2 then

elseif doPlayerAddItem(cid,2264,1) then

setPlayerStorageValue(cid,6000,1)

selfSay('Thanks take this')

focus = 0

talk_start = 0

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye, ' .. getCreatureName(cid) .. '!')

focus = 0

talk_start = 0

end

end

 

end

function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 45 then

if focus > 0 then

selfSay('Next Please...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Good bye then.')

focus = 0

end

end

end

 

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...