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

Windows Crash server [TFS 1.2]

Joined
Jul 18, 2014
Messages
193
Solutions
2
Reaction score
15
Hi, i created a new script for a quest, but the problem is when the players use the lever (the script that i made) after a few times, the server get crashed. Im not sure if it's because the script is so long and requires a lot of ram. It haves 269 lines, and im thinking a way to put it more short, maybe with a lib lua or something.

Can you help me please?
It's TFS 1.2 ^^
Thanks :)
 
Hi, i created a new script for a quest, but the problem is when the players use the lever (the script that i made) after a few times, the server get crashed. Im not sure if it's because the script is so long and requires a lot of ram. It haves 269 lines, and im thinking a way to put it more short, maybe with a lib lua or something.

Can you help me please?
It's TFS 1.2 ^^
Thanks :)

We can, but you need to post the script here.
 
We can, but you need to post the script here.
Here is it:
Code:
local storePlayers, playerTile = {}
local function startfirstwave()
    local m = 0
    repeat
        local posx = math.random(24823, 24864)
        local posy = math.random(24221, 24254)
        Game.createMonster("Demon", {x = posx, y = posy, z = 7})
        m = m + 1
    until m == 30
    return true
end

local function firstwave()
    for i = 1, #storePlayers do
        local players = storePlayers[i]
        players:sendTextMessage(TALKTYPE_ORANGE_1, "Starting First Wave...")
        Game.setStorageValue(4700, os.time()+10)
    end
    while os.time() < Game.getStorageValue(4700) do
        for a = 10, 0, -1 do
            for i = 1, #storePlayers do
                local players = storePlayers[i]
                players:sendTextMessage(TALKTYPE_MONSTER_SAY, "Wave starts in "..a)
            end
            if a == 0 then
                startfirstwave()
                Game.setStorageValue(4700, 30)
                for i = 1, #storePlayers do
                    local players = storePlayers[i]
                    players:sendTextMessage(TALKTYPE_MONSTER_YELL, Game.getStorageValue(4700).."/30 monsters left.")
                    players:setStorageValue(4700, 0)
                end
            end
        end
    end
    return true
end

local function startsecondwave()
    local m = 0
    repeat
        local posx = math.random(24823, 24864)
        local posy = math.random(24221, 24254)
        Game.createMonster("Orshabaal", {x = posx, y = posy, z = 7})
        m = m + 1
    until m == 15
    return true
end

local function secondwave()
    for i = 1, #storePlayers do
        local players = storePlayers[i]
        players:sendTextMessage(TALKTYPE_ORANGE_1, "Starting Second Wave...")
        Game.setStorageValue(4700, os.time()+10)
    end
    while os.time() < Game.getStorageValue(4700) do
        for a = 10, 0, -1 do
            for i = 1, #storePlayers do
                local players = storePlayers[i]
                players:sendTextMessage(TALKTYPE_MONSTER_SAY, "Wave starts in "..a)
            end
            if a == 0 then
                startsecondwave()
                Game.setStorageValue(4700, 15)
                for i = 1, #storePlayers do
                    local players = storePlayers[i]
                    players:sendTextMessage(TALKTYPE_MONSTER_YELL, Game.getStorageValue(4700).."/15 monsters left.")
                    players:setStorageValue(4700, 1)
                end
            end
        end
    end
    return true
end

local function startthirdwave()
    local m = 0
    repeat
        local posx = math.random(24823, 24864)
        local posy = math.random(24221, 24254)
        Game.createMonster("Morgaroth", {x = posx, y = posy, z = 7})
        m = m + 1
    until m == 10
    return true
end

