Ir para conteúdo

Posts Recomendados

Bom como eu tava tentando botar algumas magias novas só para vip usar, quando eu colocava direto na magia dava erro ai tentei criar um npc que ensinasse as magias, ai eu colocaria ele na area vip, só que esse npc esta dando erro eu falo o nome da magia e ele não responde e quando eu falo algum nome que funciona ele fala que não tenho dinheiro e mesmo assim remove.

 

Esta ai o script do npc

 

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('Adeus.')

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') and focus == 0) and getDistanceToCreature(cid) < 4 then

selfSay('Olá meu jovem, eu sou o mais poderoso sorcerer de King City, posso lhe ensinar muitas magias. Você quer ser meu aprendiz?')

focus = cid

talk_state = 0

talk_start = os.clock()

 

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

selfSay('Agora estou ocupado.')

 

elseif focus == cid then

talk_start = os.clock()

 

if msgcontains(msg, 'sim') then

selfSay('Fale o nome de qualquer magia e eu lhe ensinarei por uma certa quantia de ouro.')

talk_state = 1

 

vocation = getPlayerVocation(cid)

elseif msgcontains(msg, 'extreme invocation') and talk_state == 1 and string.len(msg) == 11 then

if vocation == 1 then

if doPlayerRemoveMoney(cid,1500) == 1 then

selfSay('Você aprendeu a magia, para usá-la fale extreme ice invocation.')

playerLearnInstantSpell(cid, 'extreme invocation')

 

else

selfSay('Você não tem dinheiro.')

end

else

selfSay('Você tem que ser sorcerer para aprender.')

end

 

elseif msgcontains(msg, 'terra perfect') and talk_state == 1 and string.len(msg) == 13 then

if vocation == 5 then

if doPlayerRemoveMoney(cid,1170) == 1 then

selfSay('Você aprendeu a magia, para usá-la fale exori gran mas tera.')

playerLearnInstantSpell(cid, 'terra perfect')

 

else

selfSay('Você não tem dinheiro.')

end

else

selfSay('Você tem que ser sorcerer para aprender.')

end

 

 

elseif msgcontains(msg, 'exevo mas ice hit') and talk_state == 1 and string.len(msg) == 15 then

if vocation == 1 then

if doPlayerRemoveMoney(cid,1350) == 1 then

selfSay('Você aprendeu a magia, para usá-la fale exori mas ice.')

playerLearnInstantSpell(cid, 'exevo mas ice hit')

 

else

selfSay('Você não tem dinheiro.')

end

else

selfSay('Você tem que ser sorcerer para aprender.')

end

 

elseif msgcontains(msg, 'change corpse') and talk_state == 1 and string.len(msg) == 19 then

if vocation == 1 then

if doPlayerRemoveMoney(cid,1600) == 1 then

selfSay('Você aprendeu a magia, para usá-la fale exeta sio.')

playerLearnInstantSpell(cid, 'Change Corpse')

 

else

selfSay('Você não tem dinheiro.')

end

else

selfSay('Você tem que ser sorcerer para aprender.')

end

 

 

talk_state = 0

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

selfSay('Que Fleros o guie em seu árduo caminho.')

focus = 0

talk_start = 0

end

end

end

 

 

 

function onCreatureChangeOutfit(creature)

 

end

 

 

function onThink()

doNpcSetCreatureFocus(focus)

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

if focus > 0 then

selfSay('Adeus.')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Que a sabedoria de Aisha ilumine o seu caminho.')

focus = 0

end

end

end

 

Agradeceria se pudessem me ajudar.

Link para o comentário
https://xtibia.com/forum/topic/176885-problema-com-npc-que-vende-magias/
Compartilhar em outros sites

×
×
  • Criar Novo...