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

TFS 0.X ML up show new spell from spells.xml

gmstrikker

Well-Known Member
Joined
Jul 30, 2014
Messages
458
Solutions
1
Reaction score
50
Is anyone know how to do, if it is possible OFC
To create a script that when players get magic level up, it show the new spells he can use
spells that are from his vocation and in that ml he just got
loading from the spells.xml ?

i put it to work with this script (by create a new list):
Code:
local spells = {
[1] = { -- sorcerer
  level = {
        [1] = {
            "Name: find person. Words: Exiva.", 
            "Name: magic rope. Words: exani tera.", 
            "Name: cure poison. Words: exana pox.", 
            "Name: food. Words: exevo pan.", 
            "Name: levitate. Words: exani hur."
        },
        [2] = {
            "Name: death strike. Words: exori mort.",
            "Name: light healing. Words: exura.",
            "Name: magic shield. Words: utamo vita.", 
            "Name: poison field. Words: adevo grav pox.", 
        },
        [3] = {
            "Name: intense healing. Words: exura gran.",
            "Name: heavy magic missile. Words: adori gran.",
            "Name: energy strike. Words: exori vis.",
            "Name: flame strike. Words: exori flam.",
            "Name: great light. Words: utevo gran lux.",
            "Name: fire field. Words: adevo grav flam."
        },
        [4] = {
            "Name: haste. Words: utani hur.", 
            "Name: magic shield. Words: utamo vita."
        },
        [5] = {
            "Name: ice strike. Words: exori frigo.",
            "Name: energy field. Words: adevo grav vis."
        },
        [6] = {
            "Name: poison strike. Words: exori pox.",
            "Name: destroy field. Words: adito grav."
        },
        [7] = {
            "Name: fire wave. Words: exevo flam hur."
        },
        [8] = {
            "Name: ultimate healing. Words: exura vita.",
            "Name: strong haste. Words: utani gran hur."
        },
        [9] = {
            "Name: fire bomb. Words: adevo mas flam.",
            "Name: great fireball. Words: adori gran flam."
        },
        [10] = {
            "Name: creature illusion. Words: utevo res ina."
        },
        [12] = {
            "Name: ultimate light. Words: utevo vis lux.",
            "Name: explosion. Words: adevo mas hur."
        },
        [13] = {
            "Name: soul fire. Words: adevo res flam."
        },
        [14] = {
            "Name: magic wall. Words: adevo grav tera."
        },
        [15] = {
            "Name: invisible. Words: utana vid."
        },
        [16] = {
            "Name: summon creature. Words: utevo res."
        },
        [18] = {
            "Name: energy bomb. Words: adevo mas vis.",
            "Name: energy wall. Words: adevo mas grav vis.",
            "Name: poison wall. Words: adevo mas grav pox."
        },
        [20] = {
            "Name: mort wave. Words: exevo mort hur."
        },
        [22] = {
            "Name: enchant staff. Words: exeta vis."
        },
        [25] = {
            "Name: sudden death. Words: adori vita vis."
        },
        [33] = {
            "Name: fire wall. Words: adevo mas grav flam."
        },
        [40] = {
            "Name: ultimate explosion. Words: exevo gran mas vis."
        }
  }
},
[2] = { --druid
level = {
        [1] = {
            "Name: find person. Words: Exiva.", 
            "Name: magic rope. Words: exani tera.", 
            "Name: cure poison. Words: exana pox.", 
            "Name: food. Words: exevo pan.", 
            "Name: levitate. Words: exani hur."
        },
        [2] = {
            "Name: Death Strike. Words: Exori Mort.",
            "Name: light healing. Words: exura.",
            "Name: magic shield. Words: utamo vita.", 
            "Name: poison field. Words: adevo grav pox."
        },
        [3] = {
            "Name: intense healing. Words: exura gran.",
            "Name: heavy magic missile. Words: adori gran.",
            "Name: energy strike. Words: exori vis.",
            "Name: flame strike. Words: exori flam.",
            "Name: great light. Words: utevo gran lux.",
            "Name: fire field. Words: adevo grav flam."
        },
        [4] = {
            "Name: haste. Words: utani hur.", 
            "Name: magic shield. Words: utamo vita."
        },
        [5] = {
            "Name: ice strike. Words: exori frigo.",
            "Name: energy field. Words: adevo grav vis."
        },
        [6] = {
            "Name: poison strike. Words: exori pox.",
            "Name: destroy field. Words: adito grav."
        },
        [7] = {
            "Name: heal friend. Words: exura sio."
        },
        [8] = {
            "Name: ultimate healing. Words: exura vita.",
            "Name: strong haste. Words: utani gran hur.",
            "Name: ice wave. Words: exevo frigo hur."
        },
        [9] = {
            "Name: fire bomb. Words: adevo mas flam.",
            "Name: great fireball. Words: adori gran flam."
        },
        [10] = {
            "Name: icicle. Words: adori frigo.",
            "Name: creature illusion. Words: utevo res ina."
        },
        [11] = {
            "Name: Ultimate Healing Rune. Words: Adura Vita."
        },
        [12] = {
            "Name: ultimate light. Words: utevo vis lux."
        },
        [13] = {
            "Name: soul fire. Words: adevo res flam."
        },
        [14] = {
            "Name: wild growth. Words: adevo grav vita."
        },
        [15] = {
            "Name: invisible. Words: utana vid.",
            "Name: mass healing. Words: exura gran mas res."
        },
        [16] = {
            "Name: summon creature. Words: utevo res."
        },
        [18] = {
            "Name: energy bomb. Words: adevo mas vis.",
            "Name: energy wall. Words: adevo mas grav vis.",
            "Name: poison wall. Words: adevo mas grav pox."
        },
        [25] = {
            "Name: avalanche. Words: adori gran frigo."
        },
        [28] = {
            "Name: wrath of nature. Words: exevo gran mas pox."
        },
        [33] = {
            "Name: fire wall. Words: adevo mas grav flam."
        },
        [35] = {
            "Name: paralyze. Words: adana ani."
        }
  }
},
[3] = { --paladin
  level = {
        [1] = {
            "Name: find person. Words: Exiva.", 
            "Name: magic rope. Words: exani tera.", 
            "Name: cure poison. Words: exana pox.", 
            "Name: food. Words: exevo pan.", 
            "Name: levitate. Words: exani hur.",
            "Name: conjure arrow. Words: exevo con."
        },
        [2] = {
            "Name: light healing. Words: exura.",
            "Name: magic shield. Words: utamo vita."
        },
        [3] = {
            "Name: intense healing. Words: exura gran.",
            "Name: great light. Words: utevo gran lux.",
            "Name: conjure poison arrow. Words: exevo con pox."
        },
        [4] = {
            "Name: haste. Words: utani hur.", 
            "Name: magic shield. Words: utamo vita."
        },
        [6] = {
            "Name: ultimate healing. Words: exura vita."
        },
  }
},
[4] = { --knight
  level = {
        [1] = {
            "Name: find person. Words: Exiva.", 
            "Name: magic rope. Words: exani tera.", 
            "Name: cure poison. Words: exana pox.", 
            "Name: levitate. Words: exani hur.",   
            "Name: levitate. Words: exani hur."
        },
        [2] = {
            "Name: light healing. Words: exura."
        },
        [3] = {
            "Name: wound cleansing. Words: exana mort.",
            "Name: great light. Words: utevo gran lux."
        },
        [4] = {
            "Name: challenge. Words: exeta res.",
            "Name: haste. Words: utani hur."
        },
        [5] = {
            "Name: berserk. Words: exori."
        }
  }
}
}
local vocs = {
  {1,5,9},
  {2,6,10},
  {3,7,11},
  {4,8,12}
}

