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

Problem Inquisition tfs 1.3

Simonalina

Member
Joined
May 10, 2008
Messages
179
Solutions
1
Reaction score
14
Location
Sweden
So, when i kill golgordan or latrivan in inquisition quest i get this error

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/quests/inquisition/inquisitionQuestBosses.lua:eek:nKill
...ts/scripts/quests/inquisition/inquisitionQuestBosses.lua:25: bad argument #2 to 'max' (number expected, got nil)
stack traceback:
[C]: at 0x7ff657675db0
[C]: in function 'max'
...ts/scripts/quests/inquisition/inquisitionQuestBosses.lua:25: in function <...ts/scripts/quests/inquisition/inquisitionQuestBosses.lua:11>


Lua:
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
        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)

    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
 

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,246
Solutions
71
Reaction score
585
Location
Hell
No one? :O

newValue = math.max(0, Game.getStorageValue(bossStorage)) + 1
argument 1 = 0
argument 2 = Game.getStorageValue(bossStorage)

your error message:
bad argument #2 to 'max' (number expected, got nil)
which in simpler language means : "max function needs a number for the 2nd argument but nil was passed." (nil means nothing/void/null/empty)

Your problem is:
Game.getStorageValue(bossStorage)
returns NIL and not a Number

try replacing
newValue = math.max(0, Game.getStorageValue(bossStorage)) + 1
with
newValue = math.max(0, Game.getStorageValue(bossStorage) or 0) + 1
 
Top