• 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 BOOS Check - monster check - TFS 1.5 DOWNGRADE NEKIRO 8.0

Bee King

Active Member
Joined
May 9, 2024
Messages
73
Reaction score
26
In my server, there are 4 open-world bosses, and I set their spawn time to be longer in the spawn XML… They are far from the city, so to check if they are there, you need to take a long walk.


Here comes my request...


I would like a script, an action ID to add to an item or maybe a sign… where, upon use, it shows whether the monster is on the map or not.


Example:


BOSS Demodras - Live
BOSS Dracola - Live
BOSS Flyfly - No live
BOSS The Old Widow - No live



I tried doing something with ChatGPT, but it couldn't find a function to check if a certain monster is on the map...


If anyone can help with this script, or maybe point me in the right direction, I would be very grateful...
 
Solution
You guys are probably using some old Lua version
It has nothing to do with old Lua...

I'm using a more recent TFS. I've tested several different bases, like TFS 1.4.2, 1.5, 1.6, etc., and there was still a bug, even after your last edit. I tested it again, and it didn’t work... I killed the boss, but it still appeared as alive.


I took your script and made some adjustments.


Now, when logging in, it shows information about the number of bosses. If you use the !bosslist command, it displays how many bosses exist. For example, if there are two Dracolas alive, the message will be: 'Boss Dracola alive: 2'. If you kill one and leave the other alive, it will show 'Boss Dracola alive: 1'. If you kill both, it will say...
Have you tried with this?
I've implemented it without any problem and works great, exactly as you want.

If you don't want to make any engine changes then you can attach script to a monster with onDeath / onSpawn event and handle GlobalStorageValues storing info if boss is alive - but it's worse solution when you want to increase boss number.
 
Last edited:
I don't think it's the same as what I want... I don't want data, hours, or anything like that. My bosses are regular monsters added with the map editor... like a rotworm, cyclops, etc.


As for the solution you suggested with globalstorages.
That's what I wanted, an event with onDeath on the monster, and a script to check if it's alive or dead using storages, but I couldn't make it.


I just wanted to know if they are alive on the map or not.
 
Last edited:
I think what I would do is make a revscript using onSpawn to flip a table value to true, while also registering an onDeath event to handle changing the table value to false when the boss dies. You should be able to reference that table in any other LUA functions, or just create a talk action like !bosslist. Something like this should work, although I seem to be making some mistake with onSpawn here:
LUA:
ACTIVE_BOSS_LIST = {
    {name = "Demodras", live = false},
    {name = "Dracola", live = false},
    {name = "Flyfly", live = false},
    {name = "The Old Widow", live = false},
}

local spawnCallback = EventCallback
function spawnCallback.onSpawn(creature, position, startup, artificial)
    for i = 1, #ACTIVE_BOSS_LIST do
        if ACTIVE_BOSS_LIST[i].name == creature:getName() then
            creature:registerEvent("onDeath_registerBoss")
            ACTIVE_BOSS_LIST[i].live = true
        end
    end
    return true
end
spawnCallback:register()

local deathEvent = CreatureEvent("onDeath_registerBoss")
function deathEvent.onKill(creature, target)
    print(target:getName())
    for i = 1, #ACTIVE_BOSS_LIST do
        if ACTIVE_BOSS_LIST[i].name == target:getName() then
            ACTIVE_BOSS_LIST[i].live = false
        end
    end
    return true
end
deathEvent:type("kill")
deathEvent:register()

local talkaction = TalkAction("!bosslist")
function talkaction.onSay(player, words, param, type)
    local msg = ""
    for i = 1, #ACTIVE_BOSS_LIST do
        msg = msg .. "Boss " .. ACTIVE_BOSS_LIST[i].name .. ": " .. (ACTIVE_BOSS_LIST[i].live == true and "Live" or "Not Live") .. "\n"
    end
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg)
    return false
end
talkaction:register()
 
I tested this script, the command "works," but it always says the bosses are dead, even though they are there, alive and well. :|
 