local function thirdwave()
    for i = 1, #storePlayers do
        local players = storePlayers[i]
        players:sendTextMessage(TALKTYPE_ORANGE_1, "Starting Third Wave...")
        Game.setStorageValue(4700, os.time()+10)
    end
    while os.time() < Game.getStorageValue(4700) do
        for a = 10, 0, -1 do
            for i = 1, #storePlayers do
                local players = storePlayers[i]
                players:sendTextMessage(TALKTYPE_MONSTER_SAY, "Wave starts in "..a)
            end
            if a == 0 then
                startthirdwave()
                Game.setStorageValue(4700, 10)
                for i = 1, #storePlayers do
                    local players = storePlayers[i]
                    players:sendTextMessage(TALKTYPE_MONSTER_YELL, Game.getStorageValue(4700).."/10 monsters left.")
                    players:setStorageValue(4700, 2)
                end
            end
        end
    end
    return true
end

local function startfourthwave()
    local m = 0
    repeat
        local posx = math.random(24823, 24864)
        local posy = math.random(24221, 24254)
        Game.createMonster("Guardian of Skandinavia", {x = posx, y = posy, z = 7})
        m = m + 1
    until m == 5
    return true
end

local function fourthwave()
    for i = 1, #storePlayers do
        local players = storePlayers[i]
        players:sendTextMessage(TALKTYPE_ORANGE_1, "Starting Fourth Wave...")
        Game.setStorageValue(4700, os.time()+10)
    end
    while os.time() < Game.getStorageValue(4700) do
        for a = 10, 0, -1 do
            for i = 1, #storePlayers do
                local players = storePlayers[i]
                players:sendTextMessage(TALKTYPE_MONSTER_SAY, "Wave starts in "..a)
            end
            if a == 0 then
                startfourthwave()
                Game.setStorageValue(4700, 5)
                for i = 1, #storePlayers do
                    local players = storePlayers[i]
                    players:sendTextMessage(TALKTYPE_MONSTER_YELL, Game.getStorageValue(4700).."/5 monsters left.")
                    players:setStorageValue(4700, 3)
                end
            end
        end
    end
    return true
end

local function startfifthwave()
    local m = 0
    repeat
        local posx = math.random(24823, 24864)
        local posy = math.random(24221, 24254)
        Game.createMonster("Gaz'Haragoth", {x = posx, y = posy, z = 7})
        m = m + 1
    until m == 3
    return true
end

