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

Solved magic level scroll

seleo

Active Member
Joined
Jun 6, 2012
Messages
498
Reaction score
33
Location
Egypt
Hello
im trying to add magic level scrolls and skill scroll based in vocations to my server
but i got an error when i try to use this magic scroll script
this is the magicscroll.lua file
Lua:
    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)
	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

but i got this error when i use the item

Code:
[Error - Action Interface]
data/actions/scripts/magicscroll.lua:onUse
Description:
data/actions/scripts/magicscroll.lua:11: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
        [C]: in function 'pairs'
        data/actions/scripts/magicscroll.lua:11: in function <data/actions/scripts/magicscroll.lua:10>

the script is based on mana spent
 
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(t) 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
 
it gives no errors
but it give no magic levels im using it in war server and the magic levels add automaticly when the player starts
spent mana is not working
can you please fix it so it add magic levels ?
 
Lua:
local t = {
    	[{1, 5}] = {100, 1}, -- {MAX_LEVEL, MLVL}
    	[{2, 6}] = {100, 1},
   	[{3, 7}] = {25, 1},
     	[{4, 8}] = {10, 1}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	for voc, b in pairs(t) do
		if(isInArray(voc, getPlayerVocation(cid))) then
			if(getPlayerMagLevel(cid) < b[1]) then
				doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + b[2]) - getPlayerSpentMana(cid)))
				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
 
this one gives more magic levels depends in your magic level
if you have a higher magic level is gives you more magic levels:D
 
Lua:
local t = {
    	[{1, 5}] = {100, 1}, -- {MAX_LEVEL, MLVL}
    	[{2, 6}] = {100, 1},
   	[{3, 7}] = {25, 1},
     	[{4, 8}] = {10, 1}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	for voc, b in pairs(t) do
		if(isInArray(voc, getPlayerVocation(cid))) then
			if(getPlayerMagLevel(cid) < b[1]) then
				for i = 1, b[2] do
					doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid)), false)
				end
				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
 
Back
Top