LUA:
local raidBossInformation = {
    {
        dayToSpawn = "Monday",
        position = Position(27, 38, 14),
        monsterName = "Boss Madareth",
        respawnTime = 1, -- hours
        messageOnSpawn = "Boss Madareth is now ... Go kill Him.",
        messageOnDeath = "Boss Madareth has been defeated, the Boss will reveal himself  in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },

    {
        dayToSpawn = "Sunday",
        position = Position(37, 98, 15),
        monsterName = "Boss Dipthrah",
        respawnTime = 1, -- hours
        messageOnSpawn = "Boss Dipthrah is now ... Go kill Him.",
        messageOnDeath = "Boss Dipthrah has been defeated, the Boss will reveal himself  in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
   },
   {
        dayToSpawn = "Monday",
        position = Position(7742, 85, 7),
        monsterName = "Fire Stone",
        respawnTime = 4, -- hours
        messageOnSpawn = "Fire Stone is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Fire Stone has been defeated, the Stone will reveal himself in Raids in 4 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Monday",
        position = Position(7716, 81, 7),
        monsterName = "Metin Stone",
        respawnTime = 1, -- hours
        messageOnSpawn = "Metin Stone is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Metin Stone has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Monday",
        position = Position(7713, 47, 7),
        monsterName = "The Looting Boss",
        respawnTime = 2, -- hours
        messageOnSpawn = "The Looting Boss is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "The Looting Boss has been defeated, the Stone will reveal himself in Raids in 2 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Monday",
        position = Position(7736, 40, 7),
        monsterName = "horrorcore",
        respawnTime = 1, -- hours
        messageOnSpawn = "Horrorcore Boss is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Horrorcore Boss has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Monday",
        position = Position(7745, 36, 7),
        monsterName = "baiak pancada",
        respawnTime = 1, -- hours
        messageOnSpawn = "StongExp is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "StongExp has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Monday",
        position = Position(7753, 36, 7),
        monsterName = "baiak pancada",
        respawnTime = 1, -- hours
        messageOnSpawn = "StongExp is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "StongExp has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },

    {
        dayToSpawn = "Tuesday",
        position = Position(7742, 85, 7),
        monsterName = "Icy Stone",
        respawnTime = 4, -- hours
        messageOnSpawn = "Icy Stone is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Icy Stone has been defeated, the Stone will reveal himself in Raids in 4 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Tuesday",
        position = Position(7716, 81, 7),
        monsterName = "Metin Stone",
        respawnTime = 1, -- hours
        messageOnSpawn = "Metin Stone is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Metin Stone has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Tuesday",
        position = Position(7713, 47, 7),
        monsterName = "The Looting Boss",
        respawnTime = 2, -- hours
        messageOnSpawn = "The Looting Boss is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "The Looting Boss has been defeated, the Stone will reveal himself in Raids in 2 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Tuesday",
        position = Position(7736, 40, 7),
        monsterName = "horrorcore",
        respawnTime = 1, -- hours
        messageOnSpawn = "Horrorcore Boss is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Horrorcore Boss has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Tuesday",
        position = Position(7745, 36, 7),
        monsterName = "baiak pancada",
        respawnTime = 1, -- hours
        messageOnSpawn = "StongExp is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "StongExp has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Tuesday",
        position = Position(7753, 36, 7),
        monsterName = "baiak pancada",
        respawnTime = 1, -- hours
        messageOnSpawn = "StongExp is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "StongExp has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },

    {
        dayToSpawn = "Wednesday",
        position = Position(7742, 85, 7),
        monsterName = "Earth Stone",
        respawnTime = 4, -- hours
        messageOnSpawn = "Earth Stone is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Earth Stone has been defeated, the Stone will reveal himself in Raids in 4 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Wednesday",
        position = Position(7716, 81, 7),
        monsterName = "Metin Stone",
        respawnTime = 1, -- hours
        messageOnSpawn = "Metin Stone is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Metin Stone has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Wednesday",
        position = Position(7713, 47, 7),
        monsterName = "The Looting Boss",
        respawnTime = 2, -- hours
        messageOnSpawn = "The Looting Boss is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "The Looting Boss has been defeated, the Stone will reveal himself in Raids in 2 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Wednesday",
        position = Position(7736, 40, 7),
        monsterName = "horrorcore",
        respawnTime = 1, -- hours
        messageOnSpawn = "Horrorcore Boss is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Horrorcore Boss has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Wednesday",
        position = Position(7745, 36, 7),
        monsterName = "baiak pancada",
        respawnTime = 1, -- hours
        messageOnSpawn = "StongExp is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "StongExp has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Wednesday",
        position = Position(7753, 36, 7),
        monsterName = "baiak pancada",
        respawnTime = 1, -- hours
        messageOnSpawn = "StongExp is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "StongExp has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Thursday",
        position = Position(7742, 85, 7),
        monsterName = "Wind Stone",
        respawnTime = 4, -- hours
        messageOnSpawn = "Wind Stone is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Wind Stone has been defeated, the Stone will reveal himself in Raids in 4 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Thursday",
        position = Position(7716, 81, 7),
        monsterName = "Metin Stone",
        respawnTime = 1, -- hours
        messageOnSpawn = "Metin Stone is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Metin Stone has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Thursday",
        position = Position(7713, 47, 7),
        monsterName = "The Looting Boss",
        respawnTime = 2, -- hours
        messageOnSpawn = "The Looting Boss is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "The Looting Boss has been defeated, the Stone will reveal himself in Raids in 2 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Thursday",
        position = Position(7736, 40, 7),
        monsterName = "horrorcore",
        respawnTime = 1, -- hours
        messageOnSpawn = "Horrorcore Boss is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Horrorcore Boss has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Thursday",
        position = Position(7745, 36, 7),
        monsterName = "baiak pancada",
        respawnTime = 1, -- hours
        messageOnSpawn = "StongExp is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "StongExp has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Thursday",
        position = Position(7753, 36, 7),
        monsterName = "baiak pancada",
        respawnTime = 1, -- hours
        messageOnSpawn = "StongExp is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "StongExp has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },

    {
        dayToSpawn = "Friday",
        position = Position(7742, 85, 7),
        monsterName = "Fire Stone",
        respawnTime = 4, -- hours
        messageOnSpawn = "Fire Stone is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Fire Stone has been defeated, the Stone will reveal himself in Raids in 4 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Friday",
        position = Position(7716, 81, 7),
        monsterName = "Metin Stone",
        respawnTime = 1, -- hours
        messageOnSpawn = "Metin Stone is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Metin Stone has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Friday",
        position = Position(7713, 47, 7),
        monsterName = "The Looting Boss",
        respawnTime = 2, -- hours
        messageOnSpawn = "The Looting Boss is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "The Looting Boss has been defeated, the Stone will reveal himself in Raids in 2 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Friday",
        position = Position(7736, 40, 7),
        monsterName = "horrorcore",
        respawnTime = 1, -- hours
        messageOnSpawn = "Horrorcore Boss is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Horrorcore Boss has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Friday",
        position = Position(7745, 36, 7),
        monsterName = "baiak pancada",
        respawnTime = 1, -- hours
        messageOnSpawn = "StongExp is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "StongExp has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Friday",
        position = Position(7753, 36, 7),
        monsterName = "baiak pancada",
        respawnTime = 1, -- hours
        messageOnSpawn = "StongExp is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "StongExp has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Saturday",
        position = Position(7742, 85, 7),
        monsterName = "Earth Stone",
        respawnTime = 4, -- hours
        messageOnSpawn = "Earth Stone is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Earth Stone has been defeated, the Stone will reveal himself in Raids in 4 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Saturday",
        position = Position(7716, 81, 7),
        monsterName = "Metin Stone",
        respawnTime = 1, -- hours
        messageOnSpawn = "Metin Stone is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Metin Stone has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Saturday",
        position = Position(7713, 47, 7),
        monsterName = "The Looting Boss",
        respawnTime = 2, -- hours
        messageOnSpawn = "The Looting Boss is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "The Looting Boss has been defeated, the Stone will reveal himself in Raids in 2 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Saturday",
        position = Position(7736, 40, 7),
        monsterName = "horrorcore",
        respawnTime = 1, -- hours
        messageOnSpawn = "Horrorcore Boss is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Horrorcore Boss has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Saturday",
        position = Position(7745, 36, 7),
        monsterName = "baiak pancada",
        respawnTime = 1, -- hours
        messageOnSpawn = "StongExp is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "StongExp has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Saturday",
        position = Position(7753, 36, 7),
        monsterName = "baiak pancada",
        respawnTime = 1, -- hours
        messageOnSpawn = "StongExp is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "StongExp has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },

    ------ Pits of Inferno
    {
        dayToSpawn = "Sunday",
        position = Position(7742, 85, 7),
        monsterName = "Metin of Darkness",
        respawnTime = 4, -- hours
        messageOnSpawn = "Metin of Darkness is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Metin of Darkness has been defeated, the Stone will reveal himself in Raids in 4 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Sunday",
        position = Position(7716, 81, 7),
        monsterName = "Metin Stone",
        respawnTime = 1, -- hours
        messageOnSpawn = "Metin Stone is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Metin Stone has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Sunday",
        position = Position(7713, 47, 7),
        monsterName = "The Looting Boss",
        respawnTime = 2, -- hours
        messageOnSpawn = "The Looting Boss is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "The Looting Boss has been defeated, the Stone will reveal himself in Raids in 2 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Sunday",
        position = Position(7736, 40, 7),
        monsterName = "horrorcore",
        respawnTime = 1, -- hours
        messageOnSpawn = "Horrorcore Boss is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "Horrorcore Boss has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Sunday",
        position = Position(7745, 36, 7),
        monsterName = "baiak pancada",
        respawnTime = 1, -- hours
        messageOnSpawn = "StongExp is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "StongExp has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
    {
        dayToSpawn = "Sunday",
        position = Position(7753, 36, 7),
        monsterName = "baiak pancada",
        respawnTime = 1, -- hours
        messageOnSpawn = "StongExp is now in Raids Teleport... Go kill Him.",
        messageOnDeath = "StongExp has been defeated, the Stone will reveal himself in Raids in 1 hours check time say !boss.",
        creatureId = 0, -- don't touch
        lastKilledTime = 0 -- don't touch
    },
}

local day -- don't touch

local function respawnBoss(index)
    local spawn = raidBossInformation[index]
    local monster = Game.createMonster(spawn.monsterName, spawn.position, false, true)
    if monster then
        spawn.creatureId = monster:getId()
        monster:setMasterPosition(spawn.position)
        monster:registerEvent("raidBossDeath1")
        Game.broadcastMessage(spawn.messageOnSpawn, MESSAGE_EVENT_ADVANCE)
    else
        print("Failed to respawn index: " .. index .. " -> " .. spawn.monsterName .. "")
    end
end

local globalevent = GlobalEvent("raidBosses1")

function globalevent.onStartup()
    day = os.date('%A')
    for index, spawn in pairs(raidBossInformation) do
        if spawn.dayToSpawn == day or spawn.dayToSpawn == "Any" then
            local monster = Game.createMonster(spawn.monsterName, spawn.position, false, true)
            if monster then
                spawn.creatureId = monster:getId()
                monster:setMasterPosition(spawn.position)
                monster:registerEvent("raidBossDeath1")
            else
                print("Failed to spawn index: " .. index .. " -> " .. spawn.monsterName .. "")
            end
        end
    end
    return true
end

globalevent:register()


local creatureevent = CreatureEvent("raidBossDeath1")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    local bossId = creature:getId()
    for i = 1, #raidBossInformation do
        if raidBossInformation[i].creatureId == bossId then
            raidBossInformation[i].creatureId = 0
            raidBossInformation[i].lastKilledTime = os.time()
            Game.broadcastMessage(raidBossInformation[i].messageOnDeath, MESSAGE_EVENT_ADVANCE)
            addEvent(respawnBoss, 1000 * 60 * 60 * raidBossInformation[i].respawnTime, i)
            return true
        end
    end
    print("Something went wrong in raidBossDeath script.")
    return true
end

creatureevent:register()


local talk = TalkAction("/boss", "!boss")

function talk.onSay(player, words, param)
    local text = ""
    for i = 1, #raidBossInformation do
        if text ~= "" then
            text = text .. "\n"
        end
        text = text .. raidBossInformation[i].monsterName
        text = text .. " " .. (raidBossInformation[i].dayToSpawn == "Any" and " [" .. day .. "]" or " [" .. raidBossInformation[i].dayToSpawn .. "]") .. "\n    "
        if raidBossInformation[i].creatureId == 0 then
            if raidBossInformation[i].lastKilledTime == 0 then
                text = text .. "Unavailable"
            else
                text = text .. "Dead -> respawning in " .. os.date("!%Hh %Mm %Ss", (raidBossInformation[i].lastKilledTime + (60 * 60 * raidBossInformation[i].respawnTime)) - os.time())
            end
        else
            text = text .. "Alive"
        end
    end
    player:showTextDialog(1953, text, false)
    return false
end

talk:separator(" ")
talk:register()
Post automatically merged:

check this post and make all

 
The friend up there sent me this trend, but what I want is something much simpler... like what Boiga tried to do over there...
 
I'm not sure what mistake I'm making with onSpawn, maybe someone can point out the error
Post automatically merged:

I got some help and the problem is that onSpawn is disabled by default. We can enable it by going to events/events.xml and changing onSpawn under "Monster methods" from 0 to 1.

I had a couple other mistakes in the previous code (onKill should be registered to the players, not the boss monster). Here is a working version:

LUA:
local ACTIVE_BOSS_LIST = {
    {name = "Demodras", live = false},
    {name = "Dracola", live = false},
    {name = "Flyfly", live = false},
    {name = "The Old Widow", live = false},
}

local loginevent = CreatureEvent("login_registration")
function loginevent.onLogin(player)
    player:registerEvent("onKill_BossList")
    return true
end
loginevent:register()

local spawnCallback = EventCallback
function spawnCallback.onSpawn(creature, position, startup, artificial)
    for i = 1, #ACTIVE_BOSS_LIST do
        if ACTIVE_BOSS_LIST[i].name == creature:getName() then
            ACTIVE_BOSS_LIST[i].live = true
        end
    end
    return true
end
spawnCallback:register()

local deathEvent = CreatureEvent("onKill_BossList")
function deathEvent.onKill(creature, target)
    for i = 1, #ACTIVE_BOSS_LIST do
        if ACTIVE_BOSS_LIST[i].name == target:getName() then
            ACTIVE_BOSS_LIST[i].live = false
        end
    end
    return true
end
deathEvent:type("kill")
deathEvent:register()

local talkaction = TalkAction("!bosslist")
function talkaction.onSay(player, words, param, type)
    local msg = ""
    for i = 1, #ACTIVE_BOSS_LIST do
        if msg ~= "" then msg = msg .. "\n" end
        msg = msg .. "Boss " .. ACTIVE_BOSS_LIST[i].name .. ": " .. (ACTIVE_BOSS_LIST[i].live == true and "Live" or "Not Live")
    end
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg)
    return false
end
talkaction:register()
 
Last edited:
It's a pretty simple script. Here’s what you wanted—using the !bosses command to check the status of a boss, whether it's alive or dead. It doesn't matter if it's far or close; it verifies normally and works fine.


Note: If your source doesn’t have the getMonsters function, you’ll need to add it so that the script can check if the monster/boss is present on the map or not. This is very important.



LUA:
local bosses = {
    "Demodras",
    "Dracola",
    "Flyfly",
    "The Old Widow"
}

local talkAction = TalkAction("!bosses")
function talkAction.onSay(player, words, param, type)
    local message = "Boss Status:\n"
    
    local bossNamesMap = {}
    for _, name in ipairs(bosses) do
        bossNamesMap[name:lower()] = true
    end
    
    local bossStatus = {}
    for _, name in ipairs(bosses) do
        bossStatus[name:lower()] = false
    end
    
       -- Iterate through game monsters but process ONLY those matching our predefined boss table
    for _, monster in ipairs(Game.getMonsters()) do
        local monsterName = monster:getName():lower()
        
        -- Constant-time O(1) lookup checks if monster matches any entry in our boss table
        if bossNamesMap[monsterName] then
            bossStatus[monsterName] = true
        end
    end
    
    for _, bossName in ipairs(bosses) do
        local bossNameLower = bossName:lower()
        
        if bossStatus[bossNameLower] then
            message = message .. "BOSS " .. bossName .. " - Alive\n"
        else
            message = message .. "BOSS " .. bossName .. " - Not alive\n"
        end
    end
    
    player:sendTextMessage(MESSAGE_INFO_DESCR, message)
    return false
end
talkAction:register()
 
Last edited:
I made this change in events and also added the new script... it still says that all the bosses are dead :(
Strange, it is working fine for me. Still, Mateus's solution is better, I didn't know that getMonsters() is an option. His code is simpler and faster so I would go with his if you can.
 
It's a pretty simple script. Here’s what you wanted—using the !bosses command to check the status of a boss, whether it's alive or dead. It doesn't matter if it's far or close; it verifies normally and works fine.


Note: If your source doesn’t have the getMonsters function, you’ll need to add it so that the script can check if the monster/boss is present on the map or not. This is very important.



LUA:
local bosses = {
    "Demodras",
    "Dracola",
    "Flyfly",
    "The Old Widow"
}

local talkAction = TalkAction("!bosses")
function talkAction.onSay(player, words, param, type)
    local message = "Boss Status:\n"
    local allMonsters = Game.getMonsters()
 
    for _, bossName in ipairs(bosses) do
        local isAlive = false
     
        for i = 1, #allMonsters do
            if allMonsters[i]:getName():lower() == bossName:lower() then
                isAlive = true
                break
            end
        end
     
        if isAlive then
            message = message .. "BOSS " .. bossName .. " - Alive\n"
        else
            message = message .. "BOSS " .. bossName .. " - Not alive\n"
        end
    end
 
    player:sendTextMessage(MESSAGE_INFO_DESCR, message)
    return false
end
talkAction:register()
I am making the change in the source and will test it... thanks, Prof. Mateus.
 
Last edited:
Lua Script Error: [Scripts Interface]
/home/otserv/data/scripts/custom/checkboss.lua:callback
/home/otserv/data/scripts/custom/checkboss.lua:11: attempt to call field 'getMonsters' (a nil value)
stack traceback:
[C]: in function 'getMonsters'
/home/otserv/data/scripts/custom/checkboss.lua:11: in function </home/otserv/data/scripts/custom/checkboss.lua:9>

Did u add this??
 
It's a pretty simple script. Here’s what you wanted—using the !bosses command to check the status of a boss, whether it's alive or dead. It doesn't matter if it's far or close; it verifies normally and works fine.


Note: If your source doesn’t have the getMonsters function, you’ll need to add it so that the script can check if the monster/boss is present on the map or not. This is very important.



LUA:
local bosses = {
    "Demodras",
    "Dracola",
    "Flyfly",
    "The Old Widow"
}

local talkAction = TalkAction("!bosses")
function talkAction.onSay(player, words, param, type)
    local message = "Boss Status:\n"
    local allMonsters = Game.getMonsters()
  
    for _, bossName in ipairs(bosses) do
        local isAlive = false
      
        for i = 1, #allMonsters do
            if allMonsters[i]:getName():lower() == bossName:lower() then
                isAlive = true
                break
            end
        end
      
        if isAlive then
            message = message .. "BOSS " .. bossName .. " - Alive\n"
        else
            message = message .. "BOSS " .. bossName .. " - Not alive\n"
        end
    end
  
    player:sendTextMessage(MESSAGE_INFO_DESCR, message)
    return false
end
talkAction:register()
I'm sorry, what?
Let's say you have 1000 monsters scattered around on your server, with 20 bosses.
And let's say on average, when you search through the monsters it finds it after half the total monsters..

Every time someone uses this talkaction.. you're iterating through 500 * 20 -> 10,000 monsters to find out if the bosses are alive or dead.

That's just ludicrously inefficient.
Here is a working version:
I've update @boiga 's script slightly here, but it's vastly better then @Mateus Robeerto 's script.
LUA:
local ACTIVE_BOSS_LIST = {
    ["Demodras"] = {alive = false},
    ["Dracola"] = {alive = false},
    ["Flyfly"] = {alive = false},
    ["The Old Widow"] = {alive = false},
}

local loginevent = CreatureEvent("login_registration")
function loginevent.onLogin(player)
    player:registerEvent("onKill_BossList")
    return true
end
loginevent:register()


local spawnCallback = EventCallback
function spawnCallback.onSpawn(creature, position, startup, artificial)
    local boss = ACTIVE_BOSS_LIST[creature:getName()]
    if boss then
        boss.alive = true
    end
    return true
end
spawnCallback:register()


local deathEvent = CreatureEvent("onKill_BossList")
function deathEvent.onKill(creature, target)
    local boss = ACTIVE_BOSS_LIST[creature:getName()]
    if boss then
        boss.alive = false
    end
    return true
end
deathEvent:type("kill")
deathEvent:register()


local talkaction = TalkAction("!bosslist")
function talkaction.onSay(player, words, param, type)

    local bossNames = {}
    for name in pairs(ACTIVE_BOSS_LIST) do
        table.insert(bossNames, name)
    end
    table.sort(bossNames)
    
    local msg = ""    
    for i = 1, #bossNames do
        local name = bossNames[i]
        local data = ACTIVE_BOSS_LIST[name]
        msg = msg .. (i > 1 and "\n" or "") .. "Boss " .. name .. ": " .. (data.alive and "Live" or "Not Live")
    end    
    
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg)    
    return false
end
talkaction:register()
Post automatically merged:

I made this change in events and also added the new script... it still says that all the bosses are dead :(
Most likely you are typing the creatures names into the table without capitals.

You must write "Rat" instead of "rat" or "Dragon Lord" instead of "dragon lord"
 
Last edited by a moderator:
Isso é ridiculamente ineficiente.
But he only has one boss each, not multiple bosses. If he has two Demodras or more, then it's fine—your script is much better. xD
Post automatically merged:

I'm sorry, what?
Let's say you have 1000 monsters scattered around on your server, with 20 bosses.
And let's say on average, when you search through the monsters it finds it after half the total monsters..

Every time someone uses this talkaction.. you're iterating through 500 * 20 -> 10,000 monsters to find out if the bosses are alive or dead.

That's just ludicrously inefficient.

I've update @boiga 's script slightly here, but it's vastly better then @Mateus Robeerto 's script.
LUA:
local ACTIVE_BOSS_LIST = {
    ["Demodras"] = {alive = false},
    ["Dracola"] = {alive = false},
    ["Flyfly"] = {alive = false},
    ["The Old Widow"] = {alive = false},
}

local loginevent = CreatureEvent("login_registration")
function loginevent.onLogin(player)
    player:registerEvent("onKill_BossList")
    return true
end
loginevent:register()


local spawnCallback = EventCallback
function spawnCallback.onSpawn(creature, position, startup, artificial)
    local boss = ACTIVE_BOSS_LIST[creature:getName()]
    if boss then
        boss.alive = true
    end
    return true
end
spawnCallback:register()


local deathEvent = CreatureEvent("onKill_BossList")
function deathEvent.onKill(creature, target)
    local boss = ACTIVE_BOSS_LIST[creature:getName()]
    if boss then
        boss.alive = false
    end
    return true
end
deathEvent:type("kill")
deathEvent:register()


local talkaction = TalkAction("!bosslist")
function talkaction.onSay(player, words, param, type)

    local bossNames = {}
    for name in pairs(ACTIVE_BOSS_LIST) do
        table.insert(bossNames, name)
    end
    table.sort(bossNames)
   
    local msg = ""   
    for i = 1, #bossNames do
        local name = bossNames[i]
        local data = ACTIVE_BOSS_LIST[name]
        msg = msg .. (i > 1 and "\n" or "") .. "Boss " .. name .. ": " .. (data.alive and "Live" or "Not Live")
    end   
   
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg)   
    return false
end
talkaction:register()
Post automatically merged:


Most likely you are typing the creatures names into the table without capitals.

You must write "Rat" instead of "rat" or "Dragon Lord" instead of "dragon lord"
bosses.gif


Haha, I’m surprised you don’t like me anymore. 😂 I took the script you edited and tested it. There was a bug... I used the command to check if the boss was alive or not, and it worked fine. But then, I summoned Demodras and used the command—it showed as alive, which is correct. After killing Demodras, I used the command again, but it still said it was alive...


Note: Demodras is no longer on the map. Can you take a look and improve the script? xD


1742754752713.webp??????
 
Last edited:
Haha, I’m surprised you don’t like me anymore. 😂
I don't hate people. I just dislike poorly made scripts.
Haha, I’m surprised you don’t like me anymore. 😂 I took the script you edited and tested it. There was a bug... I used the command to check if the boss was alive or not, and it worked fine. But then, I summoned Demodras and used the command—it showed as alive, which is correct. After killing Demodras, I used the command again, but it still said it was alive...


Note: Demodras is no longer on the map. Can you take a look and improve the script? xD
You guys are probably using some old Lua version.. so we need to order the functions differently, so that the onLogin method registers after the onKill method is loaded.

Alright, updated and added some basic stuff.

Main drawback of this script is that you can only have 1 unique of each boss on the server.
If you want 2+ demodras for example, you need to change the script almost completely to accommodate that.

Added some basic prints as well, so you can debug in the console.
LUA:
local ACTIVE_BOSS_LIST = ACTIVE_BOSS_LIST or {
    ["dEModRAs"] = {alive = false}, -- can name the boss however you want. won't affect the script.
    ["Dracola"] = {alive = false},
    ["Flyfly"] = {alive = false},
    ["The Old Widow"] = {alive = false},
}

local lowercased_boss_list = {}
for bossName, data in pairs(ACTIVE_BOSS_LIST) do
    lowercased_boss_list[string.lower(bossName)] = data
end
ACTIVE_BOSS_LIST = lowercased_boss_list
lowercased_boss_list = nil

local sortedBossNames = {}
for name in pairs(ACTIVE_BOSS_LIST) do
    table.insert(sortedBossNames, name)
end
table.sort(sortedBossNames)

local function titleCase(str)
    local result = str:gsub("(%a)([%w_']*)", function(first, rest)
        return first:upper() .. rest:lower()
    end)
    return result
end

local spawnCallback = EventCallback
function spawnCallback.onSpawn(creature, position, startup, artificial)
    local boss = ACTIVE_BOSS_LIST[creature:getName():lower()]
    if boss then
        boss.alive = true
        print(creature:getName() .. " is now alive.")
    end
    return true
end
spawnCallback:register()


local deathEvent = CreatureEvent("onKill_BossList")
function deathEvent.onKill(creature, target)
    local boss = ACTIVE_BOSS_LIST[creature:getName():lower()]
    if boss then
        boss.alive = false
        print(creature:getName() .. " is now dead.")
    end
    return true
end
deathEvent:type("kill")
deathEvent:register()


local talkaction = TalkAction("!bosslist")
function talkaction.onSay(player, words, param, type)
    local msg = ""
    for i = 1, #sortedBossNames do
        local name = sortedBossNames[i]
        local data = ACTIVE_BOSS_LIST[name]
        msg = msg .. (i > 1 and "\n" or "") .. "Boss " .. titleCase(name) .. ": " .. (data.alive and "Alive" or "Dead")
    end
 
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg)
    return false