local function fifthwave()
    for i = 1, #storePlayers do
        local players = storePlayers[i]
        players:sendTextMessage(TALKTYPE_ORANGE_1, "Starting Fifth Wave...")
        Game.setStorageValue(4700, os.time()+10)
    end
    while os.time() < Game.getStorageValue(4700) do
        for a = 10, 0, -1 do
            for i = 1, #storePlayers do
                local players = storePlayers[i]
                players:sendTextMessage(TALKTYPE_MONSTER_SAY, "Wave starts in "..a)
            end
            if a == 0 then
                startfifthwave()
                Game.setStorageValue(4700, 3)
                for i = 1, #storePlayers do
                    local players = storePlayers[i]
                    players:sendTextMessage(TALKTYPE_MONSTER_YELL, Game.getStorageValue(4700).."/3 monsters left.")
                    players:setStorageValue(4700, 4)
                end
            end
        end
    end
    return true
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local playerPositions = {
    Position(24846, 24233, 7),
    Position(24847, 24233, 7),
    Position(24848, 24233, 7)
}
    for i = 1, #playerPositions do
        playerTile = Tile(playerPositions[i]):getTopCreature()
        storePlayers[#storePlayers + 1] = playerTile
    end

    if Game.getStorageValue(4700) > 0 then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "A wave is already running...")
    end
   
        if Game.getStorageValue(4700) <= 0 and Game.getStorageValue(4801) <= 0 and player:getStorageValue(4700) == -1 then
            firstwave()
        elseif Game.getStorageValue(4700) <= 0 and Game.getStorageValue(4801) <= 0 and player:getStorageValue(4700) == 0 then    
            for i = 1, #storePlayers do
                local players = storePlayers[i]
                if not playerTile or not playerTile:isPlayer() then
                    player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 3 players.")
                    return true
                end
                players:setStorageValue(4700, 1)
                Game.setStorageValue(4801, 1)
            end
           
            secondwave()
        elseif Game.getStorageValue(4700) <= 0 and Game.getStorageValue(4801) == 1 and player:getStorageValue(4700) == 1 then
            for i = 1, #storePlayers do
                local players = storePlayers[i]
                if not playerTile or not playerTile:isPlayer() then
                    player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 3 players.")
                    return true
                end
                players:setStorageValue(4700, 2)
                Game.setStorageValue(4801, 2)
            end
            thirdwave()
        elseif Game.getStorageValue(4700) <= 0 and Game.getStorageValue(4801) == 2 and player:getStorageValue(4700) == 2 then
            for i = 1, #storePlayers do
                local players = storePlayers[i]
                if not playerTile or not playerTile:isPlayer() then
                    player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 3 players.")
                    return true
                end
                players:setStorageValue(4700, 3)
                Game.setStorageValue(4801, 3)
            end
            fourthwave()
        elseif Game.getStorageValue(4700) <= 0 and Game.getStorageValue(4801) == 3 and player:getStorageValue(4700) == 3 then
            for i = 1, #storePlayers do
                local players = storePlayers[i]
                if not playerTile or not playerTile:isPlayer() then
                    player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 3 players.")
                    return true
                end
                players:setStorageValue(4700, 4)
                Game.setStorageValue(4801, 4)
            end
            fifthwave()
        elseif Game.getStorageValue(4700) <= 0 and Game.getStorageValue(4801) == 4 and player:getStorageValue(4700) == 4 then
            Game.setStorageValue(4801, 0)
            Game.setStorageValue(4800, os.time()+2400)
            for i = 1, #storePlayers do
                local players = storePlayers[i]
                players:setStorageValue(4700, 5)
                players:sendTextMessage(TALKTYPE_MONSTER_YELL, "Fifth Wave finished. Congratulations! You got DemonHunter Second Addon.")
                players:teleportTo(Position(32369, 32241, 7))
                players:addOutfitAddon(288, 2)
                players:addOutfitAddon(289, 2)
            end
        end
    return true
end

Do you have any error msg in console?
No, it works perfectly. The problem is only the number of lines in the script, because it requires more RAM and i don't have enough money to put it more.
 
Last edited by a moderator:
God damn Zoe!
That is a lot of code..

So basically you copy and pasted the same functions over and over, 2 unique functions and a table of values should cut it, this is just a brief glance. :p
 
God damn Zoe!
That is a lot of code..

So basically you copy and pasted the same functions over and over, 2 unique functions and a table of values should cut it, this is just a brief glance. :p

Hahaha, yes i did that, and i was thinking in that you said, but i got a little problem talking about tables. Let's imagine that i have this table:

Code:
local monsters = {
['demon'] = {number = 30},
['orshabaal'] = {number = 15}
}

So, i have to say:

Code:
repeat
local i = 0
Game.createMonster(monsters[WHAT THE HELL DO I HAVE TO PUT HERE?], monsters[again].number)
i = i + 1
until i = monsters[again].number
I could use the cycle 'for' too, but i made the example with repeat.
So, the problem is, what do i have to put in monsters[HERE] ?
Sometimes there should call a storage but i dont know how.
 
Hahaha, yes i did that, and i was thinking in that you said, but i got a little problem talking about tables. Let's imagine that i have this table:

Code:
local monsters = {
['demon'] = {number = 30},
['orshabaal'] = {number = 15}
}

So, i have to say:

Code:
repeat
local i = 0
Game.createMonster(monsters[WHAT THE HELL DO I HAVE TO PUT HERE?], monsters[again].number)
i = i + 1
until i = monsters[again].number
I could use the cycle 'for' too, but i made the example with repeat.
So, the problem is, what do i have to put in monsters[HERE] ?
Sometimes there should call a storage but i dont know how.
Edited for your sanity :p

