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

Lua Donation mana rune

Androw23

New Member
Joined
Jun 3, 2020
Messages
20
Reaction score
4
Location
USA
Hey Folks, is there a way I can create a donation mana rune that will give players a stable number, for example, 3k mana each time. instead of a range based on the character level and magic level.
 
Solution
Hey Folks, is there a way I can create a donation mana rune that will give players a stable number, for example, 3k mana each time. instead of a range based on the character level and magic level.

Should players be able to heal another players with it?
Do you want animatedText like yellow aswell?

Script:

Lua:
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, 1000) -- Change the time here ( 1000 means = 1 sec )
 
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
 
    local mana = 3000
 
    targetPlayer = Player(target)
    if not targetPlayer then
        player:SendTextMessage(MESSAGE_INFO_DESCR, "You may only use this on players!")
        return true
    end...
Try this
Lua:
function onUse(cid, item, frompos, itemEx, topos)
local playerinfo = -- Please don't touch
{
level = getPlayerLevel(cid),
mlevel = getPlayerMagLevel(cid),
voc = getPlayerVocation(cid)
}
local config =
{
strenght = "constant", ---Values: template (strenght dependent on level and magic level), constant (on all level adding same mana)
template = {min = (((playerinfo.level * 2.3) + (playerinfo.mlevel * 5)) / 3.2) , max =(((playerinfo.level * 2.6) + (playerinfo.mlevel * 5.5)) / 3.2)}, -- liczymy - lvl * 4 /1.5 = x m lvl * 2 /1.5 = x lvl + m lvl = Minimum, lvl * 6 /1.5 = x m lvl * 4 /1.5 = x lvl + m lvl = Maximum
constant = {min = 3000, max = 3000},--only if strenght is constant
exhaustion = 1,--exhaustion in secs
exhaustion_value = 56789, --exhaustion storage value
minimum_level = 15,--minimum level to use manarune
minimum_mlevel = 1,--minimum magic level to use manarune
cannot_use_voc = {0} --id vocation which cannot use
}
local rand = 0
if(isPlayer(itemEx.uid) == false) then
return true
end
if(playerinfo.level < config.minimum_level) then
return true
end
if(playerinfo.mlevel < config.minimum_mlevel) then
return true
end
if(isInArray(config.cannot_use_voc, playerinfo.voc)) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Cant use.")
return true
end
if(config.strenght ~= "template" and config.strenght ~= "constant") then
config.strenght = "constant"
end
if(getPlayerStorageValue(cid, config.exhaustion_value) > os.time()) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You are exhausted.")
return true
end
if(config.strenght == "template") then
rand = math.random(config.template.min, config.template.max)
elseif (config.strenght == "constant") then
rand = math.random(config.constant.min, config.constant.max)
end
doPlayerAddMana(cid, rand)
setPlayerStorageValue(cid, config.exhaustion_value, (os.time() + config.exhaustion))
doCreatureSay(cid, "+"..math.floor(rand).." mana", TALKTYPE_ORANGE_1)
doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
return true
end
 
Try this one
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target or not target:isPlayer() then
        return false
    end
    local mana = 1000
    target:addMana(mana)
    toPosition:sendMagicEffect(CONST_ME_HOLYAREA)
    item:remove(1)
    return true
end
 
why if i can ask?
you can use all the functionality of spells.xml file
ETRFzch.png


without the need to code anything else, also if you use action you probably need to add exhaust to it or players can just spam mana rune
 
Hey Folks, is there a way I can create a donation mana rune that will give players a stable number, for example, 3k mana each time. instead of a range based on the character level and magic level.

Should players be able to heal another players with it?
Do you want animatedText like yellow aswell?

Script:

Lua:
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, 1000) -- Change the time here ( 1000 means = 1 sec )
 
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
 
    local mana = 3000
 
    targetPlayer = Player(target)
    if not targetPlayer then
        player:SendTextMessage(MESSAGE_INFO_DESCR, "You may only use this on players!")
        return true
    end
 
    local pos = targetPlayer:getPosition() -- getThingPos(itemEx.uid)
 
    targetPlayer:addMana(mana)
    pos:sendMagicEffect(50) -- You can change the effect as you want
    player:addCondition(exhaust)
    return true
end
 
Last edited:
Solution
@DoktorHolzbein I would love if a player can heal another player. I tried the other previous codes but for some reason, I don't see any change.
the way I do it : data > spells > scripts > runes > donationmana.lua. do I also have to change any other script than that?
 
The one I posted should be added in data/actions/scripts
and then add this to actions.xml
XML:
<action itemid="yourruneid" script="yourscriptnamehere.lua"/>
I did nothing special to it, Just a rune adding mana but it can be edited if you gave more details about what exactly you need.
Or you can go for Evil Puncker's one.
 
The one I posted should be added in data/actions/scripts
and then add this to actions.xml
XML:
<action itemid="yourruneid" script="yourscriptnamehere.lua"/>
I did nothing special to it, Just a rune adding mana but it can be edited if you gave more details about what exactly you need.
Or you can go for Evil Puncker's one.
I get this error in the log:
[30/07/2021 11:31:38] [Error - Action Interface]
[30/07/2021 11:31:38] data/actions/scripts/other/donatemana1.lua:eek:nUse
[30/07/2021 11:31:38] Description:
[30/07/2021 11:31:38] data/actions/scripts/other/donatemana1.lua:2: attempt to call method 'isPlayer' (a nil value)
[30/07/2021 11:31:38] stack traceback:
[30/07/2021 11:31:38] data/actions/scripts/other/donatemana1.lua:2: in function <data/actions/scripts/other/donatemana1.lua:1>

Anyone mind helping out?
 
Back
Top