• 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 VIP Manarune problem, Rep++

Nikkster

Programmer
Joined
May 9, 2008
Messages
2,848
Reaction score
10
Location
Confidential
Hello, in the following days I have recieved small lags when players are using the VIP manarune. I'm getting a couple of errors when someone is using it in the server starter (The logs).






[05/03/2009 11:13:15] Lua Script Error: [Spell Interface]
[05/03/2009 11:13:15] data/spells/scripts/custom/donated manarune.lua:onCastSpell

[05/03/2009 11:13:16] luaDoTargetCombatCondition(). Condition not found

05/03/2009 11:14:04] Lua Script Error: [Spell Interface]
[05/03/2009 11:14:05] data/spells/scripts/custom/donated manarune.lua:onCastSpell

[05/03/2009 11:14:05] luaDoTargetCombatCondition(). Condition not found


~~ Something like this. Here's my vip manarune script:
In items.xml
Code:
	<item id="2299" article="a" name="VIP Manarune">
		<attribute key="weight" value="120"/>
	</item>

In: Data - Spells - Custom - donated manarune

Code:
 -- >>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_EXHAUSTED)
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
 
[05/03/2009 11:14:05] luaDoTargetCombatCondition(). Condition not found

That means that the condition doesn't exist, maybe it got an other name now. You're using an old script right?
 
Well, the rune is named as "VIP Manarune" and in the spells - custrom, its named as "Donated Manarune"..


So do you think if I changed the script "Donated Manarune" to VIP manarune would work?
 
Try this one, just a quick review. May work, may not.
PHP:
-- >>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)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, HEAL_TIMES * HEAL_DELAY + FIRST_HEAL_DELAY)
    
function onCastSpell(cid, var)
    doAddCondition(cid, exhaust)
    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
 
Nah that has nothing to do with it. I think this bugs, but not sure:S
Code:
local exhaust = createConditionObject(CONDITION_EXHAUSTED)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, HEAL_TIMES * HEAL_DELAY + FIRST_HEAL_DELAY)

edit: l0al makromango was first
 
Try this one, just a quick review. May work, may not.
PHP:
-- >>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)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, HEAL_TIMES * HEAL_DELAY + FIRST_HEAL_DELAY)
    
function onCastSpell(cid, var)
    doAddCondition(cid, exhaust)
    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



No, it's showing the same errors :/



edit, anyway, thanks macro! It stopped lagging anyways but still showing the errors but nvm, as long as it doesn't lag its cool!
 
Last edited:
PHP:
local config = {
    -- Set to true if the mana should be calculated by percentage, false if it should be calculated by a min/max value.
    usePercentage = false,
    storage = 12228, -- Storage for exhaustion.
    exhaustion = 2, -- 1 = 1 second
    manaRecieved = {
        percentage = 0.20, -- if 'usePercentage' is set to true.
        minimumMana = 100, -- if 'usePercentage' is set to false.
        maximumMana = 200 -- if 'usePercentage' is set to false.    
    }
}
local mana = 0

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if ( os.time() >= ( getPlayerStorageValue(cid, config.storage) + config.exhaustion ) ) or getPlayerStorageValue(cid, config.storage) == -1 then
        if config.usePercentage == true then
            mana = getCreatureMaxMana(cid) * config.manaRecieved.percentage
        else
            mana = math.random(config.manaRecieved.minimumMana, config.manaRecieved.maximumMana)
        end
        doCreatureAddMana(cid, mana)
        doSendAnimatedText(getCreaturePosition(cid), mana, TEXTCOLOR_LIGHTBLUE)
        doSendMagicEffect(getCreaturePosition(cid), 12)
        setPlayerStorageValue(cid, config.storage, os.time())
    else
        doSendMagicEffect(getCreaturePosition(cid), 2)
        doPlayerSendCancel(cid, "You are exhausted.")
    end
    return TRUE
end
 
Last edited:
Disable your mana rune in your spells.xml file, and use it through the actions.xml file instead.
 
Well, not really. Send me a PM with your MSN and I'll add you (will remove you afterwards as I'd like to keep my MSN clean from people I barely know, no offense directly towards you).
 
Still doesn't work, getting these errors:


[07/03/2009 22:39:11] Lua Script Error: [Action Interface]
[07/03/2009 22:39:11] data/actions/scripts/Donated Manarune.lua:onUse

[07/03/2009 22:39:11] data/actions/scripts/Donated Manarune.lua:19: attempt to call field 'rand' (a nil value)
[07/03/2009 22:39:11] stack traceback:
[07/03/2009 22:39:11] data/actions/scripts/Donated Manarune.lua:19: in function <data/actions/scripts/Donated Manarune.lua:14>

[07/03/2009 22:39:14] Lua Script Error: [Action Interface]
[07/03/2009 22:39:14] data/actions/scripts/Donated Manarune.lua:onUse

[07/03/2009 22:39:14] data/actions/scripts/Donated Manarune.lua:19: attempt to call field 'rand' (a nil value)
[07/03/2009 22:39:14] stack traceback:
[07/03/2009 22:39:14] data/actions/scripts/Donated Manarune.lua:19: in function <data/actions/scripts/Donated Manarune.lua:14>


Well nvm, copied another script on my server which is working :P but macro, ill add reputation to you as soon as I can again, been doing too much lately.. stop being so helpful ^o)

/nikkster
 
Last edited:
Back
Top