end
talkaction:register()


local loginevent = CreatureEvent("login_registration")
function loginevent.onLogin(player)
    player:registerEvent("onKill_BossList")
    return true
end
loginevent:register()
 
Last edited by a moderator:
You guys are probably using some old Lua version
It has nothing to do with old Lua...

I'm using a more recent TFS. I've tested several different bases, like TFS 1.4.2, 1.5, 1.6, etc., and there was still a bug, even after your last edit. I tested it again, and it didn’t work... I killed the boss, but it still appeared as alive.


I took your script and made some adjustments.


Now, when logging in, it shows information about the number of bosses. If you use the !bosslist command, it displays how many bosses exist. For example, if there are two Dracolas alive, the message will be: 'Boss Dracola alive: 2'. If you kill one and leave the other alive, it will show 'Boss Dracola alive: 1'. If you kill both, it will say they are dead.


I also added the spawn time functionality in the RME Editor. Now, it notifies everyone when a boss spawns and, when it's defeated, it announces it to everyone as well. Pretty simple and functional, without using the getMonsters function.

hug!

LUA:
if not BossTracker then
    BossTracker = {
        bosses = {
            ["demodras"] = {
                name = "Demodras",
                count = 0,
                dead = 0
            },
            ["dracola"] = {
                name = "Dracola",
                count = 0,
                dead = 0
            },
            ["flyfly"] = {
                name = "Flyfly",
                count = 0,
                dead = 0
            },
            ["the old widow"] = {
                name = "The Old Widow",
                count = 0,
                dead = 0
            }
        }
    }
