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

need level based manarune

Put this in your lib/050-functions.lua:
Lua:
function math.Round(number) 
if number >= 0 then
	return math.floor(number+.5) 
else 
	return math.ceil(number-.5) 
	end
end
Lua:
function onUse(cid, item, frompos, item2, topos)
-- Config
local magiclveq = 1
local levelreq = 8
local effect = 12
-- Config 
if isPlayer(item2.uid) then
	if getPlayerMagLevel(item2.uid) >= magiclveq then
		if getPlayerLevel(item2.uid) >= leveleq then
		
			-- Formula
			local level = getPlayerLevel(item2.uid)
			local magic = getPlayerMagLevel(item2.uid)
			local min = (level * 7.33) + (magic * 4) - 50
			local max = (level * 9.33) + (magic * 5) - 10
			local addMana = doPlayerAddMana(math.round(min,max))
			-- Formula
		
			doPlayerAddMana(item2.uid, math.Round(addMana))
			doSendMagicEffect(getCreaturePosition(item2.uid), effect)
			doSendAnimatedText(getCreaturePosition(item2.uid), ""..mathRound(addMana).."")
			doRemoveItem(item.uid, 1)
		end
	else
		doPlayerSendCancel(cid, "Sorry, not enough level.")
	end
else
	doPlayerSendCancel(cid, "Sorry, not enough magic level.")
else
	doPlayerSendCancel(cid, "Sorry, not possible.")
end
return true
end
 
Last edited:
Put this in your lib/050-functions.lua:
Lua:
function math.Round(number) 
if number >= 0 then
	return math.floor(number+.5) 
else 
	return math.ceil(number-.5) 
	end
end
Lua:
function onUse(cid, item, frompos, item2, topos)
-- Config
local magiclveq = 1
local levelreq = 8
local effect = 12
-- Config 
if isPlayer(item2.uid) then
	if getPlayerMagLevel(item2.uid) >= magiclveq then
		if getPlayerLevel(item2.uid) >= leveleq then
		
			-- Formula
			local level = getPlayerLevel(item2.uid)
			local magic = getPlayerMagLevel(item2.uid)
			local min = (level * 7.33) + (magic * 4) - 50
			local max = (level * 9.33) + (magic * 5) - 10
			local addMana = doPlayerAddMana(math.round(min,max))
			-- Formula
		
			doPlayerAddMana(item2.uid, math.Round(addMana))
			doSendMagicEffect(getCreaturePosition(item2.uid), effect)
			doSendAnimatedText(getCreaturePosition(item2.uid), ""..mathRound(addMana).."")
			doRemoveItem(item.uid, 1)
		end
	else
		doPlayerSendCancel(cid, "Sorry, not enough level.")
	end
else
	doPlayerSendCancel(cid, "Sorry, not enough magic level.")
else
	doPlayerSendCancel(cid, "Sorry, not possible.")
end
return true
end

Why do you use function math.Round(number)? The spell will do this automatically. And better use math.abs() insted if you do.
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(isPlayer(itemEx.uid) == true) then
	local level = getPlayerLevel(cid) 
	local mlevel = getPlayerMagLevel(cid)
	local heal = level * 9 + mlevel * 1 - 100
	local maxheal = level * 8 + mlevel * 1
		doPlayerAddMana(cid, math.abs(heal, maxheal))
		doSendMagicEffect(getThingPos(itemEx.uid), 12)
	else
		doPlayerSendCancel(cid,"Can Only Use On Creatures")
	end
	return true
end
 
Back
Top