• 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!

RevScripts Callback event error on script

Icaraii

Member
Joined
Jan 5, 2020
Messages
168
Reaction score
21
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:
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?
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
895
Solutions
87
Reaction score
867
Location
London
GitHub
MillhioreBT
You must have the EventCallback system on your server, otherwise it won't work, since I am using local variables for everything, it would be impossible to simply copy the code to the event onTargetCombat on data/events/scripts/creature.lua but with a small modification it would be enough
but right now I have to do something and I can't, so if later I have time I will help you with pleasure
 
OP
I

Icaraii

Member
Joined
Jan 5, 2020
Messages
168
Reaction score
21
I use TFS 1.3, but I don't know if I have the eventcallback system. I will be glad if you can help me when you have the time, thanks.
 
Top