• 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 [TFS 1.1] addEvent help

Cornwallis

Member
Joined
Jan 3, 2010
Messages
480
Reaction score
16
I've been searching for how to properly use addEvent but i couldn't find any recent results. The while loop may be the problem too. So what it's supposed to do is divide the players soul by 10+ (3*party memebers) so if there's 2 party members then soul = 16, which if i have 100 soul then 100/16 is 6.something, so the while loop will cast the spell 6 times.
HTML:
function onCastSpell(cid, var)
    local pos = getCreaturePosition(cid)
    if getPlayerParty(cid) == TRUE then
        local membersList = getPartyMembers(cid)
        if(membersList == nil or type(membersList) ~= 'table' or #membersList <= 1) then
            doPlayerSendCancel(cid, "No party members in range.")
            doSendMagicEffect(pos, CONST_ME_POFF)
            return false
        end

        local affectedList = {}
        for _, pid in ipairs(membersList) do
            if(getDistanceBetween(getCreaturePosition(pid), pos) <= 36) then
                table.insert(affectedList, pid)
            end
        end

        local tmp = #affectedList
        if(tmp <= 1) then
            doPlayerSendCancel(cid, "No party members in range.")
            doSendMagicEffect(pos, CONST_ME_POFF)
            return false
        end
      
        local soul = 10 + (3*tmp)

        if(doCombat(cid, combat, var) ~= true) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            doSendMagicEffect(pos, CONST_ME_POFF)
            return false
        end
        local soul = getPlayerSoul(cid)/(10 + (3*tmp))
        local event = 0
        local times = event*1000
        doPlayerAddSoul(cid, -soul, FALSE)
        while event <= soul do
            event = event + 1
            addEvent(doCombat(cid, combat, var), times)
            doPlayerAddMana(tmp, min, max)
        end
    else
        local soul = getPlayerSoul(cid)/10
        local event = 0
        local times = event*1000
        local position = getPlayerPosition(cid)
        doPlayerAddSoul(cid, -soul, FALSE)
        while event <= soul do
            event = event + 1
            addEvent(Combat(), times)
            doPlayerAddMana(cid, min, max)
        end
    end
    return true
end
[/code]
I get this error:
HTML:
Lua Script Error: [Spell Interface]
data/spells/scripts/healing/salvation.lua:onCastSpell
LuaScriptInterface::luaAddEvent(). callback parameter should be a function.
stack traceback:
        [C]: in function 'addEvent'
[HTML]
 
I think this:
Code:
addEvent(doCombat(cid, combat, var), times)
should be:
Code:
addEvent(doCombat, cid, combat, var, times)
without the parentheses in the middle
 
i get this error:
HTML:
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
LuaScriptInterface::luaDoCombat(). Creature not found
stack traceback:
        [C]: at 0x7ff6d10a1470
 
Back
Top