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

combo sd spell problem tfs 1.3

vexler222

Active Member
Joined
Apr 22, 2012
Messages
714
Solutions
15
Reaction score
46
Hi, i have problem with combo sd spell, it working normal, but i try add cooldown for 30s, and cooldown work good, but after when i added it, spell not working right, he shooting only one time not 3x :/

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 4) + (maglevel * 18) + 120
    local max = (level / 4) + (maglevel * 19) + 200
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local function executeAttack(cid, variant, i, j)
    local player = Player(cid)
    if not player then
        return
    end
    if i >= j then
        return
    end
        if player:getExhaustion(10107) > 1 then
            player:sendCancelMessage("Blocked for: " .. player:getExhaustion(10107) .." sek")
            return false
        end
    addEvent(executeAttack, 250, cid, variant, i + 1, j)
    return combat:execute(player, variant) and player:setExhaustion(10107, 30)
end

function onCastSpell(creature, variant, isHotkey)
    return executeAttack(creature:getId(), variant, 0, 3)
end
 
Solution
E
One second ago i add local player = Player(creature) and it work, its wrong?
Can you explain me why when i add local player = Player(cid) and to function i add
function onCastSpell(creature, variant, isHotkey, player)
or
function onCastSpell(creature, variant, isHotkey, cid)

it not working?
i can't use creature and player in one function?

yes you can and should add

local player = Player(creature) and it work

its actually the correct way :D
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 4) + (maglevel * 18) + 120
    local max = (level / 4) + (maglevel * 19) + 200
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local function executeAttack(cid, variant, i, j)
    local player = Player(cid)
    if not player then
        return
    end
    if i >= j then
        return
    end
    addEvent(executeAttack, 250, cid, variant, i + 1, j)
    return combat:execute(player, variant)
end

function onCastSpell(creature, variant, isHotkey)
    if player:getExhaustion(10107) > 1 then
        player:sendCancelMessage("Blocked for: " .. player:getExhaustion(10107) .." sek")
        return false
    end
    player:setExhaustion(10107, 30)
    return executeAttack(creature:getId(), variant, 0, 3)
end
 
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 4) + (maglevel * 18) + 120
    local max = (level / 4) + (maglevel * 19) + 200
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local function executeAttack(cid, variant, i, j)
    local player = Player(cid)
    if not player then
        return
    end
    if i >= j then
        return
    end
    addEvent(executeAttack, 250, cid, variant, i + 1, j)
    return combat:execute(player, variant)
end

function onCastSpell(creature, variant, isHotkey)
    if player:getExhaustion(10107) > 1 then
        player:sendCancelMessage("Blocked for: " .. player:getExhaustion(10107) .." sek")
        return false
    end
    player:setExhaustion(10107, 30)
    return executeAttack(creature:getId(), variant, 0, 3)
end
Im trying too like it, but i got errors with player nill value, i tryed add "player" in function but still not work ;/
 
easiest/laziest solution:

change:
Lua:
function onCastSpell(creature, variant, isHotkey)

to:
Lua:
function onCastSpell(player, variant, isHotkey)
 
easiest/laziest solution:

change:
Lua:
function onCastSpell(creature, variant, isHotkey)

to:
Lua:
function onCastSpell(player, variant, isHotkey)

One second ago i add local player = Player(creature) and it work, its wrong?
Can you explain me why when i add local player = Player(cid) and to function i add
function onCastSpell(creature, variant, isHotkey, player)
or
function onCastSpell(creature, variant, isHotkey, cid)

it not working?
i can't use creature and player in one function?
 
One second ago i add local player = Player(creature) and it work, its wrong?
Can you explain me why when i add local player = Player(cid) and to function i add
function onCastSpell(creature, variant, isHotkey, player)
or
function onCastSpell(creature, variant, isHotkey, cid)

it not working?
i can't use creature and player in one function?

yes you can and should add

local player = Player(creature) and it work

its actually the correct way :D
 
Solution
Back
Top