Code:
function n(a)
    local x = {}
    for i, _ in pairs(a) do
        table.insert(x, i)
    end
    return x
end

Example
Code:
local monsters = {
['demon'] = {number = 30},
['orshabaal'] = {number = 15}
}

print( unpack( n(monsters) ) )
output
Code:
orshabaal    demon

one function down 1 to go
Code:
local function waves(name, amount, x, y)
    for i = 1, amount do
        Game.createMonster(name, {x = math.random(x.min, x.max), y = math.random(y.min, y.max), z = 7})
    end
end

Maybe 2 :p

Here we go
Code:
function waves(name, amount, x, y)
    for i = 1, amount do
        Game.createMonster(name, {x = math.random(x.min, x.max), y = math.random(y.min, y.max), z = 7})
    end
end

function startWaves(storage, name, amount x, y, text, value)
    local time_ = #storePlayers * 10
    Game.setStorageValue(storage, os.time() + time_)

    for i = 1, #storedPlayers do
        storePlayers[i]:sendTextMessage(TALKTYPE_ORANGE_1, text)
        addEvent(
            function(cid, n)
                local player = Player(cid)
                if player then
                    player:sendTextMessage(TALKTYPE_MONSTER_SAY, "Wave starts in " .. n)
                end
            end,
            i * 1000, storePlayers[i]:getId(), time_ - i
        )
        addEvent(
            function(cid)
                local player = Player(cid)
                if player then
                    waves(name, amount, x, y)
                    Game.setStorageValue(storage, amount)
                    player:sendTextMessage(TALKTYPE_MONSTER_YELL, Game.getStorageValue(storage).."/" .. amount .. " monsters left.")
                    players:setStorageValue(storage, value)
                end
            end,
            time_ * 1000, storePlayers[i]:getId()
        )
    end
end

See 2 functions :p
Of course it isn't the whole script.
 
Last edited by a moderator:
So now we have 1 table and 2 functions
Code:
local storage = 4700
local c = {
    [1] = {name = "Demon", text = "First", amount = 30, value = 0},
    [2] = {name = "Orshabaal", text = "Second", amount = 15, value = 1},
    [3] = {name = "Morgaroth", text = "Third", amount = 10, value = 2},
    [4] = {name = "Guardian of Skandinavia", text = "Fourth", amount = 5, value = 3},
    [5] = {name = "Gaz'Haragoth", text = "Fifth", amount = 3, value = 4},
    pos = {x = {min = 24823, max = 24864}, y = {min = 24221, max = 24254}}
}
function waves(name, amount, x, y)
    for i = 1, amount do
        Game.createMonster(name, {x = math.random(x.min, x.max), y = math.random(y.min, y.max), z = 7})
    end
end

function startWaves(storage, name, amount x, y, text, value)
    local time_ = #storePlayers * 10 
    Game.setStorageValue(storage, os.time() + time_)

    for i = 1, #storedPlayers do
        storePlayers[i]:sendTextMessage(TALKTYPE_ORANGE_1, "Starting " .. text .. " Wave...")
        addEvent(
            function(cid, n)
                local player = Player(cid)
                if player then
                    player:sendTextMessage(TALKTYPE_MONSTER_SAY, "Wave starts in " .. n)
                end
            end,
            i * 1000, storePlayers[i]:getId(), time_ - i
        )
        addEvent(
            function(cid)
                local player = Player(cid)
                if player then
                    waves(name, amount, x, y)
                    Game.setStorageValue(storage, amount)
                    player:sendTextMessage(TALKTYPE_MONSTER_YELL, Game.getStorageValue(storage).."/" .. amount .. " monsters left.")
                    players:setStorageValue(storage, value)
                end
            end,
            time_ * 1000, storePlayers[i]:getId()
        )
    end
end
 
