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

Lua TFS [1.2] Why does this error happen in the distro?

Shiris undrin

Intermediate OT User
Joined
Jun 10, 2010
Messages
113
Solutions
1
Reaction score
100
Why does this error happen in the distro? When I finish the arena quest in svargrond last final portal to get to the reward room, that's when the error appears in the distro, it doesn't affect the quest at all, apparently, but I wanted to fix it and I couldn't find any way, because when I modify something in the arenaPit.lua:59 line it influences the quest and causes a larger error.

Erro:
data/movements/scripts/quests/svargrond arena/arenaPit.lua:59: in function <data/movements/scripts/quests/svargrond arena/arenaPit.lua:5>

arenaPit.lua:
Lua:
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)
        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
 

Attachments

Solution
I managed to find the solution, and error happens due to the way the lines were written and with the wrong spacing and also some lines missing. I tested several servers [1.2] with the quest arena of svargrond and there is this small error, I also found several unsolved topics, the solution is:

Lua:
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)...
In your in-game screenshot, you aren't getting the reward text..

So my guess is that this line
if pitId > 10 then
should be
if pitId >= 10 then

But without the rest of the code, it's impossible to know.

change this
Lua:
    SvargrondArena.cancelEvents(playerId)
    SvargrondArena.resetPit(pitId)
    SvargrondArena.scheduleKickPlayer(playerId, pitId)
    Game.createMonster(ARENA[arenaId].creatures[pitId], PITS[pitId].summon, false, true)
to
Lua:
    print("pitId = " .. pitId)
    print("arenaId = " .. arenaId)
    SvargrondArena.cancelEvents(playerId)
    SvargrondArena.resetPit(pitId)
    SvargrondArena.scheduleKickPlayer(playerId, pitId)
    Game.createMonster(ARENA[arenaId].creatures[pitId], PITS[pitId].summon, false, true)

and change
Lua:
if pitId > 10 then
to
Lua:
if pitId > 10 then
    print("Player completed the arena.")

If it's working as expected, it should print
Code:
pitId = 1
arenaId = (1, 2 or 3) -- greenhorn = 1, scrapper = 2, warlord = 3
pitId = 2
arenaId = 1
pitId = 3
arenaId = 1
pitId = 4
arenaId = 1
pitId = 5
arenaId = 1
pitId = 6
arenaId = 1
pitId = 7
arenaId = 1
pitId = 8
arenaId = 1
pitId = 9
arenaId = 1
pitId = 10
arenaId = 1
Player completed the arena.
 
The quest is working normally, the message also appears perfectly at the end of the quest... it bothers me badly for no reason that erro appears in the distro. As you can see in the image and the error still kept popping up. Please tell me if I need to post any other action or lib scripts.
 

Attachments

The quest is working normally, the message also appears perfectly at the end of the quest... it bothers me badly for no reason that erro appears in the distro. As you can see in the image and the error still kept popping up. Please tell me if I need to post any other action or lib scripts.
It looks like the script is being triggered twice each time?
That's very strange.

I can't even imagine what's going on to make it trigger twice..
The first print is also strange to me.. because why would it start at pitId 2 instead of 1?

Even stranger.. is why/how the arenaId would increase by 1?
The only logical reason I can think of, is that the quest was modified to work without an npc, and it is more 'automatic'.
But that would mean it's impossible to do the quest multiple times... which is normally what happens..
Normally you can do each arena as many times as you want, but you can only get the reward once. 🤷‍♂️

--
Anyways, it boils down to something extremely weird going on.
And honestly I'm not even sure where to start looking.
I can't say I've ever seen an onStepIn script trigger twice before.

Okay real question..
Does two bosses spawn in each pit?

Like I feel this is something that is definitely happening... but I don't understand why you wouldn't mention that..
And if there isn't two bosses summoning.. I would be beyond confused..

--
Alright, let's assume somehow that 2 bosses are not summoning..

Ugh. lmao
This is the jankiest bandaid solution..

It'll get rid of the error.. but it wouldn't fix the double triggering of the script.

That's the best I can offer.

Change
Lua:
    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
to
Lua:
    if PITS[pitId] and ARENA[arenaId] then
        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)
    end
    return true
 
I managed to find the solution, and error happens due to the way the lines were written and with the wrong spacing and also some lines missing. I tested several servers [1.2] with the quest arena of svargrond and there is this small error, I also found several unsolved topics, the solution is:

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

    if PITS[pitId] and ARENA[arenaId] then
            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)
    end
end
 
Last edited:
Solution
This is the jankiest bandaid solution..

It'll get rid of the error.. but it wouldn't fix the double triggering of the script.

Change
Lua:
    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
to
Lua:
    if PITS[pitId] and ARENA[arenaId] then
        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)
    end
    return true
I managed to find the solution, and error happens due to the way the lines were written and with the wrong spacing and also some lines missing. I tested several servers [1.2] with the quest arena of svargrond and there is this small error, I also found several unsolved topics, the solution is:

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

    if PITS[pitId] and ARENA[arenaId] then
            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
end
As I told you a few days ago, this doesn't fix the fundamental issue of the script somehow triggering twice, but it would get rid of the error.

It doesn't technically matter.. but the return true should be outside of the final if statement.
 
As I told you a few days ago, this doesn't fix the fundamental issue of the script somehow triggering twice, but it would get rid of the error.

It doesn't technically matter.. but the return true should be outside of the final if statement.
But that's no problem, I tested several servers scripts using the print code and it's all duplicated, it doesn't affect the mission at all because the player can do the 3 parts of the mission only once and get the rewards once, the problem was an error in the arenaPit.lua script that was spelled wrong and caused the error " arenaPit.lua: 59: in function " just flooding the server distro and that was very annoying but now everything is correct.

@Xikini Thanks for giving me a light to fix this error.
 
Last edited:
Back
Top