• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[TFS 1.2] Kill monster

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
339
Hi folks, I was trying to make something here but it isn't working, does not have any kind of errors, just don't work.

The idea of this script is if you kill a Ghazbaran for like three times then you'll get a achievement and a storage.

I think this script is fucked up. Don't know, XD!

Code:
local function summonMonster(name, position)
    Game.createMonster(name, position)
    position:sendMagicEffect(CONST_ME_TELEPORT)
end

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if targetMonster:getName():lower() ~= 'ghazbaran' then
        return true
    end

    local player = creature:getPlayer()
    local storage = player:getStorageValue(Storage.bossSlayer)
    if storage >= 0 and storage < 3 then
        player:setStorageValue(Storage.bossSlayer, math.max(1, storage) + 1)
        player:addAchievement('Boss Slayer')
    end
   
    target:say("A demon will be summoned in two minutes", TALKTYPE_MONSTER_SAY, false, player, Position(2454, 2657, 9))
    addEvent(summonMonster, 2 * 60 * 1000, 'Demon', Position(2454, 2657, 9))
   
    return true
end

Thanks everyone.
 
Change
Code:
local storage = player:getStorageValue(Storage.bossSlayer)
if storage >= 0 and storage < 3 then
    player:setStorageValue(Storage.bossSlayer, math.max(1, storage) + 1)
    player:addAchievement('Boss Slayer')
end
to
Code:
local storage = math.max(0, player:getStorageValue(Storage.bossSlayer))
if storage < 3 then
    player:setStorageValue(Storage.bossSlayer, storage + 1)

    if storage + 1 == 3 then
        player:addAchievement('Boss Slayer')
    end
end
 
@silveralol
I didn't know about that. Do you know if it is possible use player:addAchievementProgress to give a achievement if you killed 50 Dragon Lords in a spawnArea?
 
@silveralol
I didn't know about that. Do you know if it is possible use player:addAchievementProgress to give a achievement if you killed 50 Dragon Lords in a spawnArea?
this function I took from orts datapack actions/others/potions
seems that it make the achievement counts every time that run the line...
not tested about the counter of kill bosses....
about the counter of the dragons lords, you just use the function "isInRange" to check if the or Game.getSpectator to check if the DL dies in the determined area
 
Back
Top