end

local sortedBossNames = {}
for name, data in pairs(BossTracker.bosses) do
    table.insert(sortedBossNames, name)
end
table.sort(sortedBossNames)
local function titleCase(str)
    local result = str:gsub("(%a)([%w_']*)", function(first, rest)
        return first:upper() .. rest:lower()
    end)
    return result
end

local function getBossStatusMessage()
    local msg = ""
    local anyBossAlive = false
    local aliveBosses = {}
 
    for i = 1, #sortedBossNames do
        local name = sortedBossNames[i]
        local data = BossTracker.bosses[name]
        if data.count > 0 then
            anyBossAlive = true
            table.insert(aliveBosses, {name = data.name or titleCase(name), count = data.count})
        end
    end
 
    if anyBossAlive then
        msg = "Active Bosses: "
        for i, boss in ipairs(aliveBosses) do
            if i > 1 then
                msg = msg .. ", "
            end
            msg = msg .. boss.name .. " (" .. boss.count .. ")"
        end
    end
 
    return msg, anyBossAlive
end

local spawnCallback = EventCallback
function spawnCallback.onSpawn(creature, position, startup, artificial)
    local name = string.lower(creature:getName())
    if BossTracker.bosses[name] then
        BossTracker.bosses[name].count = BossTracker.bosses[name].count + 1
        --print(creature:getName() .. " spawned. Count: " .. BossTracker.bosses[name].count)
    
        creature:registerEvent("BossDeathTracker")
    
        local bossName = BossTracker.bosses[name].name or titleCase(name)
        Game.broadcastMessage("Boss " .. bossName .. " has appeared in the world!", MESSAGE_STATUS_WARNING)
    end
    return true
