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

Arena_kill error

Hokku

Member
Joined
Jul 25, 2013
Messages
98
Reaction score
18
Location
Extremadura, Spain
Hello! I had configured svargrond arena script from Printer datapack https://otland.net/threads/10-77-tfs-1-2-orts-a-real-map-project.204514/ to my TFS 1.1 by Mark Samman and after repair all debugs when i join the pit and kill the first boss Frostfur, nothing happens, pile doesnt move. Here is the debug at console
2m2dwtt.png


My arena_kill.lua
Code:
function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return
    end

    local player = creature:getPlayer()
    local pit = player:getStorageValue(Storage.SvargrondArena.Pit)
    if pit < 1 or pit > 10 then
        return
    end

    local arena = player:getStorageValue(Storage.SvargrondArena.Arena)
    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:setActionId(25200)
            end

            SvargrondArena.sendPillarEffect(pit)
        end
    end

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

Spended last two days trying to fix by myself and not i cannot, would be great if someone can help me.
 
Solution
The script is fine, just add this method to lib/core/creature.lua.
Code:
function Creature.getMonster(self)
    return self:isMonster() and self or nil
end
untested:
Code:
function onKill(creature, target)
    if not target:isMonster() then
        return false
    end

    local targetMonster = target:getMonster()
    local player = creature:getPlayer()
    local pit = player:getStorageValue(Storage.SvargrondArena.Pit)
    if pit < 1 or pit > 10 then
        return
    end

    local arena = player:getStorageValue(Storage.SvargrondArena.Arena)
    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:setActionId(25200)
            end

            SvargrondArena.sendPillarEffect(pit)
        end
    end

    player:setStorageValue(Storage.SvargrondArena.Pit, pit + 1)
    player:say('Victory! Head through the new teleporter into the next room.', TALKTYPE_MONSTER_SAY)
    return true
end
 
Code:
    function onKill(creature, target)
        if not target:isMonster() then
            return false
        end

        local targetMonster = target:getMonster()
        local player = creature:getPlayer()
        local pit = player:getStorageValue(Storage.SvargrondArena.Pit)

        if pit < 1 or pit > 10 then
            return false
        end

        local arena = player:getStorageValue(Storage.SvargrondArena.Arena)
        if arena < 1 then
            return false
        end

        if not isInArray(ARENA[arena].creatures, targetMonster:getName():lower()) then
            return false
        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:setActionId(25200)
                end
                SvargrondArena.sendPillarEffect(pit)
            end
        end

        player:setStorageValue(Storage.SvargrondArena.Pit, pit + 1)
        player:say('Victory! Head through the new teleporter into the next room.', TALKTYPE_MONSTER_SAY)
        return true
    end
 
The script is fine, just add this method to lib/core/creature.lua.
Code:
function Creature.getMonster(self)
    return self:isMonster() and self or nil
end
 
Solution
untested:
Code:
function onKill(creature, target)
    if not target:isMonster() then
        return false
    end

    local targetMonster = target:getMonster()
    local player = creature:getPlayer()
    local pit = player:getStorageValue(Storage.SvargrondArena.Pit)
    if pit < 1 or pit > 10 then
        return
    end

    local arena = player:getStorageValue(Storage.SvargrondArena.Arena)
    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:setActionId(25200)
            end

            SvargrondArena.sendPillarEffect(pit)
        end
    end

    player:setStorageValue(Storage.SvargrondArena.Pit, pit + 1)
    player:say('Victory! Head through the new teleporter into the next room.', TALKTYPE_MONSTER_SAY)
    return true
end
I seen this indent tags that is why I re-posted your code.
 
Sorry for posting again but the script have a little issue and is lagging my server a lot, i tried to add 'addAchievement' function from Printer datapack and other servers lib and havent found nothing about it, the script dont give my any ingame bug, so i can complete the quest, and quest log is ok. Using custom map.

f1krit.png


movements/arenaPit.lua
Code:
local condition = Condition(CONDITION_OUTFIT)
condition:setTicks(120000)
condition:setOutfit({lookType = 111})

function onStepIn(creature, item, position, fromPosition)


    local player = creature:getPlayer()

    if not player then

        return