Last edited:
So now we have 1 table and 2 functions
Code:
local storage = 4700
local c = {
    [1] = {name = "Demon", text = "First", amount = 30, value = 0},
    [2] = {name = "Orshabaal", text = "Second", amount = 15, value = 1},
    [3] = {name = "Morgaroth", text = "Third", amount = 10, value = 2},
    [4] = {name = "Guardian of Skandinavia", text = "Fourth", amount = 5, value = 3},
    [5] = {name = "Gaz'Haragoth", text = "Fifth", amount = 3, value = 4},
    pos = {x = {min = 24823, max = 24864}, y = {min = 24221, max = 24254}}
}
function waves(name, amount, x, y)
    for i = 1, amount do
        Game.createMonster(name, {x = math.random(x.min, x.max), y = math.random(y.min, y.max), z = 7})
    end
end

function startWaves(storage, name, amount x, y, text, value)
    local time_ = #storePlayers * 10
    Game.setStorageValue(storage, os.time() + time_)

    for i = 1, #storedPlayers do
        storePlayers[i]:sendTextMessage(TALKTYPE_ORANGE_1, "Starting " .. text .. " Wave...")
        addEvent(
            function(cid, n)
                local player = Player(cid)
                if player then
                    player:sendTextMessage(TALKTYPE_MONSTER_SAY, "Wave starts in " .. n)
                end
            end,
            i * 1000, storePlayers[i]:getId(), time_ - i
        )
        addEvent(
            function(cid)
                local player = Player(cid)
                if player then
                    waves(name, amount, x, y)
                    Game.setStorageValue(storage, amount)
                    player:sendTextMessage(TALKTYPE_MONSTER_YELL, Game.getStorageValue(storage).."/" .. amount .. " monsters left.")
                    players:setStorageValue(storage, value)
                end
            end,
            time_ * 1000, storePlayers[i]:getId()
        )
    end
end

OMFG, Someone has called you "god"? You're awesome!, but you forgot add the reward when the fifth wave finish. And you forgot add the function onUse too haha. By the way, can you tell me, in cycle "for" what's the difference between:

Code:
for i_, in pairs(a) do
-------
end

And

Code:
for i,_ ipairs(a) do
------
end
??. For what is the "pairs" and the "ipairs" ?
 
OMFG, Someone has called you "god"? You're awesome!, but you forgot add the reward when the fifth wave finish. And you forgot add the function onUse too haha. By the way, can you tell me, in cycle "for" what's the difference between:

Code:
for i_, in pairs(a) do
-------
end

And

Code:
for i,_ ipairs(a) do
------
end
??. For what is the "pairs" and the "ipairs" ?
Yes, I know I left out the onUse, I was just waiting for the Lǎoshī to come in and correct my work, but really I was just tired and was kind of hoping you would see the direction I was headed and would finish the script yourself. :p

The difference between pairs and ipairs is pairs will iterate over everything in the table regardless if it has a numerical key/index or not in no particular order, however it will skip similar indexes.

Where as ipairs will only iterate through a table if the table has keys that are numerical (explicitly defined or not), however its is limited to the bounds or length of the table, and will skip similar indexes as well.

This is why I recommend everyone serious about learning to code, test their code in a lua interpreter 1st before trying to load it up on the server, of course the functions which exist for tfs will not work with raw lua, but that does not mean you can't write similar or basic functionality.

There are many resources on the web to test your work or just little tid bits of code, don't let the know it all mods or high profile programmers fool you, constantly testing the little things is what helps you make great bigger things. :)
 
Yes, I know I left out the onUse, I was just waiting for the Lǎoshī to come in and correct my work, but really I was just tired and was kind of hoping you would see the direction I was headed and would finish the script yourself. :p

The difference between pairs and ipairs is pairs will iterate over everything in the table regardless if it has a numerical key/index or not in no particular order, however it will skip similar indexes.