end
spawnCallback:register()

local deathEvent = CreatureEvent("BossDeathTracker")
function deathEvent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    local name = string.lower(creature:getName())
    if BossTracker.bosses[name] then
        BossTracker.bosses[name].count = math.max(0, BossTracker.bosses[name].count - 1)
        BossTracker.bosses[name].dead = BossTracker.bosses[name].dead + 1
    
        local bossName = BossTracker.bosses[name].name or titleCase(name)
        Game.broadcastMessage("Boss " .. bossName .. " has been defeated!", MESSAGE_STATUS_WARNING)
    
        --print(creature:getName() .. " died. Remaining: " .. BossTracker.bosses[name].count .. ", Dead total: " .. BossTracker.bosses[name].dead)
    end
    return true
end
deathEvent:register()

local talkaction = TalkAction("!bosslist")
function talkaction.onSay(player, words, param, type)
    local msg = ""
    for i = 1, #sortedBossNames do
        local name = sortedBossNames[i]
        local data = BossTracker.bosses[name]
        local displayName = data.name or titleCase(name)
    
        if data.count > 0 then
            msg = msg .. (i > 1 and "\n" or "") .. "Boss " .. displayName .. ": Alive " .. data.count
        else
            msg = msg .. (i > 1 and "\n" or "") .. "Boss " .. displayName .. ": Dead"
        end
    end
 
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg)
    return false
