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.
I get this error:
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]
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]