Where as ipairs will only iterate through a table if the table has keys that are numerical (explicitly defined or not), however its is limited to the bounds or length of the table, and will skip similar indexes as well.

This is why I recommend everyone serious about learning to code, test their code in a lua interpreter 1st before trying to load it up on the server, of course the functions which exist for tfs will not work with raw lua, but that does not mean you can't write similar or basic functionality.

There are many resources on the web to test your work or just little tid bits of code, don't let the know it all mods or high profile programmers fool you, constantly testing the little things is what helps you make great bigger things. :)

Thanks for the info^^ I tried to reduce the code by myself but i have a little problem, i dont know if you can help me:
Code:
local storePlayers, playerTile = {}
local counter = 0
local function nwave()
local nextwave = {
    [1] = {st4700 = -1, st4801 = -1, nextst4801 = 1, nextstplayer4700 = 0, stplayer4700 = -1, monster = "Demon", monstercount = 3, nextp = 2},
    [2] = {st4700 = 0, st4801 = 1, nextst4801 = 2, nextstplayer4700 = 1, stplayer4700 = 1, monster = "Orshabaal", monstercount = 15, nextp = 3},
    [3] = {st4700 = 0, st4801 = 2, nextst4801 = 3, nextstplayer4700 = 2, stplayer4700 = 2, monster = "Morgaroth", monstercount = 10, nextp = 4},
    [4] = {st4700 = 0, st4801 = 3, nextst4801 = 4, nextstplayer4700 = 3, stplayer4700 = 3, monster = "Guardian of Skandinavia", monstercount = 5, nextp = 5},
    [5] = {st4700 = 0, st4801 = 4, nextst4801 = 5, nextstplayer4700 = 4, stplayer4700 = 4, monster = "Gaz'Haragoth", monstercount = 3, nextp = 0}
}
    print("Fase 5")
        print("Fase 6")
        print(Game.getStorageValue(4801))
        for p = 1, #nextwave do
            local nzxt = nextwave[p]
            print("Fase 7")
            print(nzxt.st4801)
        if Game.getStorageValue(4801) ~= counter then
            print(p.." This one dos")
            print(Game.getStorageValue(4801).." Second one dos")
            print(nzxt.st4801.." Third One dos")
            return true           
        else
            print("Fase 8")
                for m = 1, nzxt.monstercount do
                    local posx = math.random(24823, 24864)
                    local posy = math.random(24221, 24254)
                    Game.createMonster(nzxt.monster, {x = posx, y = posy, z = 7})
                end
                print("Wave off")
                print(Game.getStorageValue(4801))
                Game.setStorageValue(4700, nzxt.monstercount)
                Game.setStorageValue(5000, nzxt.nextp)
                for i = 1, #storePlayers do
                    local players = storePlayers[i]
                    players:sendTextMessage(TALKTYPE_MONSTER_YELL, Game.getStorageValue(4700).."/"..nzxt.monstercount.." monsters left.")
                    players:setStorageValue(4700, nzxt.nextstplayer4700)
                end
            return true
        end
        end
    return true
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
print("START")
print(Game.getStorageValue(4801).." :Storage 4801")
local nextwave = {
    [1] = {st4700 = -1, st4801 = -1, nextst4801 = 1, nextstplayer4700 = 0, stplayer4700 = -1, monster = "Demon", monstercount = 30, nextp = 2},
    [2] = {st4700 = 0, st4801 = 1, nextst4801 = 2, nextstplayer4700 = 1, stplayer4700 = 1, monster = "Orshabaal", monstercount = 15, nextp = 3},
    [3] = {st4700 = 0, st4801 = 2, nextst4801 = 3, nextstplayer4700 = 2, stplayer4700 = 2, monster = "Morgaroth", monstercount = 10, nextp = 4},
    [4] = {st4700 = 0, st4801 = 3, nextst4801 = 4, nextstplayer4700 = 3, stplayer4700 = 3, monster = "Guardian of Skandinavia", monstercount = 5, nextp = 5},
    [5] = {st4700 = 0, st4801 = 4, nextst4801 = 5, nextstplayer4700 = 4, stplayer4700 = 4, monster = "Gaz'Haragoth", monstercount = 3, nextp = 0}
}


