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

CreatureEvent Spells on Level Up, let players know which spells do they learn!

hodleo

Formerly cbrm -Crypto enthusiast, Retired scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,598
Solutions
3
Reaction score
955
Location
Caribbean Sea
50687113.jpg

Today I modified the action script of the book of spells. This new script shows a message displaying the detailed info of the new spells the player can make/learns when he levels up. If there are not new spells for a new level the script is not activated of course.

CONFIGURATION

repeatAfterDeath

true -> player will always get the msg at lvlup
false -> player will only get the message the 1st time he gets the new level

detailedInfo
true -> player will get name, words, mana & mana% info of spells
false -> player will only get the name and the words of the spells

messageType
'channel' -> displays a channel message with pre-configured message class
'popUp' -> displays a text dialog

channelClass
This option only applies when messageType is 'channel', default value is MESSAGE_EVENT_ORANGE
Lua:
MESSAGE_STATUS_CONSOLE_RED
MESSAGE_EVENT_ORANGE = 19
MESSAGE_STATUS_CONSOLE_ORANGE = 20
MESSAGE_STATUS_WARNING = 21
MESSAGE_EVENT_DEFAULT = 23
MESSAGE_STATUS_DEFAULT = 24
MESSAGE_INFO_DESCR = 25
MESSAGE_STATUS_SMALL = 26
MESSAGE_STATUS_CONSOLE_BLUE = 27

SETUP

*create creaturescripts/scripts/spellup.lua

Lua:
--[[------------------------------------------------<|]
    |* * * * * * * * * * * * * * * * * * * * * * * * * * *|
    |* * * * * * *  [SpellUp! Script] * * * * * * * * * * |
    |* * * * * * * * By: Cybermaster * * * * * * * * * * *|     
    |* * *  Tested on: The Forgotten Server 0.3.6pl1 * * *|
    |* * * * * * * * * * * * * * * * * * * * * * * * * * *|
    |>---------------------------------------------------]]

local s = { --SETUP
    repeatAfterDeath = false, -- true -> player will always get the msg at lvlup | false -> player will only get the 1st time the gets the new level
    detailedInfo = true, -- true -> player will get name, words, mana & mana% info of spells | false -> player will only get the name and the words of the spells
-- storage below is where the newlevel will be stored ONLY IF YOU USE repeatAfterDeath
    Storage = 10000,
    messageType = 'channel', -- options: 'popUp' or 'channel'
--this one below only used if messageType = channel
    channelClass = MESSAGE_EVENT_ORANGE
    }
   
function onAdvance(cid, skill, oldlevel, newlevel)
    if skill ~= SKILL__LEVEL or not s.repeatAfterDeath and getCreatureStorage(cid, s.Storage) >= newlevel then
        return true
    end
 
    local t = {}
    for i = 0, getPlayerInstantSpellCount(cid) - 1 do
        local spell = getPlayerInstantSpellInfo(cid, i)
        if(spell.level ~= 0) and spell.level == newlevel then
            if(spell.manapercent > 0) then
                spell.mana = spell.manapercent .. '%'
            end
            table.insert(t, spell)
        end
    end

    table.sort(t, function(a, b) return a.level < b.level end)
    local text, prevLevel = '', -1
    for i, spell in ipairs(t) do
        local line = ''
        if(prevLevel ~= spell.level) then
            if(i ~= 1) then
                line = '\n'
            end

            line = line .. 'You have just advanced to level '..newlevel..' and learned new spells!\n'
            prevLevel = spell.level
        end
        text = text ..line..' ['..spell.name..'] "'..spell.words..'" '..(s.detailedInfo and 'Mana['..spell.mana..']'..(spell.mlevel > 0 and ' ML['..spell.mlevel..']' or '') or '')..'\n'
    end
 
    if text == '' then
        return true
    end
 
    doCreatureSetStorage(cid, s.Storage, newlevel)
    if s.messageType == 'popUp' then
        doShowTextDialog(cid, 2175, text)
    elseif s.messageType == 'channel' then
        doPlayerSendTextMessage(cid, s.channelClass, text)
    end
    return true
end

*add@creaturescripts/creaturescripts.xml
XML:
<event type="advance" name="SpellUp" event="script" value="spellup.lua"/>

*register@creaturescripts/scripts/login.lua
Lua:
registerCreatureEvent(cid,'SpellUp')

That's all you have to do :peace:
 
Last edited:
i like it. its a really nice idea. especially for servers that have loads of custom spells.
 
thanks :) keep commenting
 
Great idea Rep++ ;d
 
Really a great idea for some spells are not very used to end up getting forgotten and unused.

Nice Job.

;]
 
Back
Top