Felipe93
Ghost Member
Hello
I use tfs 1.5 I'm trying to make npcs that sells spells works, the problem is that I'not getting any errors in console
the npc reply to hi bye and if a certain vocation that is not in the array want to get an spell the noc replys that only sells spells to paladins
but when a paladn want to get an spells the npcs does no says nothing and i don't get any error in console
this is part of the code with the spells function
here full lua file
i tried changing part of the code from
to this
but with this i do get error and it does not replies either
I use tfs 1.5 I'm trying to make npcs that sells spells works, the problem is that I'not getting any errors in console
the npc reply to hi bye and if a certain vocation that is not in the array want to get an spell the noc replys that only sells spells to paladins
but when a paladn want to get an spells the npcs does no says nothing and i don't get any error in console
this is part of the code with the spells function
Lua:
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
if getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7 then
else
if msgcontains(msg, '') then
npcHandler:say("Sorry, I only sell spells to paladins.", 1)
return false
end
end
--name the spell--
if msgcontains(msg, 'find person') or msgcontains(msg, 'Find person') then
spellprice = 80
spellvoc = {1, 2, 3, 4, 5, 6, 7, 8}
spellname = "find person"
spellmagiclevel = 0
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for all vocations.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'ultimate healing') or msgcontains(msg, 'Ultimate healing') then
spellprice = 1000
spellvoc = {1, 2, 3, 5, 6, 7}
spellname = "ultimate healing"
spellmagiclevel = 8
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for sorcerers, druids and paladins.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'invisible') or msgcontains(msg, 'Invisible') then
spellprice = 1000
spellvoc = {1, 2, 3, 5, 6, 7}
spellname = "invisible "
spellmagiclevel = 15
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for sorcerers, druids and paladins.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'explosive arrow') or msgcontains(msg, 'Explosive arrow') then
spellprice = 1000
spellvoc = {3, 7}
spellname = "explosive arrow"
spellmagiclevel = 10
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for royal paladins.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'destroy field') or msgcontains(msg, 'Destroy field') then
spellprice = 350
spellvoc = {1, 2, 3, 5, 6, 7}
spellname = "destroy field"
spellmagiclevel = 6
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for sorcerers, druids and paladins.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'poison arrow') or msgcontains(msg, 'Poison arrow') then
spellprice = 700
spellvoc = {3, 7}
spellname = "poison arrow"
spellmagiclevel = 5
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for paladins.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'fireball') or msgcontains(msg, 'fireball') then
spellprice = 800
spellvoc = {1, 2, 3, 5, 6, 7}
spellname = "fireball"
spellmagiclevel = 5
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for sorcerers, druids and paladins.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'magic shield') or msgcontains(msg, 'magic shield') then
spellprice = 450
spellvoc = {1, 2, 3, 5, 6, 7}
spellname = "magic shield"
spellmagiclevel = 4
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for sorcerers, druids and paladins.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'heavy magic missile') or msgcontains(msg, 'Heavy magic missile') then
spellprice = 600
spellvoc = {1, 2, 3, 5, 6, 7}
spellname = "heavy magic missile"
spellmagiclevel = 3
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for sorcerers, druids and paladins.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'great light') or msgcontains(msg, 'Great light') then
spellprice = 500
spellvoc = {1, 2, 3, 4, 5, 6, 7, 8}
spellname = "great light"
spellmagiclevel = 3
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for all vocations.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'conjure arrow') or msgcontains(msg, 'Conjure arrow') then
spellprice = 450
spellvoc = {3, 7}
spellname = "conjure arrow"
spellmagiclevel = 2
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for paladins.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'intense healing') or msgcontains(msg, 'Intense healing') then
spellprice = 350
spellvoc = {1, 2, 3, 5, 6, 7}
spellname = "intense healing"
spellmagiclevel = 2
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for sorcerers, druids and paladins.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'antidote') or msgcontains(msg, 'Antidote') then
spellprice = 150
spellvoc = {1, 2, 3, 4, 5, 6, 7, 8}
spellname = "antidote"
spellmagiclevel = 2
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for all vocations.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'light magic missile') or msgcontains(msg, 'Light magic missile') then
spellprice = 200
spellvoc = {1, 2, 3, 5, 6, 7}
spellname = "light magic missile"
spellmagiclevel = 1
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for sorcerers, druids and paladins.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'light healing') or msgcontains(msg, 'Light healing') then
spellprice = 170
spellvoc = {1, 2, 3, 4, 5, 6, 7, 8}
spellname = "light healing"
spellmagiclevel = 1
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for all vocations.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'create food') or msgcontains(msg, 'Create food') then
spellprice = 150
spellvoc = {2, 3, 6, 7}
spellname = "create food"
spellmagiclevel = 0
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for druids and paladins.", 1)
talk_state = 0
end
elseif msgcontains(msg, 'light') or msgcontains(msg, 'Light') then
spellprice = 100
spellvoc = {1, 2, 3, 4, 5, 6, 7, 8}
spellname = "light"
spellmagiclevel = 0
if isInArray(spellvoc, getPlayerVocation(cid)) then
npcHandler:say("Do you want to learn the spell '".. spellname .."' for ".. spellprice .." gold?", 1)
talk_state = 8754
else
npcHandler:say("I am sorry but this spell is only for all vocations.", 1)
talk_state = 0
end
--End of Give spell--
--System that does the job after confirm spell--
elseif talk_state == 8754 and msgcontains(msg, 'yes') then
if isInArray(spellvoc, getPlayerVocation(cid)) then
if getPlayerMagLevel(cid) >= spellmagiclevel then
if not getPlayerLearnedInstantSpell(cid, spellname) then
if doPlayerRemoveMoney(cid, spellprice) == true then
playerLearnInstantSpell(cid, spellname)
doSendMagicEffect(getPlayerPosition(cid), 14)
npcHandler:say("Here you are. Look in your spellbook for the pronounciation of this spell.", 1)
talk_state = 0
else
npcHandler:say("Oh. You do not have enough money.", 1)
talk_state = 0
end
else
npcHandler:say("You already know how to cast this spell.", 1)
talk_state = 0
end
else
npcHandler:say("You must have magic level ".. spellmagiclevel .." or better to learn this spell!", 1)
talk_state = 0
end
end
elseif talk_state == 8754 and msgcontains(msg, '') then
npcHandler:say("Maybe next time.", 1)
talk_state = 0
--End of the System that does the job after confirm spell--
elseif msgcontains(msg, 'spell') or msgcontains(msg, 'Spell') then
npcHandler:say("I sell 'find person', 'light', 'create food', 'light healing', 'light magic missile', 'antidote', 'intense healing', 'conjure arrow', 'great light', 'heavy magic missile', 'magic shield' and. ...", 1)
npcHandler:say("'fireball', 'poison arrow', 'destroy field', 'ultimate healing', 'explosive arrow' and 'invisible'.", 5)
talk_state = 0
elseif msgcontains(msg, 'missile') or msgcontains(msg, 'Missile') then
npcHandler:say("Paladins are the best missile fighters in Tibia!", 1)
talk_state = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
i tried changing part of the code from
Code:
if getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7 then
else
if msgcontains(msg, '') then
npcHandler:say("Sorry, I only sell spells to paladins.", 1)
return false
end
end
Code:
if player:getVocation():getId() == 3 or player:getVocation():getId() == 7 then
else
if msgcontains(msg, '') then
npcHandler:say("Sorry, I only sell spells to paladins.", 1)
return false
end
end
Code:
: attempt to index global 'player' (a nil value)
Attachments
-
Elane.lua16.7 KB · Views: 1 · VirusTotal