• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Spell Npc

bruxo

Mirage Team
Joined
Oct 8, 2007
Messages
33
Reaction score
1
Location
Porto Alegre, Brazil
I need some help with my spells npcs xD.

I will say the bug, if he say light healing, he buy light o_O, and he can buy the same spell 2x...

The script:

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á, eu sou o l?*der da Guilda dos Knights, você quer aprender alguma magia comigo?')
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('Eu posso lhe ensinar muitas magias, se você for knight, é claro. Qual que você quer aprender? Não utilize espaços.')
talk_state = 1

vocation = getPlayerVocation(cid)
elseif msgcontains(msg, 'lighthealing') and talk_state == 1 then
if vocation == 4 then
if doPlayerRemoveMoney(cid,170) == 1 then
selfSay('Você aprendeu a magia, para usá-la fale exura.')
playerLearnInstantSpell(cid, 'light healing')

else
selfSay('Você não tem dinheiro.')
end
else
selfSay('Você tem que ser knight para aprender.')
end


elseif msgcontains(msg, 'light') and talk_state == 1 then
if vocation == 4 then
if doPlayerRemoveMoney(cid,100) == 1 then
selfSay('Você aprendeu a magia, para usá-la fale utevo lux.')
playerLearnInstantSpell(cid, 'light')

else
selfSay('Você não tem dinheiro.')
end
else
selfSay('Você tem que ser knight para aprender.')
end

elseif msgcontains(msg, 'findperson') and talk_state == 1 then
if vocation == 4 then
if doPlayerRemoveMoney(cid,80) == 1 then
selfSay('Você aprendeu a magia, para usá-la fale exiva "nome.')
playerLearnInstantSpell(cid, 'find person')

else
selfSay('Você não tem dinheiro.')
end
else
selfSay('Você tem que ser knight para aprender.')
end

elseif msgcontains(msg, 'antidote') and talk_state == 1 then
if vocation == 4 then
if doPlayerRemoveMoney(cid,150) == 1 then
selfSay('Você aprendeu a magia, para usá-la fale exana pox.')
playerLearnInstantSpell(cid, 'antidote')

else
selfSay('Você não tem dinheiro.')
end
else
selfSay('Você tem que ser knight para aprender.')
end

elseif msgcontains(msg, 'greatlight') and talk_state == 1 then
if vocation == 4 then
if doPlayerRemoveMoney(cid,500) == 1 then
selfSay('Você aprendeu a magia, para usá-la fale utevo gran lux.')
playerLearnInstantSpell(cid, 'great light')

else
selfSay('Você não tem dinheiro.')
end
else
selfSay('Você tem que ser knight para aprender.')
end

talk_state = 0
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Adeus!')
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('Próximo por favor.')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Vá.')
focus = 0
end
end
end

Srry by bad english.
 
Yes, translate it to english, then i can help.

But i just now see that there is needed getPlayerLearnedInstantSpell, this will check that player have this spell already.
 
Translating for english for you...

Code:
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('Hi, I'm leader of Knights guild, Do you want to lear some spell?')
focus = cid
talk_state = 0
talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Wait, now i'm busy.')

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

if msgcontains(msg, 'yes') then
selfSay('I can teach you some spells, if you are a knight ofcourse. What spell you want to lean?')
talk_state = 1

vocation = getPlayerVocation(cid)
elseif msgcontains(msg, 'lighthealing') and talk_state == 1 then
if vocation == 4 then
if doPlayerRemoveMoney(cid,170) == 1 then
selfSay('You learn the spell, to use it, say exura.')
playerLearnInstantSpell(cid, 'light healing')

else
selfSay('You have no money.')
end
else
selfSay('You need be a Knight to learn spells from me.')
end


elseif msgcontains(msg, 'light') and talk_state == 1 then
if vocation == 4 then
if doPlayerRemoveMoney(cid,100) == 1 then
selfSay('You learn the spell, to use it, say utevo lux.')
playerLearnInstantSpell(cid, 'light')

else
selfSay('You have no money.')
end
else
selfSay('You need be a knight to learn spells with me.')
end

elseif msgcontains(msg, 'findperson') and talk_state == 1 then
if vocation == 4 then
if doPlayerRemoveMoney(cid,80) == 1 then
selfSay('You learn the spell, to use it, say exiva "name.')
playerLearnInstantSpell(cid, 'find person')

else
selfSay('You have no money.')
end
else
selfSay('You need be a knight to learn spells with me.')
end

elseif msgcontains(msg, 'antidote') and talk_state == 1 then
if vocation == 4 then
if doPlayerRemoveMoney(cid,150) == 1 then
selfSay('You learn the spell, to use it, say exana pox.')
playerLearnInstantSpell(cid, 'antidote')

else
selfSay('You have no money.')
end
else
selfSay('You need be a knight to learn spells with me.')
end

elseif msgcontains(msg, 'greatlight') and talk_state == 1 then
if vocation == 4 then
if doPlayerRemoveMoney(cid,500) == 1 then
selfSay('You learn the spell, to use it, say utevo gran lux.')
playerLearnInstantSpell(cid, 'great light')

else
selfSay('You have no money.')
end
else
selfSay('You need be a knight to learn spells with me.')
end

talk_state = 0
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye!')
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('Next please.')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Go away.')
focus = 0
end
end
end
 

Similar threads

Back
Top