end
talkaction:register()

local loginEvent = CreatureEvent("BossTrackerLogin")
function loginEvent.onLogin(player)
    local msg, anyBossAlive = getBossStatusMessage()
    if anyBossAlive then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg)
    end
 
    return true
end
loginEvent:register()

Note: I’m using my TFS 1.7 8.60.
bosses.gif
 
Last edited:
Solution
It has nothing to do with old Lua...

I'm using a more recent TFS. I've tested several different bases, like TFS 1.4.2, 1.5, 1.6, etc., and there was still a bug, even after your last edit. I tested it again, and it didn’t work... I killed the boss, but it still appeared as alive.


I took your script and made some adjustments.


Now, when logging in, it shows information about the number of bosses. If you use the !bosslist command, it displays how many bosses exist. For example, if there are two Dracolas alive, the message will be: 'Boss Dracola alive: 2'. If you kill one and leave the other alive, it will show 'Boss Dracola alive: 1'. If you kill both, it will say they are dead.


I also added the spawn time functionality in the RME Editor. Now, it notifies everyone when a boss spawns and, when it's defeated, it announces it to everyone as well. Pretty simple and functional, without using the getMonsters function.

hug!

LUA:
if not BossTracker then
    BossTracker = {
        bosses = {
            ["demodras"] = {
                name = "Demodras",
                count = 0,
                dead = 0
            },
            ["dracola"] = {
                name = "Dracola",
                count = 0,
                dead = 0
            },
            ["flyfly"] = {
                name = "Flyfly",
                count = 0,
                dead = 0
            },
            ["the old widow"] = {
                name = "The Old Widow",
                count = 0,
                dead = 0
            }
        }
    }
