• 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 Svargrond arena [TFS 1.0]

arthuraio

Member
Joined
Apr 9, 2015
Messages
123
Reaction score
13
I'm using the global project 10.76/10.77 server

I have an annoying problem with this arena, wasted my whole saturday trying to fix it to not avail.

here is the thing, everything goes fine from talking to the NPC to entering the first teleport. NOW that we are in the first pit, the "frostfur" is summoned, after killing it, nothing happens.... Yeah that's it, nothing. Forcing you to cancel the arena leaving through the "give up" teleport and be turned into a chicken.

The blue pillar should be turned into the teleport to the next room, but as I said, nothing happens. everything is fine at the .XML part, I think something is wrong with this script in particular... I can't really understand it, i hate when people write a script like that with alot of locals. Makes it unreadable for me. Anyone with more experience is able to help me...?

Code:
function onKill(cid, target)
    local targetMonster = Monster(target)
    if not targetMonster then
        return
    end

    local player = Player(cid)
    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

REP++
 
Last edited:
I'm not really sure but it seems like the storage values are not set after the kill.
You could try to replace line #7 with this:

Code:
local player = Player(cid)

to

local player = cid:getPlayer()
 
Thanks for the reply, but no. Still the same problem. I will put every script related to this arena, maybe you or someone else are able to find something.

Actions: Arena Door

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if player:getStorageValue(Storage.SvargrondArena.Arena) < 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'This door seems to be sealed against unwanted intruders.')
        return true
    end

    -- Doors to rewards
    if isInArray({SvargrondArena.actionGreenhorn, SvargrondArena.actionScrapper, SvargrondArena.actionWarlord}, item.actionid) then
        if player:getStorageValue(item.actionid) <= 0 then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'It\'s locked.')
            return true
        end

        -- Cannot use opened door
        if item.itemid == 5133 then
            return false
        end
        Item(item.uid):transform(item.itemid + 1)
        player:teleportTo(toPosition, true)

    -- Arena entrance doors
    else
        if player:getStorageValue(Storage.SvargrondArena.Pit) ~= 1 then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'This door seems to be sealed against unwanted intruders.')
            return true
        end

        -- Cannot use opened door
        if item.itemid == 5133 then
            return false
        end
        Item(item.uid):transform(item.itemid + 1)
        player:teleportTo(toPosition, true)
    end

    return true
end

Actions: Arena Reward

Code:
dofile('data/lib/svargrondArenaQuest.lua')
local STORAGE_ARENA = 1100
function onUse(cid, item, fromPosition, itemEx, toPosition)

    if(getPlayerStorageValue(cid, STORAGE_ARENA) < 0) then
        return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Nothing here.")
    end
   
    for i = 1 , 3 do
        local arena = getPlayerStorageValue(cid, STORAGE_ARENA) - i
        if ARENA[arena].reward[item.uid] then
            local reward = ARENA[arena].reward[item.uid]
            if getPlayerStorageValue(cid, ARENA[arena].reward.storage) > 0 then
                return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It's empty.")
            end
    
            if reward.container then
                local cont = doPlayerAddItem(cid, reward.id, 1)
                for i = 1, table.maxn(reward.inside) do
                    doAddContainerItem(cont, reward.inside[i][1], reward.inside[i][2])
                end
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found " .. getItemName(reward.id) .. ".")
                setPlayerStorageValue(cid, ARENA[arena].reward.storage, 1)
                doPlayerAddExp(cid, 5000, true, true)
                return true
            else
                doPlayerAddItem(cid, reward.id[1], reward.id[2])
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found " .. (reward.id[2] < 2 and "x" .. reward.id[2]) .. " " .. getItemName(reward.id[1]) .. ".")
                setPlayerStorageValue(cid, ARENA[arena].reward.storage, 1)
                doPlayerAddExp(cid, 5000, true, true)
                return true
            end
        end
    end
    return true
end

Movements: Arena Enter

