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

TFS 1.X+ globalevents boss

theduck

Member
Joined
Dec 6, 2018
Messages
246
Reaction score
20
I'm trying to do that every 15 minutes the boss is creator more if he already has a boss with that name in place he does not do another


Code:
local config = {
    monsterName = 'Ferumbras',
    bossPosition = Position(33384, 31282, 6),
    centerPosition = Position(33384, 31282, 6),
    rangeX = 50,
    rangeY = 50
}
local function checkBoss(centerPosition, rangeX, rangeY, bossName)
    local spectators, spec = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
    for i = 1, #spectators do
        spec = spectators[i]
        if spec:isMonster() then
            if spec:getName() == bossName then
                return true
            end
        end
    end
    return false
end
function onThink(interval, lastExecution)
    if checkBoss(config.centerPosition, config.rangeX, config.rangeY, config.monsterName) then
        return false
    end
    local boss =
    Game.createMonster(config.monsterName, config.bossPosition, true, true)
    boss:setReward(true)
    return true
end
 
Solution
[Error - GlobalEvents::think] Failed to execute event: bossnome
I'm not sure what could be the problem, since there is not really an error to go on..

I don't see why this would cause an issue, but change line 22 to 'return true' instead of 'return false'.

If that doesn't change anything, green text everythingexcept the main function and put 'print("Testing global event")'.. just to make sure the script loads normally without any of the other stuff.

If it does load using only print, start un-green texting stuff until the script errors again.
Once you narrow down the issue to a block of code, or a single line of code, then we/you can look for the issue directly, instead of going through the entire script looking for an error...
line 24, 25
This should appear on the same line, instead of separate lines.
Lua:
local boss =
    Game.createMonster(config.monsterName, config.bossPosition, true, true)

local boss = Game.createMonster(config.monsterName, config.bossPosition, true, true)
I don't see anything else that looks wrong.
 
line 24, 25
This should appear on the same line, instead of separate lines.
Lua:
local boss =
    Game.createMonster(config.monsterName, config.bossPosition, true, true)

local boss = Game.createMonster(config.monsterName, config.bossPosition, true, true)
I don't see anything else that looks wrong.
[Error - GlobalEvents::think] Failed to execute event: bossnome
 
[Error - GlobalEvents::think] Failed to execute event: bossnome
I'm not sure what could be the problem, since there is not really an error to go on..

I don't see why this would cause an issue, but change line 22 to 'return true' instead of 'return false'.

If that doesn't change anything, green text everythingexcept the main function and put 'print("Testing global event")'.. just to make sure the script loads normally without any of the other stuff.

If it does load using only print, start un-green texting stuff until the script errors again.
Once you narrow down the issue to a block of code, or a single line of code, then we/you can look for the issue directly, instead of going through the entire script looking for an error, that might not be obvious.

----
On a side note, I really don't recommend the way you are doing this.

This would be more efficient as an onKill or onDeath script, that way it only triggers when the boss dies, and gives a more accurate respawn timer.
 
Solution
Back
Top