• 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+ [TFS 1.2]creaturescript error onKill(attempt to call method 'getMonster' (a nil value))

Eduardo170

Well-Known Member
Joined
Jan 7, 2014
Messages
422
Solutions
3
Reaction score
66
Location
Caracas, Venezuela
They blocked me in the previous post, and they gave me no reason.
kkgVbiu.jpg

Code:
local bosses = {
    ['ushuriel'] = 200,
    ['zugurosh'] = 201,
    ['madareth'] = 202,
    ['latrivan'] = 203,
    ['golgordan'] = 203,
    ['annihilon'] = 204,
    ['hellgorak'] = 205
}

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

    local targetName = targetMonster:getName():lower()
    local bossStorage = bosses[targetName]
    if not bossStorage then
        print('if not bossStorage then')
        return true
    end

    local newValue = 2
    if targetName == 'latrivan' or targetName == 'golgordan' then
        newValue = math.max(0, Game.getStorageValue(bossStorage)) + 1
    end
    Game.setStorageValue(bossStorage, newValue)
    print('Game.setStorageValue(bossStorage, newValue)')

    if newValue == 2 then
        player:say('You now have 3 minutes to exit this room through the teleporter. It will bring you to the next room.', TALKTYPE_MONSTER_SAY)
        addEvent(Game.setStorageValue, 3 * 60 * 1000, bossStorage, 0)
    end
    return true
end
KM3T02K.png

gnBZj0z.png

I added this in each boss.
Code:
<script>
        <event name="inquisitionBosses"/>
    </script>
 
Last edited:
GetMonster is not in TFS 1.2 libraries.
If you're using an old script, you'll need to add GetMonster to your /data/lib file for creature.lua.
 
Code:
local bosses = {
    ['ushuriel'] = 200,
    ['zugurosh'] = 201,
    ['madareth'] = 202,
    ['latrivan'] = 203,
    ['golgordan'] = 203,
    ['annihilon'] = 204,
    ['hellgorak'] = 205
}

function onKill(player, target)
    local targetMonster = Monster(target)
    if not targetMonster then
        return true
    end

    local targetName = targetMonster:getName():lower()
    local bossStorage = bosses[targetName]
    if not bossStorage then
        print('if not bossStorage then')
        return true
    end

    local newValue = 2
    if targetName == 'latrivan' or targetName == 'golgordan' then
        newValue = math.max(0, Game.getStorageValue(bossStorage)) + 1
    end
    Game.setStorageValue(bossStorage, newValue)
    print('Game.setStorageValue(bossStorage, newValue)')

    if newValue == 2 then
        player:say('You now have 3 minutes to exit this room through the teleporter. It will bring you to the next room.', TALKTYPE_MONSTER_SAY)
        addEvent(Game.setStorageValue, 3 * 60 * 1000, bossStorage, 0)
    end
    return true
end
 
Code:
local bosses = {
    ['ushuriel'] = 200,
    ['zugurosh'] = 201,
    ['madareth'] = 202,
    ['latrivan'] = 203,
    ['golgordan'] = 203,
    ['annihilon'] = 204,
    ['hellgorak'] = 205
}

function onKill(player, target)
    local targetMonster = Monster(target)
    if not targetMonster then
        return true
    end

    local targetName = targetMonster:getName():lower()
    local bossStorage = bosses[targetName]
    if not bossStorage then
        print('if not bossStorage then')
        return true
    end

    local newValue = 2
    if targetName == 'latrivan' or targetName == 'golgordan' then
        newValue = math.max(0, Game.getStorageValue(bossStorage)) + 1
    end
    Game.setStorageValue(bossStorage, newValue)
    print('Game.setStorageValue(bossStorage, newValue)')

    if newValue == 2 then
        player:say('You now have 3 minutes to exit this room through the teleporter. It will bring you to the next room.', TALKTYPE_MONSTER_SAY)
        addEvent(Game.setStorageValue, 3 * 60 * 1000, bossStorage, 0)
    end
    return true
end
work, but now in the brothers latrivan y golgordan :S
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/quests/inquisition/inquisitionBosses.lua:onKill
...scripts/scripts/quests/inquisition/inquisitionBosses.lua:25: bad argument #2
to 'max' (number expected, got nil)
stack traceback:
        [C]: at 0x01207590
        [C]: in function 'max'
        ...scripts/scripts/quests/inquisition/inquisitionBosses.lua:25: in funct
ion <...scripts/scripts/quests/inquisition/inquisitionBosses.lua:11>
 
Code:
local bosses = {
    ['ushuriel'] = 200,
    ['zugurosh'] = 201,
    ['madareth'] = 202,
    ['latrivan'] = 203,
    ['golgordan'] = 203,
    ['annihilon'] = 204,
    ['hellgorak'] = 205
}

function onKill(player, target)
    local targetMonster = Monster(target)
    if not targetMonster then
        return true
    end

    local targetName = targetMonster:getName():lower()
    local bossStorage = bosses[targetName]
    local bossStorageValue = Game.getStorageValue(bossStorage)
    if not bossStorage then
        print('if not bossStorage then')
        return true
    end

    local newValue = 2
    if targetName == 'latrivan' or targetName == 'golgordan' then
        newValue = math.max(0, bossStorageValue ~= -1 and bossStorageValue or 0) + 1
    end
    Game.setStorageValue(bossStorage, newValue)
    print('Game.setStorageValue(bossStorage, newValue)')

    if newValue == 2 then
        player:say('You now have 3 minutes to exit this room through the teleporter. It will bring you to the next room.', TALKTYPE_MONSTER_SAY)
        addEvent(Game.setStorageValue, 3 * 60 * 1000, bossStorage, 0)
    end
    return true
end
 
When I kill latrivan console get me this.
Code:
Game.setStorageValue(bossStorage, newValue)
And after kill latrivan, if u kill golgordan, the console get me same message, but when I use teleport dont work :S, it only happens in latrivan and golgordan.
 
When I kill latrivan console get me this.
Code:
Game.setStorageValue(bossStorage, newValue)
And after kill latrivan, if u kill golgordan, the console get me same message, but when I use teleport dont work :S, it only happens in latrivan and golgordan.

Try

newValue = math.max(0, bossStorageValue and bossStorageValue or 0) + 1
 
Back
Top