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

How to Put Cooldown on Spells

CollapserMemory

New Member
Joined
Dec 4, 2014
Messages
66
Reaction score
1
I have Any Spell and i want put Cooldown on this ...
local scom1 = createCombatObject()
local scom2 = createCombatObject()

local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, 3)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 6)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -1.7, -1.7, -1.8, 0)

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, 3)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, 15)

arr1 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 2, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}

arr2 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 2, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}

local area1 = createCombatArea(arr1)
local area2 = createCombatArea(arr2)
setCombatArea(scom1, area1)
setCombatArea(scom2, area2)

function onTargetTile(cid, pos)
doCombat(cid,combat1,positionToVariant(pos))
end

function onTargetTile2(cid, pos)
doCombat(cid,combat2,positionToVariant(pos))
end

setCombatCallback(scom1, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
setCombatCallback(scom2, CALLBACK_PARAM_TARGETTILE, "onTargetTile2")

local function onCastSpell1(parameters)
doCombat(parameters.cid, scom1, parameters.var)
end

local function onCastSpell2(parameters)
doCombat(parameters.cid, scom2, parameters.var)
end

function onCastSpell(cid, var)
doPlayerAddSoul(cid, math.random(2, 2))
local parameters = { cid = cid, var = var}
addEvent(onCastSpell1, 1, parameters)
addEvent(onCastSpell2, 2, parameters)

return TRUE
end
 
Code:
        local scom1 = createCombatObject()
        local scom2 = createCombatObject()

        local combat1 = createCombatObject()
        setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
        setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, 3)
        setCombatParam(combat1, COMBAT_PARAM_EFFECT, 6)
        setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -1.7, -1.7, -1.8, 0)

        local combat2 = createCombatObject()
        setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
        setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, 3)
        setCombatParam(combat2, COMBAT_PARAM_EFFECT, 15)

        arr1 = {
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
        {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
        {0, 0, 0, 1, 1, 2, 1, 1, 0, 0, 0},
        {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
        {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
        }

        arr2 = {
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
        {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
        {0, 0, 0, 1, 1, 2, 1, 1, 0, 0, 0},
        {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
        {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
        }

        local area1 = createCombatArea(arr1)
        local area2 = createCombatArea(arr2)
        setCombatArea(scom1, area1)
        setCombatArea(scom2, area2)

        function onTargetTile(cid, pos)
        doCombat(cid,combat1,positionToVariant(pos))
        end

        function onTargetTile2(cid, pos)
        doCombat(cid,combat2,positionToVariant(pos))
        end

        setCombatCallback(scom1, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
        setCombatCallback(scom2, CALLBACK_PARAM_TARGETTILE, "onTargetTile2")

        local function onCastSpell1(parameters)
        doCombat(parameters.cid, scom1, parameters.var)
        end

        local function onCastSpell2(parameters)
        doCombat(parameters.cid, scom2, parameters.var)
        end
        function removeStorage(cid, storage)
            if (cid~=nil) then
                setPlayerStorageValue(cid, storage, -1)
            end
        end
        function onCastSpell(cid, var)
            local cd_stg = 9080
            local cd_time = 1 -- seconds
            if(getPlayerStorageValue(cid, cd_stg) < 1) then
                setPlayerStorageValue(cid, cd_stg, 1)
                addEvent(removeStorage,cd_time*100, cid, cd_stg)
                doPlayerAddSoul(cid, math.random(2, 2))
                local parameters = { cid = cid, var = var}
                addEvent(onCastSpell1, 1, parameters)
                addEvent(onCastSpell2, 2, parameters)
            else
                doPlayerSendCancel("Spells is cooling down")
            end
    return TRUE
end
 
Last edited:
Code:
        local scom1 = createCombatObject()
        local scom2 = createCombatObject()

        local combat1 = createCombatObject()
        setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
        setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, 3)
        setCombatParam(combat1, COMBAT_PARAM_EFFECT, 6)
        setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -1.7, -1.7, -1.8, 0)

        local combat2 = createCombatObject()
        setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
        setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, 3)
        setCombatParam(combat2, COMBAT_PARAM_EFFECT, 15)

        arr1 = {
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
        {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
        {0, 0, 0, 1, 1, 2, 1, 1, 0, 0, 0},
        {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
        {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
        }

        arr2 = {
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
        {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
        {0, 0, 0, 1, 1, 2, 1, 1, 0, 0, 0},
        {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
        {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
        }

        local area1 = createCombatArea(arr1)
        local area2 = createCombatArea(arr2)
        setCombatArea(scom1, area1)
        setCombatArea(scom2, area2)

        function onTargetTile(cid, pos)
        doCombat(cid,combat1,positionToVariant(pos))
        end

        function onTargetTile2(cid, pos)
        doCombat(cid,combat2,positionToVariant(pos))
        end

        setCombatCallback(scom1, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
        setCombatCallback(scom2, CALLBACK_PARAM_TARGETTILE, "onTargetTile2")

        local function onCastSpell1(parameters)
        doCombat(parameters.cid, scom1, parameters.var)
        end

        local function onCastSpell2(parameters)
        doCombat(parameters.cid, scom2, parameters.var)
        end
        function removeStorage(cid, storage)
            if (cid~=nil)
                setPlayerStorageValue(cid, storage, -1)
            end
        end
        function onCastSpell(cid, var)
            local cd_stg = 9080
            local cd_time = 1 -- seconds
            if(getPlayerStorageValue(cid, cd_stg) < 1) then
                setPlayerStorageValue(cid, cd_stg, 1)
                addEvent(removeStorage,cd_time*100, cid, cd_stg)
                doPlayerAddSoul(cid, math.random(2, 2))
                local parameters = { cid = cid, var = var}
                addEvent(onCastSpell1, 1, parameters)
                addEvent(onCastSpell2, 2, parameters)
            else
                doPlayerSendCancel("Spells is cooling down")
            end
        end
    return TRUE
end
[28/07/2015 02:11:31] Warning: [Event::loadScript] Can not load script. data/spells/scripts/.lua
[28/07/2015 02:11:31] cannot open data/spells/scripts/.lua: No such file or directory
[28/07/2015 02:11:31] Warning: [Event::loadScript] Can not load script. data/spells/scripts/gran frigo.lua
[28/07/2015 02:11:31] data/spells/scripts/gran frigo.lua:86: '<eof>' expected near 'end'
 
Last edited:
Editd last one, try again
[28/07/2015 02:11:31] Warning: [Event::loadScript] Can not load script. data/spells/scripts/.lua
[28/07/2015 02:11:31] cannot open data/spells/scripts/.lua: No such file or directory
[28/07/2015 02:11:31] Warning: [Event::loadScript] Can not load script. data/spells/scripts/gran frigo.lua
[28/07/2015 02:11:31] data/spells/scripts/gran frigo.lua:86: '<eof>' expected near 'end'
 
[28/07/2015 02:11:31] Warning: [Event::loadScript] Can not load script. data/spells/scripts/.lua
[28/07/2015 02:11:31] cannot open data/spells/scripts/.lua: No such file or directory
[28/07/2015 02:11:31] Warning: [Event::loadScript] Can not load script. data/spells/scripts/gran frigo.lua
[28/07/2015 02:11:31] data/spells/scripts/gran frigo.lua:86: '<eof>' expected near 'end'

WTH, you're not linking the spells correctly, pay attention on what you set in spells.xml
 
What he really want?

Does he want a spell that explodes 2 times and add soul? BUT, he want it with an unique cooldown that does not affect any other spell? Well I would say to not add a "spellgroup" exaust and set a exaust to the spell itself. BUT anyone can realize that, what makes ME realize that he must be using an old version of tfs and client where one exaust goes to every single spell.... Am I correct?
 
What he really want?

Does he want a spell that explodes 2 times and add soul? BUT, he want it with an unique cooldown that does not affect any other spell? Well I would say to not add a "spellgroup" exaust and set a exaust to the spell itself. BUT anyone can realize that, what makes ME realize that he must be using an old version of tfs and client where one exaust goes to every single spell.... Am I correct?
well he's using old methods and not metamethods, so it's safe to assume it's the pre-cooldown era
 
well he's using old methods and not metamethods, so it's safe to assume it's the pre-cooldown era

But I can't understand one thing.... the first spell mentioned in the thread, the unique cooldown worked fine, but then Bogard done the same thing in the second spell that the author requested and didn't. doesn't make sense to me, I'm kinda lost on the situation, but I really want to help.
 
But I can't understand one thing.... the first spell mentioned in the thread, the unique cooldown worked fine, but then Bogard done the same thing in the second spell that the author requested and didn't. doesn't make sense to me, I'm kinda lost on the situation, but I really want to help.
the first work, put in a newer version already the second ... which is what I really need'm using the old TFS Server 0.3.1 8:40
 
I do not know if will fix, but messing station in the first spell, and I am in need in the second true that would be .
--- I want put Cooldown on this spell... because my friend's server is Bugando spells, the exhaust configured in "spells.xml" is not holding spells correctly ... then I had the idea to put a cooldown on spells to stop this bug ..

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT,CONST_ME_ICEATTACK)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1.6, -0, -1.7, 0)

function onCastSpell(cid, var)
doPlayerAddSoul(cid, math.random(1, 1))
return doCombat(cid, combat, var)
end
 
Try this, I don't know if this will work on your version, but...

Code:
local combat0 = createCombatObject()
setCombatParam(combat0, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat0, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
setCombatParam(combat0, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
setCombatArea(combat0,createCombatArea({
{0, 0, 0, 0, 0},
{0, 1, 1, 1, 0},
{0, 1, 3, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0}}))
function onGetFormulaValues(cid, level, maglevel)
    min = -(maglevel * 1.7 + (2 + (level)))
    max = -(maglevel * 1.7 + (2 + (level * 1.8)))
    return min, max
end
setCombatCallback(combat0, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local function RunPart(c,cid,var,dirList,dirEmitPos)
    if (isCreature(cid)) then
        doCombat(cid, c, var)
        if (dirList ~= nil) then
            local i = 2;
            while (i < #dirList) do
                doSendDistanceShoot(dirEmitPos,{x=dirEmitPos.x-dirList[i],y=dirEmitPos.y-dirList[i+1],z=dirEmitPos.z},dirList[1])
                i = i + 2
            end      
        end
    end
end

function onCastSpell(cid, var)
    local cd_stg = 9080
    local cd_time = 1000 -- 1000 = 1 second
    if getPlayerStorageValue(cid, cd_stg) < 1 then
        setPlayerStorageValue(cid, cd_stg, 1)
        doPlayerAddSoul(cid, math.random(2, 2))
        RunPart(combat0,cid,var)
        addEvent(setPlayerStorageValue,cd_time,cid,cd_stg,0)
    else
        doPlayerSendCancel(cid, "Spells is cooling down")
    end
    return true
end
 
Try this, I don't know if this will work on your version, but...

Code:
local combat0 = createCombatObject()
setCombatParam(combat0, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat0, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
setCombatParam(combat0, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
setCombatArea(combat0,createCombatArea({
{0, 0, 0, 0, 0},
{0, 1, 1, 1, 0},
{0, 1, 3, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0}}))
function onGetFormulaValues(cid, level, maglevel)
    min = -(maglevel * 1.7 + (2 + (level)))
    max = -(maglevel * 1.7 + (2 + (level * 1.8)))
    return min, max
end
setCombatCallback(combat0, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local function RunPart(c,cid,var,dirList,dirEmitPos)
    if (isCreature(cid)) then
        doCombat(cid, c, var)
        if (dirList ~= nil) then
            local i = 2;
            while (i < #dirList) do
                doSendDistanceShoot(dirEmitPos,{x=dirEmitPos.x-dirList[i],y=dirEmitPos.y-dirList[i+1],z=dirEmitPos.z},dirList[1])
                i = i + 2
            end     
        end
    end
end

function onCastSpell(cid, var)
    local cd_stg = 9080
    local cd_time = 1000 -- 1000 = 1 second
    if getPlayerStorageValue(cid, cd_stg) < 1 then
        setPlayerStorageValue(cid, cd_stg, 1)
        doPlayerAddSoul(cid, math.random(2, 2))
        RunPart(combat0,cid,var)
        addEvent(setPlayerStorageValue,cd_time,cid,cd_stg,0)
    else
        doPlayerSendCancel(cid, "Spells is cooling down")
    end
    return true
end
No Error After Using spell ... But no spells on server too '--'
[28/07/2015 14:28:06] Warning: [Event::loadScript] Can not load script. data/spells/scripts/.lua
[28/07/2015 14:28:06] cannot open data/spells/scripts/.lua: No such file or directory
 
It's not even reading the script.... Let's try to do it in parts... brb

-------edtition------

try now, it's not what you want, I'm just testing to see what data your OT is not accepting.

Code:
local combat0 = createCombatObject()
setCombatParam(combat0, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat0, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
setCombatParam(combat0, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
setCombatArea(combat0,createCombatArea({
{0, 0, 0, 0, 0},
{0, 1, 1, 1, 0},
{0, 1, 3, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0}}))
function onGetFormulaValues(cid, level, maglevel)
    min = -(maglevel * 1.7 + (2 + (level)))
    max = -(maglevel * 1.7 + (2 + (level * 1.8)))
    return min, max
end
setCombatCallback(combat0, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local function RunPart(c,cid,var,dirList,dirEmitPos)
    if (isCreature(cid)) then
        doCombat(cid, c, var)
        if (dirList ~= nil) then
            local i = 2;
            while (i < #dirList) do
                doSendDistanceShoot(dirEmitPos,{x=dirEmitPos.x-dirList[i],y=dirEmitPos.y-dirList[i+1],z=dirEmitPos.z},dirList[1])
                i = i + 2
            end    
        end
    end
end

function onCastSpell(cid, var)

        doPlayerAddSoul(cid, math.random(2, 2))
        RunPart(combat0,cid,var)

    return true
end
 
Last edited:
Back
Top Bottom