Nothxbye
Banned User
- Joined
- Jan 22, 2012
- Messages
- 1,124
- Reaction score
- 174
I have this script:
But if i wanna buy 'light magic missile' npc asks if i wanna buy spell 'light'
Player: Hi
NPC: hi
Player: buy light magic missile
NPC: Do you want to buy the spell 'light' for 100 gold?
How to fix that?
Code:
local spells = {
["find person"] = {price = 80},
["light healing"] = {price = 170},
["light"] = {price = 100},
["antidote"] = {price = 150},
["intense healing"] = {price = 350},
["poison field"] = {price = 300},
["great light"] = {price = 500},
["fire field"] = {price = 500},
["heavy magic missile"] = {price = 1500},
["magic shield"] = {price = 450},
["energy field"] = {price = 700},
["destroy field"] = {price = 700},
["fire wave"] = {price = 850},
["ultimate healing"] = {price = 1000},
["great fireball"] = {price = 1200},
["fireball"] = {price = 800},
["light magic missile"] = {price = 500},
["fire bomb"] = {price = 1500},
["great energy beam"] = {price = 1800},
["energy beam"] = {price = 1000},
["creature illusion"] = {price = 1000},
["poison wall"] = {price = 1600},
["explosion"] = {price = 1800},
["fire wall"] = {price = 2000},
["invisible"] = {price = 2000},
["summon creature"] = {price = 2000},
["energy wall"] = {price = 2500},
["energy wave"] = {price = 2500},
["sudden death"] = {price = 3000}
}
local profession = getPlayerVocation(cid)
if (profession == 1) or (profession == 5) then
for v in pairs(spells) do
if (msgcontains(msg, v)) then
npcHandler:say("Do you want to buy the spell '"..v.."' for "..spells[v].price.." gold?", cid)
talkState[talkUser] = 1
cost = spells[v].price
spell = v
end
end
end
Code:
function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str))
end
But if i wanna buy 'light magic missile' npc asks if i wanna buy spell 'light'
Player: Hi
NPC: hi
Player: buy light magic missile
NPC: Do you want to buy the spell 'light' for 100 gold?
How to fix that?