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

Solved When kill player i got Lua Script Error: [CreatureScript Interface]

victorlima

Member
Joined
Aug 17, 2023
Messages
33
Reaction score
7
GitHub
victorvadl
When i kill some player in my OT im having this issue in my server console, lua script error in another script, quest scripts.

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/inquisitionQuestUngreez.lua:onKill
data/creaturescripts/scripts/inquisitionQuestUngreez.lua:2: attempt to call method 'getMonster' (a nil value)
stack traceback:
        [C]: in function 'getMonster'
        data/creaturescripts/scripts/inquisitionQuestUngreez.lua:2: in function <data/creaturescripts/scripts/inquisitionQuestUngreez.lua:1>

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/inquisitionQuestBosses.lua:onKill
data/creaturescripts/scripts/inquisitionQuestBosses.lua:12: attempt to call method 'getMonster' (a nil value)
stack traceback:
        [C]: in function 'getMonster'
        data/creaturescripts/scripts/inquisitionQuestBosses.lua:12: in function <data/creaturescripts/scripts/inquisitionQuestBosses.lua:11>

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/arena_kill.lua:onKill
data/creaturescripts/scripts/arena_kill.lua:2: attempt to call method 'getMonster' (a nil value)
stack traceback:
        [C]: in function 'getMonster'
        data/creaturescripts/scripts/arena_kill.lua:2: in function <data/creaturescripts/scripts/arena_kill.lua:1>

Can anybody help me plz?
I'm using this server: SabrehavenServer 8.0
 
Solution
can you help me to fix the others? I will try do the same thing
Lua:
function onKill(creature, target)
    local targetMonster = Monster(target:getId())
    if not targetMonster then
        return
    end

    local player = Player(creature:getId())
    if not player then
        return true
    end
    
    local pit = player:getStorageValue(1101)
    if pit < 1 or pit > 10 then
        return
    end

    local arena = player:getStorageValue(1100)
    if arena < 1 then
        return
    end

    if not isInArray(ARENA[arena].creatures, targetMonster:getName():lower()) then
        return
    end

    -- Remove pillar and create teleport
    local pillarTile = Tile(PITS[pit].pillar)
    if pillarTile then
        local pillarItem =...
Lua:
function onKill(creature, target)
    local targetMonster = Monster(target:getId())
    if not targetMonster then
        return true
    end

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

    local player = Player(creature:getId())
    if not player then
        return true
    end
    if player:getStorageValue(12160) == 18 then
        -- The Inquisition Questlog- 'Mission 6: The Demon Ungreez'
        player:setStorageValue(12166, 2)
        player:setStorageValue(12160, 19)
    end
    return true
end
 
Lua:
function onKill(creature, target)
    local targetMonster = Monster(target:getId())
    if not targetMonster then
        return true
    end

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

    local player = Player(creature:getId())
    if not player then
        return true
    end
    if player:getStorageValue(12160) == 18 then
        -- The Inquisition Questlog- 'Mission 6: The Demon Ungreez'
        player:setStorageValue(12166, 2)
        player:setStorageValue(12160, 19)
    end
    return true
end
Where should i put it? It will solve all errors or just for demon Ungreez? My inquisitionQuestUngreez is actually like this:


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

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

    local player = creature:getPlayer()
    if player:getStorageValue(12160) == 18 then
        -- The Inquisition Questlog- 'Mission 6: The Demon Ungreez'
        player:setStorageValue(12166, 2)
        player:setStorageValue(12160, 19)
    end
    return true
end

All I need is just change it for your code?
 
Yes.

It will fix it for just this one.
It fixed just one of 3 issues look:

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/inquisitionQuestBosses.lua:onKill
data/creaturescripts/scripts/inquisitionQuestBosses.lua:12: attempt to call method 'getMonster' (a nil value)
stack traceback:
        [C]: in function 'getMonster'
        data/creaturescripts/scripts/inquisitionQuestBosses.lua:12: in function <data/creaturescripts/scripts/inquisitionQuestBosses.lua:11>

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/arena_kill.lua:onKill
data/creaturescripts/scripts/arena_kill.lua:2: attempt to call method 'getMonster' (a nil value)
stack traceback:
        [C]: in function 'getMonster'
        data/creaturescripts/scripts/arena_kill.lua:2: in function <data/creaturescripts/scripts/arena_kill.lua:1>
Teste has logged out.

I think i have to do the same ajust for the other 2. inquisitionQuestBosses and arena_kill.

