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

[request] Manarune Based on Magic lvl.

nystrom

New Member
Joined
Nov 17, 2009
Messages
269
Reaction score
0
Hello i have tryed get a manarune based on magiclvl to work in hours, searching trhough this site and otfans coulple of times but non of them work.
Im based on TFS 8.52 and hope someone can help me!

Please with "mini-tuts/mini-guides" since im kinda new
 
PHP:
>> Loading script systems
[Warning - Event::loadScript] Cannot load script (data/actions/scripts/holy mana
rune.lua)
data/actions/scripts/holy manarune.lua:1: unexpected symbol near '*'

Error! No-one works! Its drive me crazyy!


What i did was this:
Maked this as a Manarune.lua
PHP:
- Script 100% by Colandus (Except for the exhaustion system).
-- If you edit this script, make sure to leave the credits to me, Colandus.

-- >>CONFIG<< --
local REMOVE_CHARGES = true -- true/false shall it remove charges?
local MIN_MANA = 100 -- How much mana minium will you get?
local MAX_MANA = 300 -- How much mana max will you get?
local USE_STATS = true -- Shall given mana be affected by player level and magic level?
local STORE_VALUE = 3567 -- Value where exhaust is saved.
local EXHAUST_TIME = 1 -- Exhaust time in seconds.
local ANIMATION_COLOR = 41 -- The color of the "animation".
-- >>CONFIG<< --

local vocMultiply = {0.35, 0.35, 0.85, 1.05, 0, 0, 0.65, 1.05} -- Remove and/or comment it out if you wish not to use it.
local removeMana = 0

function onUse(cid, item, frompos, item2, topos)
    if isPlayer(item2.uid) == TRUE then
        local maxMana = getPlayerMaxMana(item2.uid)
        if vocMultiply and getPlayerVocation(cid) >= 1 and getPlayerVocation(cid) <= 8 then
            removeMana = vocMultiply[getPlayerVocation(cid)]
        end
        local newMana = math.random(MIN_MANA, MAX_MANA)
        if USE_STATS then
            newMana = math.ceil(newMana + getPlayerLevel(cid) + getPlayerMagLevel(cid) - (newMana * removeMana))
        end
        if (maxMana - newMana) < 0 then
            newMana = maxMana - getPlayerMana(cid)
        end
        if getPlayerMana(item2.uid) < maxMana then
            if exhaust(cid, STORE_VALUE, EXHAUST_TIME) > 0 then
                if REMOVE_CHARGES then
                    if item.type > 1 then
                        doChangeTypeItem(item.uid, item.type - 1)
                    else
                        doRemoveItem(item.uid, 1)
                    end
                end
                if comparePos(getPlayerPosition(cid), getPlayerPosition(item2.uid)) then
                    doSendMagicEffect(getPlayerPosition(cid), 12)
                    doPlayerSendTextMessage(cid, 23, "You received " .. newMana .. " mana.")
                else
                    doSendMagicEffect(getPlayerPosition(cid), 14)
                    doSendMagicEffect(getPlayerPosition(item2.uid), 12)
                    doPlayerSendTextMessage(item2.uid, 23, "You received " ..  newMana .. " mana from " .. getPlayerName(cid) .. ".")
                    doPlayerSendTextMessage(cid, 23, "You gave " .. getPlayerName(item2.uid) .. " " .. newMana .. " mana.")
                end
                doPlayerAddMana(item2.uid, newMana)
                doSendAnimatedText(getPlayerPosition(item2.uid), newMana, ANIMATION_COLOR)
            else
                doPlayerSendCancel(cid, "You are exhausted.")
            end
        else
            if comparePos(getPlayerPosition(cid), getPlayerPosition(item2.uid)) then
                doPlayerSendCancel(item2.uid, "Your mana is already full.")
            else
                doPlayerSendCancel(cid, getPlayerName(item2.uid) .. " mana is already full.")
            end
            doSendMagicEffect(getPlayerPosition(cid), 2)
        end
    else
        doPlayerSendCancel(cid, "You can only use this rune on players.")
        doSendMagicEffect(getPlayerPosition(cid), 2)
    end
    return 1
end

and pasted this in lib/function.lua'
PHP:
function comparePos(pos1,pos2)
    return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z
end
And this in action.xml
PHP:
<action itemid="2316" script="manarune.lua" allowfaruse="1" blockwalls="0" />

I cant see what im doing wrong
 
You broken comment line:
Code:
[COLOR="Red"][B][SIZE="7"]-[/SIZE][/B][/COLOR]- Script 100% by Colandus (Except for the exhaustion system).
-- If you edit this script, make sure to leave the credits to me, Colandus.