Code:
function onStepIn(cid, item, position, fromPosition)
    local player = Player(cid)
    if not player then
        return true
    end

    local pitId = player:getStorageValue(Storage.SvargrondArena.Pit)
    if pitId < 1 or pitId > 10 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You cannot enter without Halvar\'s permission.')
        player:teleportTo(fromPosition)
        return true
    end

    local arenaId = player:getStorageValue(Storage.SvargrondArena.Arena)
    if not(PITS[pitId] and ARENA[arenaId]) then
        player:teleportTo(fromPosition)
        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() == 0 and 's' or '') .. 'he is done fighting.')
        player:teleportTo(fromPosition)
        return true
    end

    SvargrondArena.resetPit(pitId)
    SvargrondArena.scheduleKickPlayer(cid, 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
 
Movements: ArenaPit

Code:
local condition = Condition(CONDITION_OUTFIT, CONDITIONID_COMBAT)
condition:setTicks(120000)
condition:addOutfit({lookType = 111})

function onStepIn(cid, item, position, fromPosition)
    local player = Player(cid)
    if not player then
        return true
    end

    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(cid)
        return true
    end

    local pitId = player:getStorageValue(Storage.SvargrondArena.Pit)
    local arenaId = player:getStorageValue(Storage.SvargrondArena.Arena)
    if pitId > 10 then
        SvargrondArena.rewardPosition:sendMagicEffect(arenaId == 1 and CONST_ME_FIREWORK_BLUE or arenaId == 2 and CONST_ME_FIREWORK_YELLOW or CONST_ME_FIREWORK_RED)
        player:teleportTo(SvargrondArena.rewardPosition)
        player:setStorageValue(Storage.SvargrondArena.Pit, 0)
        player:setStorageValue(SvargrondArena.getActionIdByArena(arenaId), 1)
        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:say(arenaId == 1 and 'Welcome back, little hero!' or arenaId == 2 and 'Congratulations, brave warrior!' or 'Respect and honour to you, champion!', TALKTYPE_MONSTER_SAY)
        player:setStorageValue(ARENA[arenaId].questLog, 2)
        player:addAchievement(ARENA[arenaId].achievement)
        SvargrondArena.cancelEvents(cid)
        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() == 0 and 's' or '') .. 'he is done fighting.')
        player:teleportTo(fromPosition, true)
        return true
    end

    SvargrondArena.cancelEvents(cid)
    SvargrondArena.resetPit(pitId)
    SvargrondArena.scheduleKickPlayer(cid, 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

movements: arenaTrophy

Code:
function onStepIn(cid, item, position, fromPosition)
    local player = Player(cid)
    if not player then
        return true
    end

    --trophy tile actionid should be 23201 23202 23203
    local arenaId = player:getStorageValue(Storage.SvargrondArena.Arena) - 1
    if arenaId == item.uid - 23200 and player:getStorageValue(ARENA[arenaId].reward.trophyStorage) < 1 then
        local rewardPosition = player:getPosition()
        rewardPosition.y = rewardPosition.y - 1

        local rewardItem = Game.createItem(ARENA[arenaId].reward.trophy, 1, rewardPosition)
        if rewardItem then
            rewardItem:setDescription(string.format(ARENA[arenaId].reward.desc, player:getName()))
        end

        player:setStorageValue(ARENA[arenaId].reward.trophyStorage, 1)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
    end
    return true
end
 
lib: svargrondArenaQuest

Code:
--[[
    TODO
        - Include PITS and ARENA table in SvargrondArena -> SvargrondArena.arenas / SvargrondArena.pits
        - Restructure PITS and ARENA table (reward.storage does not seem to be used)
]]

SvargrondArena = {
    -- action ids have to be equal to action id of reward doors
    actionGreenhorn = 26100,
    actionScrapper = 27100,
    actionWarlord = 28100,

    -- kick time in seconds (10 minutes)
    kickTime = 600,
    kickPosition = Position(32251, 31098, 6),
    rewardPosition = Position(32222, 31080, 6),

    -- used to store event ids
    kickEvents = {},
    timerEvents = {},
    effectPositionCache = {},

    -- item ids used by the script
    itemTimer = 10288,
    itemPillar = 1354,
    itemTeleport = 5023,
    itemsNotErasable = {10288, 1354, 1543, 1544, 1545},
}

-- Script automatically derives other pit positions from this one
local firstPit = {
    fromPos = {x = 32205, y = 31094, z = 7},
    toPos = {x = 32214, y = 31103, z = 7},
    center = {x = 32210, y = 31098, z = 7},
    pillar = {x = 32204, y = 31098, z = 7},
    tp = {x = 32204, y = 31098, z = 7},
    summon = {x = 32210, y = 31100, z = 7}
}

PITS = {
    [1] = {
        fromPos = firstPit.fromPos,
        toPos = firstPit.toPos,
        center = firstPit.center,
        pillar = firstPit.pillar,
        tp = firstPit.tp,
        summon = firstPit.summon
    },
    [2] = {
        fromPos = {x = firstPit.fromPos.x - 14, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 14, y = firstPit.toPos.y, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 14, y = firstPit.center.y, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 14, y = firstPit.pillar.y, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 14, y = firstPit.tp.y, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 14, y = firstPit.summon.y, z = firstPit.summon.z}
    },
    [3] = {
        fromPos = {x = firstPit.fromPos.x - 28, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 28, y = firstPit.toPos.y, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 28, y = firstPit.center.y, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 28, y = firstPit.pillar.y, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 28, y = firstPit.tp.y, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 28, y = firstPit.summon.y, z = firstPit.summon.z}
    },
    [4] = {
        fromPos = {x = firstPit.fromPos.x - 42, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 42, y = firstPit.toPos.y, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 42, y = firstPit.center.y, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 42, y = firstPit.pillar.y, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 42, y = firstPit.tp.y, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 42, y = firstPit.summon.y, z = firstPit.summon.z}
    },
    [5] = {
        fromPos = {x = firstPit.fromPos.x - 35, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 35, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 35, y = firstPit.center.y - 14, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 35, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 35, y = firstPit.tp.y - 14, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 35, y = firstPit.summon.y - 14, z = firstPit.summon.z}
    },
    [6] = {
        fromPos = {x = firstPit.fromPos.x - 21, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 21, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 21, y = firstPit.center.y - 14, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 21, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 21, y = firstPit.tp.y - 14, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 21, y = firstPit.summon.y - 14, z = firstPit.summon.z}
    },
    [7] = {
        fromPos = {x = firstPit.fromPos.x - 7, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 7, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 7, y = firstPit.center.y - 14, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 7, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 7, y = firstPit.tp.y - 14, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 7, y = firstPit.summon.y - 14, z = firstPit.summon.z}
    },
    [8] = {
        fromPos = {x = firstPit.fromPos.x - 14, y = firstPit.fromPos.y - 28, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 14, y = firstPit.toPos.y - 28, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 14, y = firstPit.center.y - 28, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 14, y = firstPit.pillar.y - 28, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 14, y = firstPit.tp.y - 28, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 14, y = firstPit.summon.y - 28, z = firstPit.summon.z}
    },
    [9] = {
        fromPos = {x = firstPit.fromPos.x - 28, y = firstPit.fromPos.y - 28, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 28, y = firstPit.toPos.y - 28, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 28, y = firstPit.center.y - 28, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 28, y = firstPit.pillar.y - 28, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 28, y = firstPit.tp.y - 28, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 28, y = firstPit.summon.y - 28, z = firstPit.summon.z}
    },
    [10] = {
        fromPos = {x = firstPit.fromPos.x - 21, y = firstPit.fromPos.y - 42, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 21, y = firstPit.toPos.y - 42, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 21, y = firstPit.center.y - 41, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 21, y = firstPit.pillar.y - 41, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 21, y = firstPit.tp.y - 41, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 21, y = firstPit.summon.y - 41, z = firstPit.summon.z}
    }
}

ARENA = {
    [1] = {
        name = 'Greenhorn',
        price = 1000,
        questLog = 50140,
        achievement = 'Greenhorn',
        creatures = {
            [1] = 'Frostfur',
            [2] = 'bloodpaw',
            [3] = 'bovinus',
            [4] = 'achad',
            [5] = 'colerian the barbarian',
            [6] = 'the hairy one',
            [7] = 'axeitus headbanger',
            [8] = 'rocky',
            [9] = 'cursed gladiator',
            [10] = 'orcus the cruel'
        },
        reward = {
            storage = 1102,
            trophy = 5807,
            trophyStorage = 1103,
            desc = 'A brave warrior that finished the Greenhorn mode. Awarded to %s.',
            [26300] = {
                container = true,
                id = 1990,
                inside = {
                    {2114, 1},
                    {9570, 1},
                    {6574, 1},
                    {2688, 10},
                    {7372, 1}
                }
            },
            [26400] = {
                container = true,
                id = 7342,
                inside = {
                    {7364, 100},
                    {7365, 100}
                },
            },
            [26500] = {
                id = {7406, 1}
            },
            [26600] = {
                id = {7380, 1}
            },
            [26700] = {
                id = {7392, 1}
            }
        }
    },
    [2] = {
        name = 'Scrapper',
        price = 5000,
        questLog = 50141,
        achievement = 'Scrapper',
        creatures = {
            [1] = 'avalanche',
            [2] = 'kreebosh the exile',
            [3] = 'the dark dancer',
            [4] = 'the hag',
            [5] = 'slim',
            [6] = 'grimgor guteater',
            [7] = 'drasilla',
            [8] = 'spirit of earth',
            [9] = 'spirit of water',
            [10] = 'spirit of fire'
 
lib: svargrondArenaQuest

Code:
        },
        reward = {
            storage = 1104,
            trophy = 5806,
            trophyStorage = 1105,
            desc = 'A brave warrior that finished the Scrapper mode. Awarded to %s.',
            [27300] = {
                container = true,
                id = 1990,
                inside = {
                    {7183, 1},
                    {6574, 1},
                    {7373, 1},
                    {2688, 10}
                }
            },
            [27400] = {
                container = true,
                id = 7342,
                inside = {
                    {2304, 50},
                    {2311, 50},
                    {2547, 200},
                    {7365, 100}
                },
            },
            [27500] = {
                id = {7384, 1}
            },
            [27600] = {
                id = {7389, 1}
            },
            [27700] = {
                id = {7415, 1}
            }
        }
    },
    [3] = {
        name = 'Warlord',
        price = 10000,
        questLog = 50142,
        achievement = 'Warlord of Svargrond',
        creatures = {
            [1] = 'webster',
            [2] = 'darakan the executioner',
            [3] = 'norgle glacierbeard',
            [4] = 'the pit lord',
            [5] = 'svoren the mad',
            [6] = 'the masked marauder',
            [7] = 'gnorre chyllson',
            [8] = 'fallen mooh\'tah master ghar',
            [9] = 'deathbringer',
            [10] = 'the obliverator'
        },
        reward = {
            storage = 1006,
            trophy = 5805,
            trophyStorage = 1007,
            desc = 'A brave warrior that finished the Warlord mode. Awarded to %s.',
            [28300] = {
                container = true,
                id = 1990,
                inside = {
                    {6568, 1},
                    {6574, 1},
                    {7374, 1},
                    {2688, 10}
                }
            },
            [28400] = {
                container = true,
                id = 7342,
                inside = {
                    {6529, 100},
                    {7440, 1},
                    {7443, 1},
                    {2268, 50},
                    {2273, 50}
                },
            },
            [28500] = {
                id = {7390, 1}
            },
            [28600] = {
                id = {7434, 1}
            },
            [28700] = {
                id = {7429, 1}
            }
        }
    }
}

function SvargrondArena.getActionIdByArena(arenaId)
    if arenaId == 1 then
        return SvargrondArena.actionGreenhorn
    elseif arenaId == 2 then
        return SvargrondArena.actionScrapper
    elseif arenaId == 3 then
        return SvargrondArena.actionWarlord
    else
        print('SvargronArena::getActionIdByArena invalid arenaId')
    end
end

function SvargrondArena.getPitCreatures(pitId)
    if not PITS[pitId] then
        return {}
    end

    local ret = {}
    local specs = Game.getSpectators(PITS[pitId].center, false, false, 5, 5, 5, 5)
    for i = 1, #specs do
        ret[#ret+1] = specs[i]
    end

    return ret
end

function SvargrondArena.resetPit(pitId)
    if not PITS[pitId] then
        return
    end

    for x = PITS[pitId].fromPos.x, PITS[pitId].toPos.x do
        for y = PITS[pitId].fromPos.y, PITS[pitId].toPos.y do
            for z = PITS[pitId].fromPos.z, PITS[pitId].toPos.z do
                local tile = Tile({x=x, y=y, z=z})
                if tile then
                    local moveableItem = tile:getThing(STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE)
                    if moveableItem and moveableItem:isItem() then
                        local itemType = ItemType(moveableItem:getId())
                        if itemType and itemType:isMovable() and not isInArray(SvargrondArena.itemsNotErasable, moveableItem:getId()) then
                            moveableItem:remove()
                        end
                    end

                    local creature = tile:getTopCreature()
                    if creature and creature:isMonster() then
                        creature:remove()
                    end
                end
            end
        end
    end

    local pillarTile = Tile(PITS[pitId].pillar)
    if pillarTile then
        local teleportItem = pillarTile:getItemById(SvargrondArena.itemTeleport)
        if teleportItem then
            teleportItem:remove()
        end

        local pillarItem = pillarTile:getItemById(SvargrondArena.itemPillar)
        if not pillarItem then
            Game.createItem(SvargrondArena.itemPillar, 1, PITS[pitId].pillar)
        end
    end
end

function SvargrondArena.getPitOccupant(pitId, ignorePlayer)
    local creatures = SvargrondArena.getPitCreatures(pitId)
    for i = 1, #creatures do
        if creatures[i]:isPlayer() and creatures[i]:getId() ~= ignorePlayer:getId() then
            return creatures[i]
        end
    end

    return nil
end

function SvargrondArena.kickPlayer(cid, hideMessage)
    SvargrondArena.cancelEvents(cid)
    local player = Player(cid)
    if not player then
        return
    end

    if player:getStorageValue(Storage.SvargrondArena.Pit) > 0 then
        player:teleportTo(SvargrondArena.kickPosition)
        SvargrondArena.kickPosition:sendMagicEffect(CONST_ME_TELEPORT)
        player:setStorageValue(Storage.SvargrondArena.Pit, 0)
        if not hideMessage then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Your time ran out!')
        end
    end
end

function SvargrondArena.cancelEvents(cid)
    local kickEvent = SvargrondArena.kickEvents[cid]
    if kickEvent then
        SvargrondArena.removeTimer(kickEvent.pitId)
        stopEvent(kickEvent.eventId)
    end
    SvargrondArena.kickEvents[cid] = nil
end

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

function SvargrondArena.removeTimer(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
    SvargrondArena.timerEvents[pitId] = nil
end

function SvargrondArena.sendPillarEffect(pitId)
    local positions = SvargrondArena.effectPositionCache[pitId]
    if not positions then
        local position = PITS[pitId].pillar
        local effectPositions = {
                Position(position.x - 1, position.y,     position.z),
                Position(position.x + 1, position.y,     position.z),
                Position(position.x + 1, position.y - 1, position.z),
                Position(position.x + 1, position.y + 1, position.z),
                Position(position.x,     position.y,     position.z)
        }
        SvargrondArena.effectPositionCache[pitId] = effectPositions
        positions = effectPositions
    end

    for _, position in ipairs(positions) do
        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    end
end
 
The problem about updating to TFS 1.1 is that my compiled distro get 1 million of errors of missing content and there is people using TFS 0.2, THAT is OLD! xD
 
Add those print statements, you'll see where it's stopping and then you can figure out why.
Code:
function onKill(cid, target)
local targetMonster = Monster(target)
if not targetMonster then
return
end

local player = Player(cid)
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
print("Test 1") --------------------------
-- Remove pillar and create teleport
local pillarTile = Tile(PITS[pit].pillar)
if pillarTile then
print("Test 2")------------------------
local pillarItem = pillarTile:getItemById(SvargrondArena.itemPillar)
if pillarItem then
print("Test 3")---------------------------
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
 
Back
Top