Look my arena_kill
Lua:
function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return
    end

    local player = creature:getPlayer()
    local pit = player:getStorageValue(1101)
    if pit < 1 or pit > 10 then
        return
    end

    local arena = player:getStorageValue(1100)
    if arena < 1 then
        return
    end

    if not isInArray(ARENA[arena].creatures, targetMonster:getName():lower()) then
        return
    end

    -- Remove pillar and create teleport
    local pillarTile = Tile(PITS[pit].pillar)
    if pillarTile then
        local pillarItem = pillarTile:getItemById(SvargrondArena.itemPillar)
        if pillarItem then
            pillarItem:remove()

            local teleportItem = Game.createItem(SvargrondArena.itemTeleport, 1, PITS[pit].tp)
            if teleportItem then
                teleportItem:setMovementId(25200)
            end

            SvargrondArena.sendPillarEffect(pit)
        end
    end

    player:setStorageValue(1101, pit + 1)
    player:say('Victory! Head through the new teleporter into the next room.', TALKTYPE_MONSTER_SAY)
    return true
end

and my inquisitionQuestBosses:


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
        return true
    end

    local newValue = 2
    if targetName == 'latrivan' or targetName == 'golgordan' then
        local currentValue = 0
        if Game.getStorageValue(bossStorage) then
            currentValue = Game.getStorageValue(bossStorage)
        end
      
        newValue = math.max(0, currentValue) + 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

Can you please explain what u did and what u change to fix?
 
basically just changed
Lua:
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end
to this
Lua:
    local targetMonster = Monster(target:getId())
    if not targetMonster then
        return true
    end
 
can you help me to fix the others? I will try do the same thing
Lua:
function onKill(creature, target)
    local targetMonster = Monster(target:getId())
    if not targetMonster then
        return
    end

    local player = Player(creature:getId())
    if not player then
        return true
    end
    
    local pit = player:getStorageValue(1101)
    if pit < 1 or pit > 10 then
        return
    end

    local arena = player:getStorageValue(1100)
    if arena < 1 then
        return
    end

    if not isInArray(ARENA[arena].creatures, targetMonster:getName():lower()) then
        return
    end

    -- Remove pillar and create teleport
    local pillarTile = Tile(PITS[pit].pillar)
    if pillarTile then
        local pillarItem = pillarTile:getItemById(SvargrondArena.itemPillar)
        if pillarItem then
            pillarItem:remove()

            local teleportItem = Game.createItem(SvargrondArena.itemTeleport, 1, PITS[pit].tp)
            if teleportItem then
                teleportItem:setMovementId(25200)
            end

            SvargrondArena.sendPillarEffect(pit)
        end
    end

    player:setStorageValue(1101, pit + 1)
    player:say('Victory! Head through the new teleporter into the next room.', TALKTYPE_MONSTER_SAY)
    return true
end
Lua:
local bosses = {
    ['ushuriel'] = 200,
    ['zugurosh'] = 201,
    ['madareth'] = 202,
    ['latrivan'] = 203,
    ['golgordan'] = 203,
    ['annihilon'] = 204,
    ['hellgorak'] = 205
}

function onKill(player, target)
    local targetMonster = Monster(target:getId())
    if not targetMonster then
        return
    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
        local currentValue = 0
        if Game.getStorageValue(bossStorage) then
            currentValue = Game.getStorageValue(bossStorage)
        end
      
        newValue = math.max(0, currentValue) + 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
 
Solution
Lua:
function onKill(creature, target)
    local targetMonster = Monster(target:getId())
    if not targetMonster then
        return
    end

    local player = Player(creature:getId())
    if not player then
        return true
    end
   
    local pit = player:getStorageValue(1101)
    if pit < 1 or pit > 10 then
        return
    end

    local arena = player:getStorageValue(1100)
    if arena < 1 then
        return
    end

    if not isInArray(ARENA[arena].creatures, targetMonster:getName():lower()) then
        return
    end

    -- Remove pillar and create teleport
    local pillarTile = Tile(PITS[pit].pillar)
    if pillarTile then
        local pillarItem = pillarTile:getItemById(SvargrondArena.itemPillar)
        if pillarItem then
            pillarItem:remove()

            local teleportItem = Game.createItem(SvargrondArena.itemTeleport, 1, PITS[pit].tp)
            if teleportItem then
                teleportItem:setMovementId(25200)
            end

            SvargrondArena.sendPillarEffect(pit)
        end
    end

    player:setStorageValue(1101, pit + 1)
    player:say('Victory! Head through the new teleporter into the next room.', TALKTYPE_MONSTER_SAY)
    return true
end
Lua:
local bosses = {
    ['ushuriel'] = 200,
    ['zugurosh'] = 201,
    ['madareth'] = 202,
    ['latrivan'] = 203,
    ['golgordan'] = 203,
    ['annihilon'] = 204,
    ['hellgorak'] = 205
}

function onKill(player, target)
    local targetMonster = Monster(target:getId())
    if not targetMonster then
        return
    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
        local currentValue = 0
        if Game.getStorageValue(bossStorage) then
            currentValue = Game.getStorageValue(bossStorage)
        end
     
        newValue = math.max(0, currentValue) + 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
Thanks my friend! It worked! Do you know how can I compile my client? Im using 800otClient, and it have so many folders, i want to compile to just one .exe file. Do u have discord?
 
Back
Top