-- >>CONFIG<< --
local REMOVE_CHARGES = true -- true/false shall it remove charges?
local MIN_MANA = 100 -- How much mana minium will you get?
local MAX_MANA = 300 -- How much mana max will you get?
local USE_STATS = true -- Shall given mana be affected by player level and magic level?
local STORE_VALUE = 3567 -- Value where exhaust is saved.
local EXHAUST_TIME = 1 -- Exhaust time in seconds.
local ANIMATION_COLOR = 41 -- The color of the "animation".
-- >>CONFIG<< --

local vocMultiply = {0.35, 0.35, 0.85, 1.05, 0, 0, 0.65, 1.05} -- Remove and/or comment it out if you wish not to use it.
local removeMana = 0

function onUse(cid, item, frompos, item2, topos)
	if isPlayer(item2.uid) == TRUE then
		local maxMana = getPlayerMaxMana(item2.uid)
		if vocMultiply and getPlayerVocation(cid) >= 1 and getPlayerVocation(cid) <= 8 then
			removeMana = vocMultiply[getPlayerVocation(cid)]
		end
		local newMana = math.random(MIN_MANA, MAX_MANA)
		if USE_STATS then
			newMana = math.ceil(newMana + getPlayerLevel(cid) + getPlayerMagLevel(cid) - (newMana * removeMana))
		end
		if (maxMana - newMana) < 0 then
			newMana = maxMana - getPlayerMana(cid)
		end
		if getPlayerMana(item2.uid) < maxMana then
			if exhaust(cid, STORE_VALUE, EXHAUST_TIME) > 0 then
				if REMOVE_CHARGES then
					if item.type > 1 then
						doChangeTypeItem(item.uid, item.type - 1)
					else
						doRemoveItem(item.uid, 1)
					end
				end
				if comparePos(getPlayerPosition(cid), getPlayerPosition(item2.uid)) then
					doSendMagicEffect(getPlayerPosition(cid), 12)
					doPlayerSendTextMessage(cid, 23, "You received " .. newMana .. " mana.")
				else
					doSendMagicEffect(getPlayerPosition(cid), 14)
					doSendMagicEffect(getPlayerPosition(item2.uid), 12)
					doPlayerSendTextMessage(item2.uid, 23, "You received " ..  newMana .. " mana from " .. getPlayerName(cid) .. ".")
					doPlayerSendTextMessage(cid, 23, "You gave " .. getPlayerName(item2.uid) .. " " .. newMana .. " mana.")
				end
				doPlayerAddMana(item2.uid, newMana)
				doSendAnimatedText(getPlayerPosition(item2.uid), newMana, ANIMATION_COLOR)
			else
				doPlayerSendCancel(cid, "You are exhausted.")
			end
		else
			if comparePos(getPlayerPosition(cid), getPlayerPosition(item2.uid)) then
				doPlayerSendCancel(item2.uid, "Your mana is already full.")
			else
				doPlayerSendCancel(cid, getPlayerName(item2.uid) .. " mana is already full.")
			end
			doSendMagicEffect(getPlayerPosition(cid), 2)
		end
	else
		doPlayerSendCancel(cid, "You can only use this rune on players.")
		doSendMagicEffect(getPlayerPosition(cid), 2)
	end
	return 1
end
 
You broken comment line:
Code:
[COLOR="Red"][B][SIZE="7"]-[/SIZE][/B][/COLOR]- Script 100% by Colandus (Except for the exhaustion system).
-- If you edit this script, make sure to leave the credits to me, Colandus.

-- >>CONFIG<< --
local REMOVE_CHARGES = true -- true/false shall it remove charges?
local MIN_MANA = 100 -- How much mana minium will you get?
local MAX_MANA = 300 -- How much mana max will you get?
local USE_STATS = true -- Shall given mana be affected by player level and magic level?
local STORE_VALUE = 3567 -- Value where exhaust is saved.
local EXHAUST_TIME = 1 -- Exhaust time in seconds.
local ANIMATION_COLOR = 41 -- The color of the "animation".
-- >>CONFIG<< --

local vocMultiply = {0.35, 0.35, 0.85, 1.05, 0, 0, 0.65, 1.05} -- Remove and/or comment it out if you wish not to use it.
local removeMana = 0

