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

Magic Level Scroll [Adds Spent Mana]

Beo

Three Magic
Joined
Aug 25, 2009
Messages
9,057
Solutions
1
Reaction score
846
Code:
    local t = {
            [12466] = {
                    [{1, 5}] = {100, 100}, -- {MAX_LEVEL, SPENT_MANA}
                    [{2, 6}] = {100, 100},
                    [{3, 7}] = {25, 100},
                    [{4, 8}] = {10, 100}
            }
    }
     
    function onUse(cid, item, fromPosition, itemEx, toPosition)
            local k = t[item.itemid]
            if(k and isPlayer(cid)) then
                    for voc, b in pairs(k) do
                            if(isInArray(voc, getPlayerVocation(cid))) then
                                    if(getPlayerMagLevel(cid) < b[1]) then
                                            doPlayerAddSpentMana(cid, b[2] / getConfigInfo('rateMagic'))
                                            doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
                                            doRemoveItem(item.uid, 1)
                                    else
                                            return doPlayerSendCancel(cid, "You have reached the maximum level.")
                                    end
                            end
                    end
            end
            return true
    end

It doesn't work, I click the item I've put in Actions.xml, but nothing.

Using 3777 Rev.


If you could fix it, would be great. Thanks.
 
Use the following:

Lua:
local t = {
	[{1, 5}] = {100, 100}, -- {MAX_LEVEL, SPENT_MANA}
	[{2, 6}] = {100, 100},
	[{3, 7}] = {25, 100},
	[{4, 8}] = {10, 100}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	for voc, b in pairs(k) do
		if(isInArray(voc, getPlayerVocation(cid))) then
			if(getPlayerMagLevel(cid) < b[1]) then
				doPlayerAddSpentMana(cid, b[2] / getConfigInfo('rateMagic'))
				doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
				doRemoveItem(item.uid, 1)
			else
				return doPlayerSendCancel(cid, "You have reached the maximum level.")
			end
		end
	end
	return true
end
Here's another version, just copy/paste it.

Edit: The script you posted above didn't work (for you) because you didn't change the item number in the script, as I instructed...

Code:
    local t = {
            [COLOR="#FF0000"][12466][/COLOR] = {
                    [{1, 5}] = {100, 100}, -- {MAX_LEVEL, SPENT_MANA}
                    [{2, 6}] = {100, 100},
                    [{3, 7}] = {25, 100},
                    [{4, 8}] = {10, 100}
            }
    }
 
Last edited:
Back
Top Bottom