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

getting info from spells at certain lvl

cbrm

Retired scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,599
Solutions
3
Reaction score
972
Location
Caribbean Sea
how can I get the specific spells a player can do in certain level with the functions:
ex. lvl 30-31
not the spells from lvl 1-31, just the ones the player "learns" in lvl 30/31

LUA:
getPlayerLearnedInstantSpell(cid, name)
getPlayerInstantSpellCount(cid)
getPlayerInstantSpellInfo(cid, index)
getInstantSpellInfo(cid, name)

:ninja:
 
this is the spellbook.lua from tfs actions
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
        local t = {}
        for i = 0, getPlayerInstantSpellCount(cid) - 1 do
                local spell = getPlayerInstantSpellInfo(cid, i)
                if(spell.level ~= 0) 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 .. "Spells for Level " .. spell.level .. "\n"
                        prevLevel = spell.level
                end

                text = text .. line .. "  " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
        end

        doShowTextDialog(cid, item.itemid, text)
        return true
 
Code:
function getPlayerInstantSpellsForLevels(cid, levels)
	local t = {}
	for i = 0, getPlayerInstantSpellCount(cid) - 1 do
		local spell = getPlayerInstantSpellInfo(cid, i)
		if(isInArray(levels, spell.level) == TRUE) then
			table.insert(t, spell.name)
		end
	end
	return t
end
Code:
getPlayerInstantSpellsForLevels(cid, {30, 31})
 
Last edited:
Back
Top