Ir para conteúdo

Problema No Npc Q Vende Magias


fnd13

Posts Recomendados

Olá pessoal, bem meu npc que vende magias esta dando uns pequenos problemas, porém nao consigo identificar:

spellsknight.lua:170 'end' expected <to close 'if' at line 68> near '<eof>'

 

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)

   local msg = string.lower(msg)

if ((string.find(msg, '(%a*)hi(%a*)')) and (focus == 0)) and getDistanceToCreature(cid) < 4 then

   if getPlayerVocation(cid) == 4 then

   selfSay('Hello ' .. creatureGetName(cid) .. '! What spell do you want to learn?')

   focus = cid

   talk_start = os.clock()

   else

   selfSay('Sorry, I sell spells for knights.')

end

elseif string.find(msg, '(%a*)hi(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

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



   elseif focus == cid then

   talk_start = os.clock()

   if msgcontains(msg, 'annihilation') and focus == cid then

   if pay(cid,170) then

   learnSpell(cid,'exori gran ico')

   else selfSay('Sorry, you don\'t have enough money.')

   talk_start = os.clock()

   end

   if msgcontains(msg, 'blood rage') and focus == cid then

   if pay(cid,170) then

   learnSpell(cid,'utito tempo')

   else selfSay('Sorry, you don\'t have enough money.')

   talk_start = os.clock()

   end

   if msgcontains(msg, 'brutal strike') and focus == cid then

   if pay(cid,170) then

   learnSpell(cid,'exori ico')

   else selfSay('Sorry, you don\'t have enough money.')

   talk_start = os.clock()

   end

   if msgcontains(msg, 'challenge') and focus == cid then

   if pay(cid,170) then

   learnSpell(cid,'exeta res')

   else selfSay('Sorry, you don\'t have enough money.')

   talk_start = os.clock()

   end

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

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

   focus = 0

   talk_start = 0

  end

   end

end





function onCreatureChangeOutfit(creature)



end





function onThink()

   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

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)

local msg = string.lower(msg)

if ((string.find(msg, '(%a*)hi(%a*)')) and (focus == 0)) and getDistanceToCreature(cid) < 4 then
   if getPlayerVocation(cid) == 4 then
       selfSay('Hello ' .. creatureGetName(cid) .. '! What spell do you want to learn?')        
       focus = cid
       talk_start = os.clock()
   else
       selfSay('Sorry, I sell spells for knights.')
   end
elseif string.find(msg, '(%a*)hi(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
   selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')
elseif focus == cid then
   talk_start = os.clock()
   if msgcontains(msg, 'annihilation') and focus == cid then
       if pay(cid,170) then
           learnSpell(cid,'exori gran ico')
       else selfSay('Sorry, you don\'t have enough money.')
           talk_start = os.clock()
       end
   end
   if msgcontains(msg, 'blood rage') and focus == cid then
       if pay(cid,170) then
           learnSpell(cid,'utito tempo')
       else selfSay('Sorry, you don\'t have enough money.')
           talk_start = os.clock()
       end
   end    
   if msgcontains(msg, 'brutal strike') and focus == cid then
       if pay(cid,170) then
           learnSpell(cid,'exori ico')
       else selfSay('Sorry, you don\'t have enough money.')
           talk_start = os.clock()
       end
   end
   if msgcontains(msg, 'challenge') and focus == cid then
       if pay(cid,170) then
           learnSpell(cid,'exeta res')
       else selfSay('Sorry, you don\'t have enough money.')
           talk_start = os.clock()
       end
   end
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end

function onCreatureChangeOutfit(creature)
end

function onThink()

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

na parte da função onCreatureSay, faltou fechar com "end" três "if".

Exemplo:

 

Antes -

if msgcontains(msg, 'blood rage') and focus == cid then
       if pay(cid,170) then
           learnSpell(cid,'utito tempo')
       else selfSay('Sorry, you don\'t have enough money.')
           talk_start = os.clock()
end   

 

Depois -

if msgcontains(msg, 'blood rage') and focus == cid then
       if pay(cid,170) then
           learnSpell(cid,'utito tempo')
       else selfSay('Sorry, you don\'t have enough money.')
           talk_start = os.clock()
       end
end    

 

Dica: Quando criar um código lembra de levar organizadinho pra vc n se perder depois.

Link para o comentário
Compartilhar em outros sites

  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...