• 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

Member
Joined
Apr 22, 2012
Messages
524
Solutions
8
Reaction score
15
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
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

jacqen

Well-Known Member
Joined
Jul 10, 2017
Messages
61
Solutions
15
Reaction score
61
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
 
OP
OP
vexler222

vexler222

Member
Joined
Apr 22, 2012
Messages
524
Solutions
8
Reaction score
15
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 ;/
 

Evil Puncker

I know nothing
TFS Developer
Joined
May 30, 2009
Messages
8,116
Solutions
218
Reaction score
4,034
easiest/laziest solution:

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

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

vexler222

Member
Joined
Apr 22, 2012
Messages
524
Solutions
8
Reaction score
15
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?
 

Evil Puncker

I know nothing
TFS Developer
Joined
May 30, 2009
Messages
8,116
Solutions
218
Reaction score
4,034
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
Top