end

local sortedBossNames = {}
for name, data in pairs(BossTracker.bosses) do
    table.insert(sortedBossNames, name)
end
table.sort(sortedBossNames)
local function titleCase(str)
    local result = str:gsub("(%a)([%w_']*)", function(first, rest)
        return first:upper() .. rest:lower()
    end)
    return result
end

local function getBossStatusMessage()
    local msg = ""
    local anyBossAlive = false
    local aliveBosses = {}
 
    for i = 1, #sortedBossNames do
        local name = sortedBossNames[i]
        local data = BossTracker.bosses[name]
        if data.count > 0 then
            anyBossAlive = true
            table.insert(aliveBosses, {name = data.name or titleCase(name), count = data.count})
        end
    end
 
    if anyBossAlive then
        msg = "Active Bosses: "
        for i, boss in ipairs(aliveBosses) do
            if i > 1 then
                msg = msg .. ", "
            end
            msg = msg .. boss.name .. " (" .. boss.count .. ")"
        end
    end
 
    return msg, anyBossAlive
end

local spawnCallback = EventCallback
function spawnCallback.onSpawn(creature, position, startup, artificial)
    local name = string.lower(creature:getName())
    if BossTracker.bosses[name] then
        BossTracker.bosses[name].count = BossTracker.bosses[name].count + 1
        --print(creature:getName() .. " spawned. Count: " .. BossTracker.bosses[name].count)
   
        creature:registerEvent("BossDeathTracker")
   
        local bossName = BossTracker.bosses[name].name or titleCase(name)
        Game.broadcastMessage("Boss " .. bossName .. " has appeared in the world!", MESSAGE_STATUS_WARNING)
    end
    return true