true    end



    local playerId = player.uid
    if item.actionid == 25300 then

        player:addCondition(condition)


        player:setStorageValue(Storage.SvargrondArena.Pit, 0)

        player:teleportTo(SvargrondArena.kickPosition)

        player:say('Coward!', TALKTYPE_MONSTER_SAY)

        SvargrondArena.cancelEvents(playerId)

        return true

    end



    local pitId = player:getStorageValue(Storage.SvargrondArena.Pit)

    local arenaId = player:getStorageValue(Storage.SvargrondArena.Arena)
    if pitId > 10 then

        player:teleportTo(SvargrondArena.rewardPosition)

        player:setStorageValue(Storage.SvargrondArena.Pit, 0)

        if arenaId == 1 then

            SvargrondArena.rewardPosition:sendMagicEffect(CONST_ME_FIREWORK_BLUE)

            player:setStorageValue(Storage.SvargrondArena.Greenhorn, 1)

            player:say('Welcome back, little hero!', TALKTYPE_MONSTER_SAY)

            elseif arenaId == 2 then

            SvargrondArena.rewardPosition:sendMagicEffect(CONST_ME_FIREWORK_YELLOW)

            player:setStorageValue(Storage.SvargrondArena.Scrapper, 1)

            player:say('Congratulations, brave warrior!', TALKTYPE_MONSTER_SAY)

            elseif arenaId == 3 then

            SvargrondArena.rewardPosition:sendMagicEffect(CONST_ME_FIREWORK_RED)

            player:setStorageValue(Storage.SvargrondArena.Warlord, 1)

            player:say('Respect and honour to you, champion!', TALKTYPE_MONSTER_SAY)

        end



        player:setStorageValue(Storage.SvargrondArena.Arena, player:getStorageValue(Storage.SvargrondArena.Arena) + 1)

        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You completed ' .. ARENA[arenaId].name .. ' arena, you should take your reward now.')
        player:setStorageValue(ARENA[arenaId].questLog, 2)

        player:addAchievement(ARENA[arenaId].achievement)

        SvargrondArena.cancelEvents(playerId)

        return true

    end



    local occupant = SvargrondArena.getPitOccupant(pitId, player)

    if occupant then

        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, occupant:getName() .. ' is currently in the next arena pit. Please wait until ' .. (occupant:getSex() == PLAYERSEX_FEMALE and 's' or '') .. 'he is done fighting.')

        player:teleportTo(fromPosition, true)

        return true
    end

    SvargrondArena.cancelEvents(playerId)

    SvargrondArena.resetPit(pitId)
    SvargrondArena.scheduleKickPlayer(playerId, pitId)

    Game.createMonster(ARENA[arenaId].creatures[pitId], PITS[pitId].summon, false, true)


    player:teleportTo(PITS[pitId].center)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)

    player:say('Fight!', TALKTYPE_MONSTER_SAY)

    return true
end

The related ¿functions? in the console from line 282 to 309:

lib/arenaSvargrondQuest.lua
Code:
LINE 282 ----- function SvargrondArena.scheduleKickPlayer(cid, pitId)
    SvargrondArena.cancelEvents(cid)
    SvargrondArena.startTimer(pitId)
    local eventId = addEvent(SvargrondArena.kickPlayer, SvargrondArena.kickTime * 1000, cid)
    SvargrondArena.kickEvents[cid] = {eventId = eventId, pitId = pitId}
end

function SvargrondArena.startTimer(pitId)
    local tile = Tile(PITS[pitId].fromPos)
    if not tile then
        return
    end

    local timerItem = tile:getItemById(SvargrondArena.itemTimer)
    if timerItem then
        timerItem:remove()
    end

    timerItem = Game.createItem(SvargrondArena.itemTimer, 1, PITS[pitId].fromPos)
    if timerItem then
        timerItem:decay()
    end

    if SvargrondArena.timerEvents[pitId] then
        stopEvent(SvargrondArena.timerEvents[pitId])
    end
    SvargrondArena.timerEvents[pitId] = addEvent(SvargrondArena.removeTimer, SvargrondArena.kickTime * 1000, pitId)
end ----- LINE 309

:mad:
 
Back
Top