local vocationSpells = {}

function onAdvance(cid, skill, oldLevel, newLevel)
    if skill == 7 then
        for i, class in ipairs(vocs) do
            if isInArray(class, getPlayerVocation(cid)) then
                vocationSpells = spells[i]
            end
        end
   
        if vocationSpells == nil then
            return false
        end

        if oldLevel > newLevel then
            return false
        end

        local lvl = getPlayerMagLevel(cid, false)
        local playerSpells = vocationSpells.level[lvl]
   
        if playerSpells == nil or #playerSpells == 0 then
            return false
        end
   
        for x = 1, #playerSpells do
            doPlayerSendTextMessage(cid, 20, "[NEW-SPELL] "..playerSpells[x]..".")
        end
    end
    return true
end

i want some more dynamic :(
everytime i create a new spell i have to change on spell seller npc, spells.xml and on this, is it possible guys?
but its pretty sucks to manage, add, remove, change any spell, maybe i forgot some spells, but if anyone want to use, that is what i'm using by now...
 
Solution
i tried even:
Code:
--[[------------------------------------------------<|]
    |* * * * * * * * * * * * * * * * * * * * * * * * * * *|
    |* * * * * * *  [SpellUp! Script] * * * * * * * * * * |
    |* * * * * * * * By: Cybermaster * * * * * * * * * * *|    
    |* * *  Tested on: The Forgotten Server 0.3.6pl1 * * *|
    |* * * * * * * * * * * * * * * * * * * * * * * * * * *|
    |>---------------------------------------------------]]

local s = { --SETUP
    repeatAfterDeath = true, -- 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...
Have you tried this one


To use as Magic Level instead of Level its just change:
Code:
function onAdvance(cid, skill, oldlevel, newlevel)
    if skill ~= SKILL__LEVEL or not s.repeatAfterDeath and getCreatureStorage(cid, s.Storage) >= newlevel then
        return true
    end

For
Code:
    if skill ~= 7 or not s.repeatAfterDeath and getCreatureStorage(cid, s.Storage) >= newlevel then
        return true
    end
 
I manage to change from level up to magic level up
But there is a problem...

Spells with:
needlearn="1"
That players didn't buy is not showing on...

Anyone can help me to fix it? To show spells even if player don't have it?

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

local s = { --SETUP
    repeatAfterDeath = true, -- 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 = 'popUp', -- options: 'popUp' or 'channel'
--this one below only used if messageType = channel
    channelClass = MESSAGE_EVENT_ORANGE
}
   
function onAdvance(cid, skill, oldlevel, newlevel)
    if skill ~= 7 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.mlevel ~= 0) and spell.mlevel == 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 = ''
    for i, spell in ipairs(t) do
        text = 'NEW SPELL:\n['..spell.name..'] "'..spell.words..'" '..(s.detailedInfo and ', mana:'..spell.mana..'' 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
 
I manage to change from level up to magic level up
But there is a problem...

Spells with:
needlearn="1"
That players didn't buy is not showing on...

Anyone can help me to fix it? To show spells even if player don't have it?

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

local s = { --SETUP
    repeatAfterDeath = true, -- 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 = 'popUp', -- options: 'popUp' or 'channel'
--this one below only used if messageType = channel
    channelClass = MESSAGE_EVENT_ORANGE
}
  
function onAdvance(cid, skill, oldlevel, newlevel)
    if skill ~= 7 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.mlevel ~= 0) and spell.mlevel == 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 = ''
    for i, spell in ipairs(t) do
        text = 'NEW SPELL:\n['..spell.name..'] "'..spell.words..'" '..(s.detailedInfo and ', mana:'..spell.mana..'' 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

bump
 
why spells that needlearn="1" is not working guys? :(

i wanted to do a server where players need to buy the spells
 
thank you a lot man

but in my source there is not info about can cast for spellinfo used on script:

can u give a hand?

spells.cpp
after InstantSpell* Spells::getInstantSpellByIndex(const Player* player, uint32_t index) {...} add:

C++:
InstantSpell* Spells::getInstantSpellByIndexCustom(const Player* player, uint32_t index)
{
    uint32_t count = 0;
    for(InstantsMap::iterator it = instants.begin(); it != instants.end(); ++it)
    {
        InstantSpell* instantSpell = it->second;
        if(count == index)
            return instantSpell;

        ++count;
    }

    return NULL;
}

spells.h
after InstantSpell* getInstantSpellByIndex(const Player* player, uint32_t index); add:

C++:
InstantSpell* getInstantSpellByIndexCustom(const Player* player, uint32_t index);

luascript.cpp
inside int32_t LuaInterface::luaGetPlayerInstantSpellInfo(lua_State* L) {...} change:

from: InstantSpell* spell = g_spells->getInstantSpellByIndex(player, index);
to: InstantSpell* spell = g_spells->getInstantSpellByIndexCustom(player, index);

save, compile, test :p
 
spells.cpp
after InstantSpell* Spells::getInstantSpellByIndex(const Player* player, uint32_t index) {...} add:

C++:
InstantSpell* Spells::getInstantSpellByIndexCustom(const Player* player, uint32_t index)
{
    uint32_t count = 0;
    for(InstantsMap::iterator it = instants.begin(); it != instants.end(); ++it)
    {
        InstantSpell* instantSpell = it->second;
        if(count == index)
            return instantSpell;

        ++count;
    }

    return NULL;
}

spells.h
after InstantSpell* getInstantSpellByIndex(const Player* player, uint32_t index); add:

C++:
InstantSpell* getInstantSpellByIndexCustom(const Player* player, uint32_t index);

luascript.cpp
inside int32_t LuaInterface::luaGetPlayerInstantSpellInfo(lua_State* L) {...} change:

from: InstantSpell* spell = g_spells->getInstantSpellByIndex(player, index);
to: InstantSpell* spell = g_spells->getInstantSpellByIndexCustom(player, index);

save, compile, test :p

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

local s = { --SETUP
    repeatAfterDeath = true, -- 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 = 'popUp', -- options: 'popUp' or 'channel'
--this one below only used if messageType = channel
    channelClass = MESSAGE_EVENT_ORANGE
}
   
function onAdvance(cid, skill, oldlevel, newlevel)
    if skill ~= 7 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 = getInstantSpellByIndexCustom((cid, i)
        if(spell.mlevel ~= 0) and spell.mlevel == 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 = ''
    for i, spell in ipairs(t) do
        text = 'NEW SPELL:\n['..spell.name..'] "'..spell.words..'" '..(s.detailedInfo and ', mana:'..spell.mana..'' 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

but its not showing anything when i get new mlvl
 
i tried even:
Code:
--[[------------------------------------------------<|]
    |* * * * * * * * * * * * * * * * * * * * * * * * * * *|
    |* * * * * * *  [SpellUp! Script] * * * * * * * * * * |
    |* * * * * * * * By: Cybermaster * * * * * * * * * * *|    
    |* * *  Tested on: The Forgotten Server 0.3.6pl1 * * *|
    |* * * * * * * * * * * * * * * * * * * * * * * * * * *|
    |>---------------------------------------------------]]

local s = { --SETUP
    repeatAfterDeath = true, -- 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 = 'popUp', -- options: 'popUp' or 'channel'
--this one below only used if messageType = channel
    channelClass = MESSAGE_EVENT_ORANGE
}
  
function onAdvance(cid, skill, oldlevel, newlevel)
    if skill ~= 7 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 = getInstantSpellByIndexCustom((cid, i)
        if(spell.mlevel ~= 0) and spell.mlevel == 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 = ''
    for i, spell in ipairs(t) do
        text = 'NEW SPELL:\n['..spell.name..'] "'..spell.words..'" '..(s.detailedInfo and ', mana:'..spell.mana..'' 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

but its not showing anything when i get new mlvl

Do not modify your Lua scripts, use your original code -> link

I missed this part, you need to change one more thing:

spells.cpp
replace uint32_t Spells::getInstantSpellCount(const Player* player) {...} with:

C++:
uint32_t Spells::getInstantSpellCount(const Player* player)
{
    uint32_t count = 0;
    for(InstantsMap::iterator it = instants.begin(); it != instants.end(); ++it)
    {
        ++count;
    }

    return count;
}

Let me know how that goes :D
 
Solution
Do not modify your Lua scripts, use your original code -> link

I missed this part, you need to change one more thing:

spells.cpp
replace uint32_t Spells::getInstantSpellCount(const Player* player) {...} with:

C++:
uint32_t Spells::getInstantSpellCount(const Player* player)
{
    uint32_t count = 0;
    for(InstantsMap::iterator it = instants.begin(); it != instants.end(); ++it)
    {
        ++count;
    }

    return count;
}

Let me know how that goes :D

THANK YOU <3

trying to understand the codes u show me, i got one last question...
would be possible to show runes u can use when get ml up?
 
THANK YOU <3

trying to understand the codes u show me, i got one last question...
would be possible to show runes u can use when get ml up?

I believe this will require source edits on its own. You will want to have similar structure to how spells are being fetched. At least that's how it's done in latest TFS, not really familiar with 0.x and not sure if you can get on-level up runes for your voc.

What you can do instead is to provide dummy data inside your spells.xml and create sample lightweight Lua script that does nothing. This will be linked to all of your runes and will be synced with your already created function. I can't test it on my own right now unfortunately.

Alternatively, if you don't mind players making their own runes using spells then that's another way.

You can create new thread if you need further help
 
I believe this will require source edits on its own. You will want to have similar structure to how spells are being fetched. At least that's how it's done in latest TFS, not really familiar with 0.x and not sure if you can get on-level up runes for your voc.

What you can do instead is to provide dummy data inside your spells.xml and create sample lightweight Lua script that does nothing. This will be linked to all of your runes and will be synced with your already created function. I can't test it on my own right now unfortunately.

Alternatively, if you don't mind players making their own runes using spells then that's another way.

You can create new thread if you need further help

It has an error i didn't know, it was showing only one spell, even if u had more to show...
I manage to fix it:

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

local s = { --SETUP
    repeatAfterDeath = true, -- true -> player will always get the msg at lvlup | false -> player will only get the 1st time the gets the new level
-- storage below is where the newlevel will be stored ONLY IF YOU USE repeatAfterDeath
    Storage = 10000,
    messageType = 'popUp', -- options: 'popUp' or 'channel'
--this one below only used if messageType = channel
    channelClass = MESSAGE_EVENT_ORANGE
}
   
function onAdvance(cid, skill, oldlevel, newlevel)
    if skill ~= 7 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.mlevel ~= 0) and spell.mlevel == 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 tmpStr = ''
    local Str = ''
    for i, spell in ipairs(t) do
        tmpStr = 'NEW SPELL:\n['..spell.name..'] "'..spell.words..'"\n\n'
        Str = Str .. tmpStr
    end
 
    if Str == '' then
        return true
    end
 
    doCreatureSetStorage(cid, s.Storage, newlevel)
    if s.messageType == 'popUp' then
        doShowTextDialog(cid, 2175, Str)
    elseif s.messageType == 'channel' then
        doPlayerSendTextMessage(cid, s.channelClass, Str)
    end
    return true
end

but with your sources changes become an bug:
There is no vocation verification

so when warriors get ml up, it shows mages,archers spells so as mages, archers, it show eveything to everyone :(

---

why the first one shows {, instead [
 
its not solved... how to unmark as solved?


It has an error i didn't know, it was showing only one spell, even if u had more to show...
I manage to fix it:

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

local s = { --SETUP
    repeatAfterDeath = true, -- true -> player will always get the msg at lvlup | false -> player will only get the 1st time the gets the new level
-- storage below is where the newlevel will be stored ONLY IF YOU USE repeatAfterDeath
    Storage = 10000,
    messageType = 'popUp', -- options: 'popUp' or 'channel'
--this one below only used if messageType = channel
    channelClass = MESSAGE_EVENT_ORANGE
}
  
function onAdvance(cid, skill, oldlevel, newlevel)
    if skill ~= 7 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.mlevel ~= 0) and spell.mlevel == 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 tmpStr = ''
    local Str = ''
    for i, spell in ipairs(t) do
        tmpStr = 'NEW SPELL:\n['..spell.name..'] "'..spell.words..'"\n\n'
        Str = Str .. tmpStr
    end

    if Str == '' then
        return true
    end

    doCreatureSetStorage(cid, s.Storage, newlevel)
    if s.messageType == 'popUp' then
        doShowTextDialog(cid, 2175, Str)
    elseif s.messageType == 'channel' then
        doPlayerSendTextMessage(cid, s.channelClass, Str)
    end
    return true
end

but with your sources changes become an bug:
There is no vocation verification

so when warriors get ml up, it shows mages,archers spells so as mages, archers, it show eveything to everyone :(

---

why the first one shows {, instead [

bump
 
Back
Top