end
spawnCallback:register()

local deathEvent = CreatureEvent("BossDeathTracker")
function deathEvent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    local name = string.lower(creature:getName())
    if BossTracker.bosses[name] then
        BossTracker.bosses[name].count = math.max(0, BossTracker.bosses[name].count - 1)
        BossTracker.bosses[name].dead = BossTracker.bosses[name].dead + 1
   
        local bossName = BossTracker.bosses[name].name or titleCase(name)
        Game.broadcastMessage("Boss " .. bossName .. " has been defeated!", MESSAGE_STATUS_WARNING)
   
        --print(creature:getName() .. " died. Remaining: " .. BossTracker.bosses[name].count .. ", Dead total: " .. BossTracker.bosses[name].dead)
    end
    return true
end
deathEvent:register()

local talkaction = TalkAction("!bosslist")
function talkaction.onSay(player, words, param, type)
    local msg = ""
    for i = 1, #sortedBossNames do
        local name = sortedBossNames[i]
        local data = BossTracker.bosses[name]
        local displayName = data.name or titleCase(name)
   
        if data.count > 0 then
            msg = msg .. (i > 1 and "\n" or "") .. "Boss " .. displayName .. ": Alive " .. data.count
        else
            msg = msg .. (i > 1 and "\n" or "") .. "Boss " .. displayName .. ": Dead"
        end
    end
 
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg)
    return false
end
talkaction:register()

local loginEvent = CreatureEvent("BossTrackerLogin")
function loginEvent.onLogin(player)
    local msg, anyBossAlive = getBossStatusMessage()
    if anyBossAlive then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg)
    end
 
    return true
end
loginEvent:register()

Note: I’m using my TFS 1.7 8.60.
View attachment 91286

Your script is so bad, I'm gonna delete my account.
 
Back
Top