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

Spells from chest

Call Me saul

New Member
Joined
Oct 18, 2023
Messages
22
Reaction score
0
GitHub
callmesaul
TFS 1.4.2
i've 4 spells for (ed, rp, ms, ek) so i need when you click on chest or use book you learn spell depends on what vocation you are
also i need when you havent click or use book saying you need to make q first smth like that
 
Last edited:
I haven't tested it yet..

Lua:
local spellConfig = {
    ["knight"] = "utani hur",
    ["sorcerer"] = "exura",
    ["druid"] = "heal",
    ["paladin"] = "exori",
    ["spell_id"] = 6527 -- Spell book ID
}

local Spellaction = Action()

function Spellaction.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local vocation = player:getVocation():getName():lower()
    if not player:hasLearnedSpell(spellConfig[vocation]) then
        player:learnInstantSpell(spellConfig[vocation])
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have learned the spell " .. spellConfig[vocation] .. "!")
        item:remove(1)
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have already learned this spell.")
    end
    
    return true
end

Spellaction:id(spellConfig["spell_id"])
Spellaction:register()
 
I haven't tested it yet..

Lua:
local spellConfig = {
    ["knight"] = "utani hur",
    ["sorcerer"] = "exura",
    ["druid"] = "heal",
    ["paladin"] = "exori",
    ["spell_id"] = 6527 -- Spell book ID
}

local Spellaction = Action()

function Spellaction.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local vocation = player:getVocation():getName():lower()
    if not player:hasLearnedSpell(spellConfig[vocation]) then
        player:learnInstantSpell(spellConfig[vocation])
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have learned the spell " .. spellConfig[vocation] .. "!")
        item:remove(1)
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have already learned this spell.")
    end
 
    return true
end

Spellaction:id(spellConfig["spell_id"])
Spellaction:register()
I haven't tested it yet..

Lua:
local spellConfig = {
    ["knight"] = "utani hur",
    ["sorcerer"] = "exura",
    ["druid"] = "heal",
    ["paladin"] = "exori",
    ["spell_id"] = 6527 -- Spell book ID
}

local Spellaction = Action()

function Spellaction.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local vocation = player:getVocation():getName():lower()
    if not player:hasLearnedSpell(spellConfig[vocation]) then
        player:learnInstantSpell(spellConfig[vocation])
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have learned the spell " .. spellConfig[vocation] .. "!")
        item:remove(1)
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have already learned this spell.")
    end
 
    return true
end

Spellaction:id(spellConfig["spell_id"])
Spellaction:register()
.
 
Last edited:
Back
Top