• 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!

Lua Learn spell based on vocation.

Cornwallis

Member
Joined
Jan 3, 2010
Messages
480
Reaction score
16
I know that there is a bunch of these floating around, but I looked through page by page and couldn't find one that worked. The closest to what i wanted was this one:
Code:
local spellItemID = 2344
local Cancelwords = "You need to have a vocation to learn this spell."
local Sorcererwords = "You've learned the Monster Annihilation Spell, it can only be used on monsters!"
local Druidwords = "You've learned the Monster Annihilation Spell, it can only be used on monsters!"
local Paladinwords = "You've learned the Monster Annihilation Spell, it can only be used on monsters!"
local Knightwords = "You've learned the Monster Annihilation Spell, it can only be used on monsters!"
local Butcherwords = "You've learned the Monster Annihilation Spell, it can only be used on monsters!"
local reqLevel = 1
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
        if item.itemid == spellItemID and (getPlayerVocation(cid) == 1) and getPlayerLevel(cid) >= reqLevel then
                playerLearnInstantSpell(cid, "Sorcerer Monster Annihilation")
                doCreatureSay(cid, Sorcererwords, 19)
                doRemoveItem(cid, item.uid, 1)
        elseif item.itemid == spellItemID and (getPlayerVocation(cid) == 2) and getPlayerLevel(cid) >= reqLevel then
                playerLearnInstantSpell(cid, "Druid Monster Annihilation")
                doCreatureSay(cid, Druidwords, 19)
                doRemoveItem(cid, item.uid, 1)
        elseif item.itemid == spellItemID and (getPlayerVocation(cid) == 3) and getPlayerLevel(cid) >= reqLevel then
                playerLearnInstantSpell(cid, "Paladin Monster Annihilation")
                doCreatureSay(cid, Paladinwords, 19)
                doRemoveItem(cid, item.uid, 1)
        elseif item.itemid == spellItemID and (getPlayerVocation(cid) == 4) and getPlayerLevel(cid) >= reqLevel then
                playerLearnInstantSpell(cid, "Knight Monster Annihilation")
                doCreatureSay(cid, Knightwords, 19)
                doRemoveItem(cid, item.uid, 1)
        elseif item.itemid == spellItemID and (getPlayerVocation(cid) == 5) and getPlayerLevel(cid) >= reqLevel then
                playerLearnInstantSpell(cid, "Butcher Monster Annihilation")
                doCreatureSay(cid, Butcherwords, 19)
                doRemoveItem(cid, item.uid, 1)
        else
                doPlayerSendCancel(cid, Cancelwords)
        end
        return 1
end

Btw, I'm using mystic spirit 0.2.11pl2. Thanks in advance
EDIT; When I use the item, it debugs the client, takes the oil lamp, and doesn't give me the spell lol
 
Last edited:
Back
Top