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

8.4 script too 10.98

Zombiegod

Active Member
Joined
Oct 22, 2009
Messages
198
Solutions
1
Reaction score
25
So i have this super old manarune script that i like, however i get errors with the animated text, but if i remove it the script crashes the server.


Lua:
-- >>CONFIG<< --
local MIN_MANA_GAIN = 500 -- How much is the lowest mana you can possibly gain (If your heal less than that amount of mana you will get that mana instead) ?
local MIN_MANA_RAND = 1500 -- The minimum amount of mana to be given (random)
local MAX_MANA_RAND = 3000 -- The maximum amount of mana to be given (random)
local ACCEPT_LUCK = true -- Should it be possible to get lucky and receive extra mana? true, false
local MAG_LEVEL_MULTI = 2 -- How many times should Magic Level be multiplied, to be added to the mana formula? 1 = same, 0 = nothing etc
local LEVEL_MULTI = 2 -- How many times should Level be multiplied, to be added to the mana formula? 1 = same, 0 = nothing etc
local MAGIC_EFFECT = CONST_ME_MAGIC_BLUE -- Magic effect that will be casted on the player each time it heals the mana.
local ANIMATION_COLOR = 41 -- What animation color will there be when you heal (Comes over player showing how much mana you healed) 1 - 255 (?)
local HEAL_TIMES = 3 -- How many times should you be healed when using the manarune once? Atleast 1
local FIRST_HEAL_DELAY = 0 -- How long time will it take before it heals FIRST time? In milliseconds
local HEAL_DELAY = 1000 -- How long time will it take before it heals one? In milliseconds
-- >>CONFIG<< --

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, HEAL_TIMES * HEAL_DELAY + FIRST_HEAL_DELAY)
    
function onCastSpell(cid, var)
doTargetCombatCondition(0, cid, exhaust, CONST_ME_NONE)
    local function doHealMana(parameters)
        local random = math.random(MIN_MANA_RAND, MAX_MANA_RAND)
        if ACCEPT_LUCK == true then
        local luck = math.random(1, 100)
            if luck >= 90 then
                random = random * 2
            elseif luck == 50 then
                random = random * 3
            end
        end
        local formula = (getPlayerLevel(cid) * LEVEL_MULTI) + (getPlayerMagLevel(cid) * MAG_LEVEL_MULTI) + random
        local manaGain = math.max(MIN_MANA_GAIN, formula)
        doPlayerAddMana(cid, manaGain)
        doSendAnimatedText(getPlayerPosition(cid), manaGain, ANIMATION_COLOR)
        doSendMagicEffect(getPlayerPosition(cid), MAGIC_EFFECT)
        doCombat(parameters.cid, parameters.combat, parameters.var)
    end

    local times = HEAL_TIMES
    local parameters = {cid = cid, combat = combat, var = var}
    while times > 0 do
        if times == HEAL_TIMES then
            addEvent(doHealMana, FIRST_HEAL_DELAY, parameters)
        else
            addEvent(doHealMana, HEAL_DELAY * times, parameters)
        end
        times = times - 1
    end
end
 
What TFS version are you using? 0.4?

My hunch is the animated text thing actually has nothing to do with it.
But its the typical "I have an addEvent with a delay that crashes the server because the player has logged out before it triggers" thing.
 
Last edited:
The script was from 0.4 i think, it was from the crappy server source vs cryingdamson, and i am trying to use it on 1.3

animated text is sending up a deprecated error and does not function.

EDIT: oops, and no 0.4 throws no errors @Leo32
 
Last edited:
The concept of the script it pretty cool.
It's regrowth, but for mana.

The script itself though is old and yuck tho, I ain't converting all of it.
Here it is with the crashes fixed:

Lua:
-- >>CONFIG<< --
local MIN_MANA_GAIN = 500 -- How much is the lowest mana you can possibly gain (If your heal less than that amount of mana you will get that mana instead) ?
local MIN_MANA_RAND = 1500 -- The minimum amount of mana to be given (random)
local MAX_MANA_RAND = 3000 -- The maximum amount of mana to be given (random)
local ACCEPT_LUCK = true -- Should it be possible to get lucky and receive extra mana? true, false
local MAG_LEVEL_MULTI = 2 -- How many times should Magic Level be multiplied, to be added to the mana formula? 1 = same, 0 = nothing etc
local LEVEL_MULTI = 2 -- How many times should Level be multiplied, to be added to the mana formula? 1 = same, 0 = nothing etc
local MAGIC_EFFECT = CONST_ME_MAGIC_BLUE -- Magic effect that will be casted on the player each time it heals the mana.
local ANIMATION_COLOR = 41 -- What animation color will there be when you heal (Comes over player showing how much mana you healed) 1 - 255 (?)
local HEAL_TIMES = 3 -- How many times should you be healed when using the manarune once? Atleast 1
local FIRST_HEAL_DELAY = 0 -- How long time will it take before it heals FIRST time? In milliseconds
local HEAL_DELAY = 1000 -- How long time will it take before it heals one? In milliseconds
-- >>CONFIG<< --

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, HEAL_TIMES * HEAL_DELAY + FIRST_HEAL_DELAY)

function onCastSpell(cid, var)
doTargetCombatCondition(0, cid, exhaust, CONST_ME_NONE)
    local function doHealMana(parameters)
        if not Player(parameters.cid) then
            return false
        end
        local random = math.random(MIN_MANA_RAND, MAX_MANA_RAND)
        if ACCEPT_LUCK == true then
        local luck = math.random(1, 100)
            if luck >= 90 then
                random = random * 2
            elseif luck == 50 then
                random = random * 3
            end
        end
        local formula = (getPlayerLevel(cid) * LEVEL_MULTI) + (getPlayerMagLevel(cid) * MAG_LEVEL_MULTI) + random
        local manaGain = math.max(MIN_MANA_GAIN, formula)
        doPlayerAddMana(cid, manaGain)
        --doSendAnimatedText(getPlayerPosition(cid), manaGain, ANIMATION_COLOR)
        doSendMagicEffect(getPlayerPosition(cid), MAGIC_EFFECT)
        doCombat(parameters.cid, parameters.combat, parameters.var)
    end

    local times = HEAL_TIMES
    local parameters = {cid = cid.uid, combat = combat, var = var}
    while times > 0 do
        if times == HEAL_TIMES then
            addEvent(doHealMana, FIRST_HEAL_DELAY, parameters)
        else
            addEvent(doHealMana, HEAL_DELAY * times, parameters)
        end
        times = times - 1
    end
end
 
Last edited:
Back
Top