whitevo
Feeling good, thats what I do.
Working Code
Code:
local spells = {
["Barrier"] = {
actionID = 1102,
vocation = function(cid) return isSorcerer(cid) end,
vocation2 = "sorcerer",
minL = 2
}
}
function onUse(cid, item)
local itemID = item.actionid
local L = getPlayerLevel(cid)
local player = Player(cid)
for k, v in pairs(spells) do
if itemID == spells[k].actionID then
if spells[k].vocation(player) then
if L >= spells[k].minL then
if getPlayerLearnedInstantSpell(cid, k) == false then
playerLearnInstantSpell(cid, k)
player:sendTextMessage(MESSAGE_INFO_DESCR, "you learned " ..k.. " spell")
--possibly different text color than default green
doRemoveItem(item.uid, 1)
return true
else player:sendTextMessage(MESSAGE_INFO_DESCR, "You already know this spell")
return true
end
else player:sendTextMessage(MESSAGE_INFO_DESCR, "Need level " ..spells[k].minL.. ", to learn this spell")
return true
end
else player:sendTextMessage(MESSAGE_INFO_DESCR, "This is "..spells[k].vocation2.." spell")
--possibly different text color than default green
end
end
end
end
Last edited: