• 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 Show spell on default when up mlvl

gmstrikker

Well-Known Member
Joined
Jul 30, 2014
Messages
458
Solutions
1
Reaction score
50
My script is working fine, but i have a problem with
needlearn = "1"

when i UP magic lvl if needlearn="0", show the spell and all's ok, but if i have needlearn="1" on spell, dont show..
Pls look my script to see
Code:
function onAdvance(cid, skill, oldLevel, newLevel)
   if skill == SKILL__MAGLEVEL then     
     local spells = {}
     for index = 0,    getPlayerInstantSpellCount(cid) - 1 do
       local spell = getPlayerInstantSpellInfo(cid, index)
       if spell.mlevel > oldLevel and spell.mlevel <= newLevel then
         table.insert(spells, "  [".. spell.name .."] \"".. spell.words .. "\" Mana[".. spell.mana .."]")
       end
     end
   
     if #spells > 0 then       
       doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have just advanced to magic level ".. newLevel .." and learned new spells!")

       for _, v in pairs(spells) do
         doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, v)
       end
     end
   end
   
   return true
end

Code:
  <event type="advance" name="SpellUp" event="script" value="spellup.lua"/>
 
This is the output it will generate or something similar :)
Code:
    spells = {
        { type = "instant", name = "Death Strike",  words = "exori mort", level = 16, mana = 20 },
        { type = "instant", name = "Flame Strike",  words = "exori flam", level = 12, mana = 20 },
        { type = "instant", name = "Energy Strike",  words = "exori vis", level = 12, mana = 20 },
        { type = "instant", name = "Whirlwind Throw",  words = "exori hur", level = 15, mana = 40 },
        { type = "instant", name = "Fire Wave",  words = "exevo flam hur", level = 18, mana = 25 },
        { type = "instant", name = "Ethereal Spear",  words = "exori con", level = 23, mana = 25 },
        { type = "instant", name = "Energy Beam",  words = "exevo vis lux", level = 23, mana = 40 },
        { type = "instant", name = "Great Energy Beam",  words = "exevo gran vis lux", level = 29, mana = 110 },
        { type = "instant", name = "Groundshaker",  words = "exori mas", level = 33, mana = 160 },
        { type = "instant", name = "Berserk",  words = "exori", level = 35, mana = 115 },
        { type = "instant", name = "Energy Wave",  words = "exevo vis hur", level = 38, mana = 170 },
        { type = "instant", name = "Rage of the Skies",  words = "exevo gran mas vis", level = 55, mana = 650 },
        { type = "instant", name = "Fierce Berserk",  words = "exori gran", level = 70, mana = 340 },
        { type = "instant", name = "Hells Core",  words = "exevo gran mas flam", level = 60, mana = 1200 },
        { type = "instant", name = "Divine Missile",  words = "exori san", level = 40, mana = 20 },
        { type = "instant", name = "Divine Caldera",  words = "exevo mas san", level = 50, mana = 160 },
        { type = "instant", name = "Eternal Winter",  words = "exevo gran mas frigo", level = 60, mana = 1200 },
        { type = "instant", name = "Ice Strike",  words = "exori frigo", level = 15, mana = 20 },
        { type = "instant", name = "Ice Wave",  words = "exevo frigo hur", level = 18, mana = 25 },
        { type = "instant", name = "Terra Strike",  words = "exori tera", level = 13, mana = 20 },
        { type = "instant", name = "Terra Wave",  words = "exevo tera hur", level = 38, mana = 210 },
        { type = "instant", name = "Wrath of Nature",  words = "exevo gran mas tera", level = 55, mana = 770 },
        { type = "instant", name = "Light Healing",  words = "exura", level = 9, mana = 20 },
        { type = "instant", name = "Antidote",  words = "exana pox", level = 10, mana = 30 },
        { type = "instant", name = "Intense Healing",  words = "exura gran", level = 11, mana = 70 },
        { type = "instant", name = "Heal Friend",  words = "exura sio", level = 18, mana = 140 },
        { type = "instant", name = "Ultimate Healing",  words = "exura vita", level = 20, mana = 160 },
        { type = "instant", name = "Mass Healing",  words = "exura gran mas res", level = 36, mana = 150 },
        { type = "instant", name = "Divine Healing",  words = "exura san", level = 35, mana = 210 },
        { type = "instant", name = "Wound Cleansing",  words = "exana mort", level = 30, mana = 65 },
        { type = "instant", name = "Light",  words = "utevo lux", level = 8, mana = 20 },
        { type = "instant", name = "Find Person",  words = "exiva", level = 8, mana = 20 },
        { type = "instant", name = "Magic Rope",  words = "exani tera", level = 9, mana = 20 },
        { type = "instant", name = "Levitate",  words = "exani hur", level = 12, mana = 50 },
        { type = "instant", name = "Great Light",  words = "utevo gran lux", level = 13, mana = 60 },
        { type = "instant", name = "Magic Shield",  words = "utamo vita", level = 14, mana = 50 },
        { type = "instant", name = "Haste",  words = "utani hur", level = 14, mana = 60 },
        { type = "instant", name = "Charge",  words = "utani tempo hur", level = 25, mana = 100 },
        { type = "instant", name = "Swift Foot",  words = "utamo tempo san", level = 55, mana = 400 },
        { type = "instant", name = "Challenge",  words = "exeta res", level = 20, mana = 30 },
        { type = "instant", name = "Strong Haste",  words = "utani gran hur", level = 20, mana = 100 },
        { type = "instant", name = "Creature Illusion",  words = "utevo res ina", level = 23, mana = 100 },
        { type = "instant", name = "Ultimate Light",  words = "utevo vis lux", level = 26, mana = 140 },
        { type = "instant", name = "Cancel Invisibility",  words = "exana ina", level = 26, mana = 200 },
        { type = "instant", name = "Invisibility",  words = "utana vid", level = 35, mana = 440 },
        { type = "instant", name = "Sharpshooter",  words = "utito tempo san", level = 60, mana = 450 },
        { type = "instant", name = "Protector",  words = "utamo tempo", level = 55, mana = 200 },
        { type = "instant", name = "Blood Rage",  words = "utito tempo", level = 60, mana = 290 },
        { type = "instant", name = "Train Party",  words = "utito mas sio", level = 32, mana = 60 },
        { type = "instant", name = "Protect Party",  words = "utamo mas sio", level = 32, mana = 90 },
        { type = "instant", name = "Heal Party",  words = "utura mas sio", level = 32, mana = 120 },
        { type = "instant", name = "Enchant Party",  words = "utori mas sio", level = 32, mana = 120 },
        { type = "instant", name = "Undead Legion",  words = "exana mas mort", level = 30, mana = 500 },
        { type = "conjure", name = "Conjure Arrow",  words = "exevo con", level = 13, mana = 100 },
        { type = "conjure", name = "Food",  words = "exevo pan", level = 14, mana = 120 },
        { type = "conjure", name = "Poisoned Arrow",  words = "exevo con pox", level = 16, mana = 130 },
        { type = "conjure", name = "Conjure Bolt",  words = "exevo con mort", level = 17, mana = 140 },
        { type = "conjure", name = "Conjure Sniper Arrow",  words = "exevo con hur", level = 24, mana = 160 },
        { type = "conjure", name = "Explosive Arrow",  words = "exevo con flam", level = 25, mana = 290 },
        { type = "conjure", name = "Conjure Piercing Bolt",  words = "exevo con grav", level = 33, mana = 180 },
        { type = "conjure", name = "Enchant Staff",  words = "exeta vis", level = 41, mana = 80 },
        { type = "conjure", name = "Enchant Spear",  words = "exeta con", level = 45, mana = 350 },
        { type = "conjure", name = "Power Bolt",  words = "exevo con vis", level = 59, mana = 800 },
        { type = "conjure", name = "Poison Field",  words = "adevo grav pox", level = 14, mana = 200 },
        { type = "conjure", name = "Light Magic Missile",  words = "adori min vis", level = 15, mana = 120 },
        { type = "conjure", name = "Fire Field",  words = "adevo grav flam", level = 15, mana = 240 },
        { type = "conjure", name = "Fireball",  words = "adori flam", level = 27, mana = 460 },
        { type = "conjure", name = "Energy Field",  words = "adevo grav vis", level = 18, mana = 320 },
        { type = "conjure", name = "Stalagmite",  words = "adori tera", level = 24, mana = 400 },
        { type = "conjure", name = "Great Fireball",  words = "adori mas flam", level = 30, mana = 530 },
        { type = "conjure", name = "Heavy Magic Missile",  words = "adori vis", level = 25, mana = 350 },
        { type = "conjure", name = "Poison Bomb",  words = "adevo mas pox", level = 25, mana = 520 },
        { type = "conjure", name = "Firebomb",  words = "adevo mas flam", level = 27, mana = 600 },
        { type = "conjure", name = "Soulfire",  words = "adevo res flam", level = 27, mana = 600 },
        { type = "conjure", name = "Poison Wall",  words = "adevo mas grav pox", level = 29, mana = 640 },
        { type = "conjure", name = "Explosion",  words = "adevo mas hur", level = 31, mana = 570 },
        { type = "conjure", name = "Fire Wall",  words = "adevo mas grav flam", level = 33, mana = 780 },
        { type = "conjure", name = "Energybomb",  words = "adevo mas vis", level = 37, mana = 880 },
        { type = "conjure", name = "Energy Wall",  words = "adevo mas grav vis", level = 41, mana = 1000 },
        { type = "conjure", name = "Sudden Death",  words = "adori gran mort", level = 45, mana = 985 },
        { type = "conjure", name = "Antidote Rune",  words = "adana pox", level = 15, mana = 200 },
        { type = "conjure", name = "Intense Healing Rune",  words = "adura gran", level = 15, mana = 240 },
        { type = "conjure", name = "Ultimate Healing Rune",  words = "adura vita", level = 24, mana = 400 },
        { type = "conjure", name = "Convince Creature",  words = "adeta sio", level = 16, mana = 200 },
        { type = "conjure", name = "Animate Dead",  words = "adana mort", level = 27, mana = 600 },
        { type = "conjure", name = "Chameleon",  words = "adevo ina", level = 27, mana = 600 },
        { type = "conjure", name = "Destroy Field",  words = "adito grav", level = 17, mana = 120 },
        { type = "conjure", name = "Desintegrate",  words = "adito tera", level = 21, mana = 200 },
        { type = "conjure", name = "Magic Wall",  words = "adevo grav tera", level = 32, mana = 750 },
        { type = "conjure", name = "Wild Growth",  words = "adevo grav vita", level = 27, mana = 600 },
        { type = "conjure", name = "Paralyze",  words = "adana ani", level = 54, mana = 1400 },
        { type = "conjure", name = "Icicle",  words = "adori frigo", level = 28, mana = 460 },
        { type = "conjure", name = "Avalanche",  words = "adori mas frigo", level = 30, mana = 530 },
        { type = "conjure", name = "Stone Shower",  words = "adori mas tera", level = 28, mana = 430 },
        { type = "conjure", name = "Thunderstorm",  words = "adori mas vis", level = 28, mana = 430 },
        { type = "conjure", name = "Holy Missile",  words = "adori san", level = 27, mana = 350 },
    }
 
Ty @Codex NG , i will test it when the creaturescript work, so ty :D

Code:
local spells = {
   [1] = { --sorcerer
     level = {
       [10] = "1spell", "spell1",
       [20] = "2spell", "spell2"
     }
   },

   [2] = { --druid
     level = {
       [1] = "spell", "spell",
       [5] = "spell", "spell"
     }
   },
 
   [3] = { --paladin
     level = {
       [1] = "spell", "spell",
       [5] = "spell", "spell"
     }
   },

   [4] = { --knight
     level = {
       [1] = "1spell", "spell1",
       [5] = "2spell", "spell2"
     }
   }
}
local array_sorc = {"Sorcerer", "Master Sorcerer"}
local array_druid = {"Druid", "Elder Druid"}
local array_paladin = {"Paladin", "Royal Paladin"}
local array_knight = {"Knight", "Elite Knight"}
local text = ""
function onAdvance(cid, skill, oldLevel, newLevel)
if skill == SKILL__MAGLEVEL then
    player = Player(cid)
        if isInArray(array_sorc, player:getVocation()) then
            CONFIG = spells[1]
        elseif isInArray(array_druid, player:getVocation()) then
            CONFIG = spells[2]
        elseif isInArray(array_paladin, player:getVocation()) then
            CONFIG = spells[3]
        elseif isInArray(array_knight, player:getVocation()) then
            CONFIG = spells[4]
    end
        if not CONFIG return false end
            EVENT = CONFIG.level[player:getMagLevel()]
        if not EVENT then
    return false
    end
        for i, v in ipairs(EVENT) do
            text = text..""..i..", "
        end
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "New spells: "..text..)
        end
    return true
end
Feels wrong but think i made it xD

Idk why, but it dont work, i make a sorcerer, and addskill he to ml 20 and dont show nothing on default
 
What about a function onAdvance:

Code:
if is knight then
   if magiclevel == 1 then
     doplayersendmessage = u learned the blablabla spell
   elseif magic level == 5 then
     doplayersendmessage = u learned the blablabla spell
   end
elseif is druid then
   if magiclevel == 1 then
     doplayersendmessage = u learned the blablabla spell
   elseif magic level == 5 then
     doplayersendmessage = u learned the blablabla spell
   end
elseif is sorcerer then
   if magiclevel == 1 then
     doplayersendmessage = u learned the blablabla spell
   elseif magic level == 5 then
     doplayersendmessage = u learned the blablabla spell
   end
elseif is paladin then
   if magiclevel == 1 then
     doplayersendmessage = u learned the blablabla spell
   elseif magic level == 5 then
     doplayersendmessage = u learned the blablabla spell
   end
end

I do not post the full code, only the idea. Ofc u will have to add each spell manualy, but its ok if the script are working!

EDIT: OH, now i see.. idk if exist a function that keep running to check player magic level... my code will not work then.
 
Code:
local spells = {
   [1] = { --sorcerer
     level = {
       [10] = "1spell", "spell1",
       [20] = "2spell", "spell2"
     }
   },

   [2] = { --druid
     level = {
       [1] = "spell", "spell",
       [5] = "spell", "spell"
     }
   },
 
   [3] = { --paladin
     level = {
       [1] = "spell", "spell",
       [5] = "spell", "spell"
     }
   },

   [4] = { --knight
     level = {
       [1] = "1spell", "spell1",
       [5] = "2spell", "spell2"
     }
   }
}
local array_sorc = {"Sorcerer", "Master Sorcerer"}
local array_druid = {"Druid", "Elder Druid"}
local array_paladin = {"Paladin", "Royal Paladin"}
local array_knight = {"Knight", "Elite Knight"}
local text = ""
function onAdvance(cid, skill, oldLevel, newLevel)
if skill == SKILL__MAGLEVEL then
    player = Player(cid)
        if isInArray(array_sorc, player:getVocation()) then
            CONFIG = spells[1]
        elseif isInArray(array_druid, player:getVocation()) then
            CONFIG = spells[2]
        elseif isInArray(array_paladin, player:getVocation()) then
            CONFIG = spells[3]
        elseif isInArray(array_knight, player:getVocation()) then
            CONFIG = spells[4]
    end
        if not CONFIG return false end
            EVENT = CONFIG.level[player:getMagLevel()]
        if not EVENT then
    return false
    end
        for i, v in ipairs(EVENT) do
            text = text..""..i..", "
        end
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "New spells: "..text..)
        end
    return true
end
Feels wrong but think i made it xD

I try use it and:
OV5FEde.png
 
Why are you bumping this thread when I already stated even if this code were written correctly it would still not execute on your server unless your server was a 1.x

I wrote the parser, although it isn't perfect (you will need to adjust vocations) so that you could generate a table from the file.

If your using a 1.x then this is the fix for the script you have in quotes which defeats the purpose of the parser
Code:
function onAdvance(cid, skill, oldLevel, newLevel)
    if skill == SKILL__MAGLEVEL then
        player = Player(cid)
        if isInArray(array_sorc, player:getVocation()) then
            CONFIG = spells[1]
        elseif isInArray(array_druid, player:getVocation()) then
            CONFIG = spells[2]
        elseif isInArray(array_paladin, player:getVocation()) then
            CONFIG = spells[3]
        elseif isInArray(array_knight, player:getVocation()) then
            CONFIG = spells[4]
        end
   
        if not CONFIG then
            return false
        end
       
        EVENT = CONFIG.level[player:getMagLevel()]
       
        if not EVENT then
            return false
        end
       
        for i, v in ipairs(EVENT) do
            text = text..""..i..", "
        end
   
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "New spells: "..text..)
    end
    return true
end

If its an 0.4 and your using the parser's generated table
Code:
function onAdvance(cid, skill, oldLevel, newLevel)
    if(config.savePlayersOnAdvance) then
        doPlayerSave(cid, true)
    end

    if skill == SKILL__LEVEL then
        for i = 1, #spells do
           if isInArray(spells[i].vocs, getPlayerVocation(cid)) and spells[i].level == newLevel then
               doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "New spells: "..spells[i].name)
            end
        end
    end
    return true
end
 
Last edited:
Back
Top