function onUse(cid, item, frompos, item2, topos)
	if isPlayer(item2.uid) == TRUE then
		local maxMana = getPlayerMaxMana(item2.uid)
		if vocMultiply and getPlayerVocation(cid) >= 1 and getPlayerVocation(cid) <= 8 then
			removeMana = vocMultiply[getPlayerVocation(cid)]
		end
		local newMana = math.random(MIN_MANA, MAX_MANA)
		if USE_STATS then
			newMana = math.ceil(newMana + getPlayerLevel(cid) + getPlayerMagLevel(cid) - (newMana * removeMana))
		end
		if (maxMana - newMana) < 0 then
			newMana = maxMana - getPlayerMana(cid)
		end
		if getPlayerMana(item2.uid) < maxMana then
			if exhaust(cid, STORE_VALUE, EXHAUST_TIME) > 0 then
				if REMOVE_CHARGES then
					if item.type > 1 then
						doChangeTypeItem(item.uid, item.type - 1)
					else
						doRemoveItem(item.uid, 1)
					end
				end
				if comparePos(getPlayerPosition(cid), getPlayerPosition(item2.uid)) then
					doSendMagicEffect(getPlayerPosition(cid), 12)
					doPlayerSendTextMessage(cid, 23, "You received " .. newMana .. " mana.")
				else
					doSendMagicEffect(getPlayerPosition(cid), 14)
					doSendMagicEffect(getPlayerPosition(item2.uid), 12)
					doPlayerSendTextMessage(item2.uid, 23, "You received " ..  newMana .. " mana from " .. getPlayerName(cid) .. ".")
					doPlayerSendTextMessage(cid, 23, "You gave " .. getPlayerName(item2.uid) .. " " .. newMana .. " mana.")
				end
				doPlayerAddMana(item2.uid, newMana)
				doSendAnimatedText(getPlayerPosition(item2.uid), newMana, ANIMATION_COLOR)
			else
				doPlayerSendCancel(cid, "You are exhausted.")
			end
		else
			if comparePos(getPlayerPosition(cid), getPlayerPosition(item2.uid)) then
				doPlayerSendCancel(item2.uid, "Your mana is already full.")
			else
				doPlayerSendCancel(cid, getPlayerName(item2.uid) .. " mana is already full.")
			end
			doSendMagicEffect(getPlayerPosition(cid), 2)
		end
	else
		doPlayerSendCancel(cid, "You can only use this rune on players.")
		doSendMagicEffect(getPlayerPosition(cid), 2)
	end
	return 1
end

Just my copy fail
 
Well this script work

PHP:
 function onUse(cid, item, frompos, item2, topos)
mag = getPlayerMagLevel(cid)
if mag >= 0 then
random_number = math.random(200,500)
doPlayerAddMana(cid,random_number)
doSendMagicEffect(topos,12)
if item.type > 1 then
   doChangeTypeItem(item.uid,item.type-1)
  else
   doRemoveItem(item.uid,1)
  end
else
 doSendMagicEffect(frompos,2)
 doPlayerSendCancel(cid,"You don't have the required magic level to use that rune.")
end
return 1
end




Is there a way to edit that script with the "based on maglvl" piece from Ultimate healing rune script?
 
Code:
local req = {
	lvl = 20,
	mlvl = 5
}
local multiplier = {
	min = {
		lvl = 0.25,
		mlvl = 3,
		final = 3.8
	},
	max = {
		lvl = 0.25,
		mlvl = 3,
		final = 4.2
	}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local lvl = getPlayerLevel(cid)
	local mlvl = getPlayerMagLevel(cid)
	if lvl >= req.lvl and mlvl >= req.mlvl then
		doPlayerAddMana(itemEx.uid, math.random((lvl*multiplier.min.lvl + mlvl*multiplier.min.mlvl) * multiplier.min.final, (lvl*multiplier.max.lvl + mlvl*multiplier.max.mlvl) * multiplier.max.final))
		doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
		doRemoveItem(item.uid,1)
	else
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		doPlayerSendCancel(cid,"You don't have the required " .. (mlvl < req.mlvl and "magic ") .. "level to use that rune.")
	end
	return TRUE
end
 
Last edited:
Code:
local req = {
	lvl = 20,
	mlvl = 5
}
local multiplier = {
	min = {
		lvl = 0.25,
		mlvl = 3,
		final = 3.8
	},
	max = {
		lvl = 0.25,
		mlvl = 3,
		final = 4.2
	}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local lvl = getPlayerMagLevel(cid)
	local mlvl = getPlayerMagLevel(cid)
	if lvl >= req.lvl and mlvl >= req.mlvl then
		doPlayerAddMana(itemEx.uid, math.random((lvl*multiplier.min.lvl + mlvl*multiplier.min.mlvl) * multiplier.min.final, (lvl*multiplier.max.lvl + mlvl*multiplier.max.mlvl) * multiplier.max.final))
		doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
		doRemoveItem(item.uid,1)
	else
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		doPlayerSendCancel(cid,"You don't have the required " .. (mlvl < req.mlvl and "magic ") .. "level to use that rune.")
	end
	return TRUE
end
ur my good<3 tytytyty reeep:$
 
Back
Top