Hi,
I put @Sarah Wesker script explosive and heal a nearby boss monsters in my server, but I can't make it work, don't know why. When I copy and past the script to my data/scripts it appears a error on Eventcallback.
Sarah script:
The error it appears on TFS is:
Can somebody help me understand why isn't working?
I put @Sarah Wesker script explosive and heal a nearby boss monsters in my server, but I can't make it work, don't know why. When I copy and past the script to my data/scripts it appears a error on Eventcallback.
Sarah script:
Lua:
local explosion = {
["Demon"] = {
area = createCombatArea(AREA_CROSS6X6),
min = -1000,
max = -1500,
effect = CONST_ME_FIREAREA,
combat = COMBAT_FIREDAMAGE
}
}
local cExplosionWhenDie = CreatureEvent("ExplosionWhenDie")
function cExplosionWhenDie.onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
local prop = explosion[creature:getName()]
if prop then
doAreaCombatHealth(creature:getId(), prop.combat, creature:getPosition(), prop.area, prop.min, prop.max, prop.effect, ORIGIN_SPELL)
end
return true
end
cExplosionWhenDie:register()
local healing = {
["Dragon"] = {
bossName = "Demon",
radius = 7,
min = 1000,
max = 1500,
distanceEffect = CONST_ANI_HOLY,
effect = CONST_ME_MAGIC_BLUE
}
}
local cHealBossWhenDie = CreatureEvent("HealBossWhenDie")
function cHealBossWhenDie.onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
local prop = healing[creature:getName()]
if prop then
local creaturePos = creature:getPosition()
local spectators = Game.getSpectators(creaturePos, false, false, prop.radius, prop.radius, prop.radius, prop.radius)
for _, spectator in pairs(spectators) do
if spectator:getName() == prop.bossName then
bossPosition = spectator:getPosition()
creaturePos:sendDistanceEffect(bossPosition, prop.distanceEffect)
spectator:addHealth(math.random(prop.min, prop.max))
bossPosition:sendMagicEffect(prop.effect)
end
end
end
return true
end
cHealBossWhenDie:register()
local ev = EventCallback
function ev.onTargetCombat(creature, target)
if creature:isPlayer() and target:isMonster() then
if explosion[target:getName()] then
target:registerEvent("ExplosionWhenDie")
elseif healing[target:getName()] then
target:registerEvent("HealBossWhenDie")
end
end
return RETURNVALUE_NOERROR
end
The error it appears on TFS is:
Lua Script Error: [Scripts Interface]
C:\opentibia\data\scripts\bossmechanichealandexplosion.lua
C:\opentibia\data\scripts\bossmechanichealandexplosion.lua:48: attempt to index local 'ev' (a nil value)
stack traceback:
[C]: in function '__newindex'
C:\opentibia\data\scripts\bossmechanichealandexplosion.lua:48: in main chunk
bossmechanichealandexplosion.lua [error]
Can somebody help me understand why isn't working?