local playerPositions = {
    Position(24846, 24233, 7),
    Position(24847, 24233, 7),
    Position(24848, 24233, 7)
}
    for i = 1, #playerPositions do
        playerTile = Tile(playerPositions[i]):getTopCreature()
        storePlayers[#storePlayers + 1] = playerTile
    end
    if Game.getStorageValue(4700) > 0 then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "A wave is already running...")
    end
    print("Fase 2")
    print(p)
    for p = 1, #nextwave do
        local nzxt = nextwave[p]
        print("Fase 2/3")
        if Game.getStorageValue(4801) ~= nzxt.st4801 then
            player:sendTextMessage(TALKTYPE_MONSTER_YELL, "Nulled")
            print(p.." This one")
            print(Game.getStorageValue(4801).." Second one")
            print(nzxt.st4801.." Third One")
            repeat
                if nzxt.st4801 ~= Game.getStorageValue(4801) then
                    print("Entering Changing P")
                    print(p)
                    print(nzxt.st4801.." Actual 4801")
                    nzxt = #nextwave + 1
                    print("P changed")
                    print(p)
                    print(nzxt)
                    print(nzxt.st4801.." Actual 2 4801")
                    if Game.getStorageValue(4801) == nzxt.st4801 then
                    print("P is now correct.")
                    print(p)
                        break
                    end
                    print("P failed")
                    print(p)
                    print(nzxt.st4801.." Actual 3 4801")
                    if p >= 6 then
                        print("Failed")
                        print(p)
                        print(nzxt.st4801.." Actual 4 4801")                       
                        return true
                    end
                end
            until Game.getStorageValue(4801) == nzxt.st4801
            return true           
        else
            print("Fase 3/3")
            print(p)
            print(nzxt.st4700)
            if Game.getStorageValue(4700) == nzxt.st4700 then
                print("First GAMEST.")
            end
            if Game.getStorageValue(4801) == nzxt.st4801 then
                print("Second Gamest")
            end
   
            if Game.getStorageValue(4700) <= nzxt.st4700 and Game.getStorageValue(4801) == nzxt.st4801 and player:getStorageValue(4700) == nzxt.stplayer4700 then     -- GS 4801 IS WAVE COUNT
                print("Fase 3")
                for i = 1, #storePlayers do
                    local players = storePlayers[i]
                    if not playerTile or not playerTile:isPlayer() then
                        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 3 players.")
                        return true
                    end
                    players:setStorageValue(4700, nzxt.nextstplayer4700)
                end
                print("Fase 4")
                Game.setStorageValue(4801, nzxt.nextst4801)
                counter = nzxt.nextst4801
                nwave()
                return true
            elseif Game.getStorageValue(4700) <= 0 and Game.getStorageValue(4801) == 4 and player:getStorageValue(4700) == 4 then
                Game.setStorageValue(4801, 0)
                Game.setStorageValue(4800, os.time()+2400)
                for i = 1, #storePlayers do
                    local players = storePlayers[i]
                    players:setStorageValue(4700, 5)
                    players:sendTextMessage(TALKTYPE_MONSTER_YELL, "Fifth Wave finished. Congratulations! You got DemonHunter Second Addon.")
                    players:teleportTo(Position(32369, 32241, 7))
                    players:addOutfitAddon(288, 2)
                    players:addOutfitAddon(289, 2)
                end
            end
        end
    end
    return true
end

I put a lot of prints to see what is the problem and i saw that the variable "p" changes but not for the "nextwave[p]" so i tried a lot of things and i cant resolve it.
Help please. Thanks.
 
Back
Top