LUA:
function returndamage(parameters)
-- Heal self part
local currenthealth = getCreatureHealth(parameters.cid) or 0
local healthlost = parameters.starthealth - currenthealth
local finalcasterpos = getCreaturePosition(parameters.cid)
if healthlost > 0 then
doSendAnimatedText(finalcasterpos, healthlost, 207)
doCreatureAddHealth(parameters.cid, healthlost)
doSendMagicEffect(finalcasterpos, 39)
else
doSendAnimatedText(finalcasterpos, 'No damage', 207)
end
-- Damage others part
if isCreature(parameters.cid) then
playerList = getCreaturesInRange(parameters.casterpos, 10, 10, 1, 1)
for _, pid in ipairs(playerList) do
if getCreatureName(parameters.cid) ~= getCreatureName(pid) then
doSendAnimatedText(getCreaturePosition(pid), 'Targeted', 144)
doSendMagicEffect(getCreaturePosition(pid), 4)
doCreatureAddHealth(pid, (-healthlost))
end
end
end
end
function stillCharging(parameters)
local currentcasterpos = getCreaturePosition(parameters.cid)
doSendMagicEffect(currentcasterpos, 9)
parameters.counter = parameters.counter - 1
if parameters.counter <= 0 then doSendAnimatedText(currentcasterpos, 'charging..', 72) parameters.counter = parameters.textinterval end
end
function onCastSpell(cid, var)
-- Setting variables --
local casterpos = getCreaturePosition(cid)
local starthealth = getCreatureHealth(cid)
local notifyinterval = 500
local textinterval = 2
local chargeduration = 8000
local counter = textinterval
local parameters = {cid = cid, starthealth = starthealth, casterpos = casterpos, counter = counter, textinterval = textinterval}
-- /variables set
-- perform spells
doSendMagicEffect(casterpos, 38)
doSendAnimatedText(casterpos, 'CHARGE', 207)
addEvent(returndamage, chargeduration, parameters)
--addEvent(doDamage, chargeduration, parameters)
for i=1, 8 do
addEvent(stillCharging, notifyinterval, parameters)
notifyinterval = notifyinterval + 1000
end
-- finish off script
return true
end
what it's supposed to do is that it's give back the damage it's recived under a couple of seconds. and the errors i get is.
error:
LUA:
attempt to call global 'getcreaturesinrange' (a nil value)