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

TFS 1.X+ Snowball event tfs 1.3 problem

vexler222

Active Member
Joined
Apr 22, 2012
Messages
714
Solutions
15
Reaction score
46
Hi, i got this error when timer to start is ended and play didin't teleported players to event area


BZin0we.png


Here all files from that event - 12 KB folder on MEGA (https://mega.nz/folder/WDYSTL5b#CrRHti8H4JRC4XvzSDMbPg)
(I can't upload folders to otland, so i send it to mega nz hosting, its not problem i think?)

Bump
 
Solution
The table CACHE_GAMEAREAPOSITIONS exist, but it is empty.
It was likely created in lib/events/snowball.lua

Lua:
CACHE_GAMEPLAYERS = {}
CACHE_GAMEAREAPOSITIONS = {}

function carregarEvento()
	for newX = SNOWBALL.posArena[1].x, SNOWBALL.posArena[2].x do
		for newY = SNOWBALL.posArena[1].y, SNOWBALL.posArena[2].y do
			local AreaPos = {x = newX, y = newY, z = SNOWBALL.posArena[1].z}
			if getTileThingByPos(AreaPos).itemid == 0 then
				print("".. SNOWBALL.prefixo .."(x = " .. AreaPos.x .. " - y = " .. AreaPos.y .." - z = " .. AreaPos.z .. "), it was not possible to load these positions.")
				return false
			elseif isWalkable(AreaPos) then
				table.insert(CACHE_GAMEAREAPOSITIONS, AreaPos)
			end
		end
	end
	
	if...
I think the problem is this function from snowball/lib/events:
Lua:
function enviarSnowball(cid, pos, rounds, dir)
    local player = Player(cid)
    
    if rounds == 0 then
        return true
    end
    
    if player then
        local dirConfig = SNOWBALL.direcoes[dir]
        if dirConfig then
            local novaPos = Position(pos.x + dirConfig.dirPos.x, pos.y + dirConfig.dirPos.y, pos.z)
            if isWalkable(novaPos) then
                if Tile(novaPos):getTopCreature() then
                    local killed = Tile(novaPos):getTopCreature()
                    if Player(killed:getId()) then
                        if SNOWBALL.corposCongelados[killed:getSex()] then
                            local killed_corpse = SNOWBALL.corposCongelados[killed:getSex()][killed:getDirection()][math.random(1, #SNOWBALL.corposCongelados[killed:getSex()][killed:getDirection()])]
                            Game.createItem(killed_corpse, 1, killed:getPosition())
                            local item = Item(getTileItemById(killed:getPosition(), killed_corpse).uid)
                            addEvent(function() item:remove(1) end, 3000)
                        end
                    killed:getPosition():sendMagicEffect(3)
                    killed:teleportTo(CACHE_GAMEAREAPOSITIONS[math.random(1, #CACHE_GAMEAREAPOSITIONS)])
                    killed:getPosition():sendMagicEffect(50)
                    killed:setStorageValue(10109, (killed:getStorageValue(10109) - SNOWBALL.pontosPerda))
                    killed:setStorageValue(10108, SNOWBALL.muniMorreu)
                    killed:sendTextMessage(29, (config.mensagemFoiAcertado):format(player:getName(), SNOWBALL.pontosPerda, killed:getStorageValue(10109)))
                    player:setStorageValue(10109, player:getStorageValue(10109) + SNOWBALL.pontosAcerto)
                    player:sendTextMessage(29, (SNOWBALL.mensagemAcertei):format(killed:getName(), pontosAcerto, player:getStorageValue(10109)))
                    
                    if(CACHE_GAMEPLAYERS[2] == player:getId()) and player:getStorageValue(10109) >= Player(CACHE_GAMEPLAYERS[1]):getStorageValue(10109) then
                        player:getPosition():sendMagicEffect(7)
                        player:sendTextMessage(29, SNOWBALL.mensagemLider)
                        Player(CACHE_GAMEPLAYERS[1]):getPosition():sendMagicEffect(16)
                        Player(CACHE_GAMEPLAYERS[1]):sendTextMessage(29, SNOWBALL.mensagemPerdeuLider)
                    end
                    
                    table.sort(CACHE_GAMEPLAYERS, function(a, b) return Player(a):getStorageValue(10109) > Player(b):getStorageValue(10109) end)
                else
                    novaPos:sendMagicEffect(3)
                end
                return true
            end
                pos:sendDistanceEffect(newPos, 13)
                pos = novaPos
                return addEvent(enviarSnowball, SNOWBALL.muniVelocidade, player:getId(), pos, rounds - 1, dir)
            end
            novaPos:sendMagicEffect(3)
            return true
        end
    end
    return true
end

It looks terrible, so lets de-nest it and throw in a bunch of prints.
Lua:
function enviarSnowball(cid, pos, rounds, dir)
    if rounds == 0 then
        print("Log: Rounds: "..rounds)
        return false
    end
    
    local player = Player(cid)
    if not player then
        print("Log: Failed to load player from enviarSnowball")
        return false
    end
    
    local dirConfig = SNOWBALL.direcoes[dir]
    if not dirConfig then
        print("Log: dirConfig index failed")
        return false
    end

    local novaPos = Position(pos.x + dirConfig.dirPos.x, pos.y + dirConfig.dirPos.y, pos.z)
    if not isWalkable(novaPos) then
        novaPos:sendMagicEffect(3)
        print("log: novaPos is not walkable")
        return false
    end

    local killed = Tile(novaPos):getTopCreature()
    if not killed then
        pos:sendDistanceEffect(newPos, 13)
        pos = novaPos
        print("log: Creature (killed) not found.")
        return addEvent(enviarSnowball, SNOWBALL.muniVelocidade, player:getId(), pos, rounds - 1, dir)
    end

    -- Redundant if you can just do killed:isPlayer()?
    if not Player(killed:getId()) then
        novaPos:sendMagicEffect(3)
        print("Log: Creature [killed] failed to be casted to type Player?")
        return false
    end

    print("Log: SNOWBALL.corposCongelados[killed:getSex()]")
    if SNOWBALL.corposCongelados[killed:getSex()] then
        print("log: lots of indexes...")
        local killed_corpse = SNOWBALL.corposCongelados[killed:getSex()][killed:getDirection()][math.random(1, #SNOWBALL.corposCongelados[killed:getSex()][killed:getDirection()])]
        print("log: killed_corpse = "..type(killed_corpse))
        Game.createItem(killed_corpse, 1, killed:getPosition())
        local item = Item(getTileItemById(killed:getPosition(), killed_corpse).uid)
        addEvent(function() item:remove(1) end, 3000)
    end

    print("Log: Various [killed] and [player] actions")
    killed:getPosition():sendMagicEffect(3)
    killed:teleportTo(CACHE_GAMEAREAPOSITIONS[math.random(1, #CACHE_GAMEAREAPOSITIONS)])
    killed:getPosition():sendMagicEffect(50)
    killed:setStorageValue(10109, (killed:getStorageValue(10109) - SNOWBALL.pontosPerda))
    killed:setStorageValue(10108, SNOWBALL.muniMorreu)
    killed:sendTextMessage(29, (config.mensagemFoiAcertado):format(player:getName(), SNOWBALL.pontosPerda, killed:getStorageValue(10109)))
    
    player:setStorageValue(10109, player:getStorageValue(10109) + SNOWBALL.pontosAcerto)
    player:sendTextMessage(29, (SNOWBALL.mensagemAcertei):format(killed:getName(), pontosAcerto, player:getStorageValue(10109)))

    print("Log: CACHE_GAMEPLAYERS conditions")
    if(CACHE_GAMEPLAYERS[2] == player:getId()) and player:getStorageValue(10109) >= Player(CACHE_GAMEPLAYERS[1]):getStorageValue(10109) then
        print("Log: condition true")
        player:getPosition():sendMagicEffect(7)
        player:sendTextMessage(29, SNOWBALL.mensagemLider)
        Player(CACHE_GAMEPLAYERS[1]):getPosition():sendMagicEffect(16)
        Player(CACHE_GAMEPLAYERS[1]):sendTextMessage(29, SNOWBALL.mensagemPerdeuLider)
    end

    print("Log: table.sort")
    table.sort(CACHE_GAMEPLAYERS, function(a, b) return Player(a):getStorageValue(10109) > Player(b):getStorageValue(10109) end)

    return true
end

Try to use this one, and let me know which prints appear before Lua script error.
 
I think the problem is this function from snowball/lib/events:
Lua:
function enviarSnowball(cid, pos, rounds, dir)
    local player = Player(cid)
  
    if rounds == 0 then
        return true
    end
  
    if player then
        local dirConfig = SNOWBALL.direcoes[dir]
        if dirConfig then
            local novaPos = Position(pos.x + dirConfig.dirPos.x, pos.y + dirConfig.dirPos.y, pos.z)
            if isWalkable(novaPos) then
                if Tile(novaPos):getTopCreature() then
                    local killed = Tile(novaPos):getTopCreature()
                    if Player(killed:getId()) then
                        if SNOWBALL.corposCongelados[killed:getSex()] then
                            local killed_corpse = SNOWBALL.corposCongelados[killed:getSex()][killed:getDirection()][math.random(1, #SNOWBALL.corposCongelados[killed:getSex()][killed:getDirection()])]
                            Game.createItem(killed_corpse, 1, killed:getPosition())
                            local item = Item(getTileItemById(killed:getPosition(), killed_corpse).uid)
                            addEvent(function() item:remove(1) end, 3000)
                        end
                    killed:getPosition():sendMagicEffect(3)
                    killed:teleportTo(CACHE_GAMEAREAPOSITIONS[math.random(1, #CACHE_GAMEAREAPOSITIONS)])
                    killed:getPosition():sendMagicEffect(50)
                    killed:setStorageValue(10109, (killed:getStorageValue(10109) - SNOWBALL.pontosPerda))
                    killed:setStorageValue(10108, SNOWBALL.muniMorreu)
                    killed:sendTextMessage(29, (config.mensagemFoiAcertado):format(player:getName(), SNOWBALL.pontosPerda, killed:getStorageValue(10109)))
                    player:setStorageValue(10109, player:getStorageValue(10109) + SNOWBALL.pontosAcerto)
                    player:sendTextMessage(29, (SNOWBALL.mensagemAcertei):format(killed:getName(), pontosAcerto, player:getStorageValue(10109)))
                  
                    if(CACHE_GAMEPLAYERS[2] == player:getId()) and player:getStorageValue(10109) >= Player(CACHE_GAMEPLAYERS[1]):getStorageValue(10109) then
                        player:getPosition():sendMagicEffect(7)
                        player:sendTextMessage(29, SNOWBALL.mensagemLider)
                        Player(CACHE_GAMEPLAYERS[1]):getPosition():sendMagicEffect(16)
                        Player(CACHE_GAMEPLAYERS[1]):sendTextMessage(29, SNOWBALL.mensagemPerdeuLider)
                    end
                  
                    table.sort(CACHE_GAMEPLAYERS, function(a, b) return Player(a):getStorageValue(10109) > Player(b):getStorageValue(10109) end)
                else
                    novaPos:sendMagicEffect(3)
                end
                return true
            end
                pos:sendDistanceEffect(newPos, 13)
                pos = novaPos
                return addEvent(enviarSnowball, SNOWBALL.muniVelocidade, player:getId(), pos, rounds - 1, dir)
            end
            novaPos:sendMagicEffect(3)
            return true
        end
    end
    return true
end

It looks terrible, so lets de-nest it and throw in a bunch of prints.
Lua:
function enviarSnowball(cid, pos, rounds, dir)
    if rounds == 0 then
        print("Log: Rounds: "..rounds)
        return false
    end
  
    local player = Player(cid)
    if not player then
        print("Log: Failed to load player from enviarSnowball")
        return false
    end
  
    local dirConfig = SNOWBALL.direcoes[dir]
    if not dirConfig then
        print("Log: dirConfig index failed")
        return false
    end

    local novaPos = Position(pos.x + dirConfig.dirPos.x, pos.y + dirConfig.dirPos.y, pos.z)
    if not isWalkable(novaPos) then
        novaPos:sendMagicEffect(3)
        print("log: novaPos is not walkable")
        return false
    end

    local killed = Tile(novaPos):getTopCreature()
    if not killed then
        pos:sendDistanceEffect(newPos, 13)
        pos = novaPos
        print("log: Creature (killed) not found.")
        return addEvent(enviarSnowball, SNOWBALL.muniVelocidade, player:getId(), pos, rounds - 1, dir)
    end

    -- Redundant if you can just do killed:isPlayer()?
    if not Player(killed:getId()) then
        novaPos:sendMagicEffect(3)
        print("Log: Creature [killed] failed to be casted to type Player?")
        return false
    end

    print("Log: SNOWBALL.corposCongelados[killed:getSex()]")
    if SNOWBALL.corposCongelados[killed:getSex()] then
        print("log: lots of indexes...")
        local killed_corpse = SNOWBALL.corposCongelados[killed:getSex()][killed:getDirection()][math.random(1, #SNOWBALL.corposCongelados[killed:getSex()][killed:getDirection()])]
        print("log: killed_corpse = "..type(killed_corpse))
        Game.createItem(killed_corpse, 1, killed:getPosition())
        local item = Item(getTileItemById(killed:getPosition(), killed_corpse).uid)
        addEvent(function() item:remove(1) end, 3000)
    end

    print("Log: Various [killed] and [player] actions")
    killed:getPosition():sendMagicEffect(3)
    killed:teleportTo(CACHE_GAMEAREAPOSITIONS[math.random(1, #CACHE_GAMEAREAPOSITIONS)])
    killed:getPosition():sendMagicEffect(50)
    killed:setStorageValue(10109, (killed:getStorageValue(10109) - SNOWBALL.pontosPerda))
    killed:setStorageValue(10108, SNOWBALL.muniMorreu)
    killed:sendTextMessage(29, (config.mensagemFoiAcertado):format(player:getName(), SNOWBALL.pontosPerda, killed:getStorageValue(10109)))
  
    player:setStorageValue(10109, player:getStorageValue(10109) + SNOWBALL.pontosAcerto)
    player:sendTextMessage(29, (SNOWBALL.mensagemAcertei):format(killed:getName(), pontosAcerto, player:getStorageValue(10109)))

    print("Log: CACHE_GAMEPLAYERS conditions")
    if(CACHE_GAMEPLAYERS[2] == player:getId()) and player:getStorageValue(10109) >= Player(CACHE_GAMEPLAYERS[1]):getStorageValue(10109) then
        print("Log: condition true")
        player:getPosition():sendMagicEffect(7)
        player:sendTextMessage(29, SNOWBALL.mensagemLider)
        Player(CACHE_GAMEPLAYERS[1]):getPosition():sendMagicEffect(16)
        Player(CACHE_GAMEPLAYERS[1]):sendTextMessage(29, SNOWBALL.mensagemPerdeuLider)
    end

    print("Log: table.sort")
    table.sort(CACHE_GAMEPLAYERS, function(a, b) return Player(a):getStorageValue(10109) > Player(b):getStorageValue(10109) end)

    return true
end

Try to use this one, and let me know which prints appear before Lua script error.

same error and any prints in console
1qJY8bA.png
 
No prints above that Lua script error? Maybe it wasn't that function then :/
Try scattering a bunch of prints around the snowball code files to identify which file and function causes the error.

I thought a timer event usually means a function called from addEvent, but perhaps it can be globalevents as well?
 
No prints above that Lua script error? Maybe it wasn't that function then :/
Try scattering a bunch of prints around the snowball code files to identify which file and function causes the error.

I thought a timer event usually means a function called from addEvent, but perhaps it can be globalevents as well?

I added more prints, and i got this print before error
VVvpNgB.png


Print is in globalevents file
Lua:
function startGame(rounds)
    if rounds == 0 then
        if #CACHE_GAMEPLAYERS < SNOWBALL.minPlayers then
            for _, players in ipairs(CACHE_GAMEPLAYERS) do
                Player(players):teleportTo(Player(players):getTown():getTemplePosition())
            end
            broadcastMessage(SNOWBALL.prefixo .. (SNOWBALL.mensagemEventoFaltaPlayer):format(SNOWBALL.minPlayers))
        else
            for _, players in ipairs(CACHE_GAMEPLAYERS) do
                local player = Player(players)
                if player then
                    print("Log: startGame player is here?")
                    player:setStorageValue(10109, 0)
                    player:setStorageValue(10108, SNOWBALL.muniInicial)
                    player:setStorageValue(STORAGEVALUE_EVENTS, 1)
                    player:teleportTo(CACHE_GAMEAREAPOSITIONS[math.random(1, #CACHE_GAMEAREAPOSITIONS)])
                end
            end
            print("Log: start game test")
            broadcastMessage(SNOWBALL.prefixo .. SNOWBALL.mensagemInicioEvento)
            addEvent(terminarEvento, SNOWBALL.duracaoEvento * 60 * 1000)
        end

        Item(getTileItemById(SNOWBALL.posTpEntrarEvento, 1387).uid):remove(1)
        return true
    end
    if #CACHE_GAMEPLAYERS < SNOWBALL.minPlayers then
        broadcastMessage(SNOWBALL.prefixo .. (SNOWBALL.mensagemEsperandoIniciar):format(rounds, SNOWBALL.minPlayers - #CACHE_GAMEPLAYERS))
    else
        broadcastMessage("[Snowball]\nTeleport will be opened for ".. rounds .." min.")
    end
    return addEvent(startGame, 60 * 1000, rounds - 1)
end

function onThink(interval)
    if SNOWBALL.days[os.date("%A")] then
        local hrs = tostring(os.date("%X")):sub(1, 5)
        if isInArray(SNOWBALL.days[os.date("%A")], hrs) then
            CACHE_GAMEPLAYERS = {}
            broadcastMessage(SNOWBALL.prefixo .. SNOWBALL.mensagemEventoAberto)
            print("Log: snowball time")
            local EventTeleport = Game.createItem(1387, 1, SNOWBALL.posTpEntrarEvento)
            EventTeleport:setActionId(10101)
            print("Log: tp maked")
            addEvent(startGame, 60 * 1000, SNOWBALL.duracaoEspera)
        end
    end
    return true
end
 
Replace:
Lua:
                if player then
                    print("Log: startGame player is here?")
                    player:setStorageValue(10109, 0)
                    player:setStorageValue(10108, SNOWBALL.muniInicial)
                    player:setStorageValue(STORAGEVALUE_EVENTS, 1)
                    player:teleportTo(CACHE_GAMEAREAPOSITIONS[math.random(1, #CACHE_GAMEAREAPOSITIONS)])
                end

With:
Lua:
                if player then
                    print("Log: startGame player ["..player:getName().."] is here?")
                    player:setStorageValue(10109, 0)
                   
                    if not SNOWBALL.muniInicial then
                        print("Error: SNOWBALL.muniInicial is not defined.")
                    end
                    player:setStorageValue(10108, SNOWBALL.muniInicial)
                   
                    if not STORAGEVALUE_EVENTS then
                        print("Error: STORAGEVALUE_EVENTS is not defined.")
                    end
                    player:setStorageValue(STORAGEVALUE_EVENTS, 1)
                   
                    if not CACHE_GAMEAREAPOSITIONS then
                        print("Error: CACHE_GAMEAREAPOSITIONS is not defined.")
                    end
                   
                    local randomSeed = math.random(1, #CACHE_GAMEAREAPOSITIONS)
                    if not CACHE_GAMEAREAPOSITIONS[randomSeed] then
                        print("Error: CACHE_GAMEAREAPOSITIONS[randomSeed] is not defined.")
                    end
                    player:teleportTo(CACHE_GAMEAREAPOSITIONS[randomSeed])
                end
 
Replace:
Lua:
                if player then
                    print("Log: startGame player is here?")
                    player:setStorageValue(10109, 0)
                    player:setStorageValue(10108, SNOWBALL.muniInicial)
                    player:setStorageValue(STORAGEVALUE_EVENTS, 1)
                    player:teleportTo(CACHE_GAMEAREAPOSITIONS[math.random(1, #CACHE_GAMEAREAPOSITIONS)])
                end

With:
Lua:
                if player then
                    print("Log: startGame player ["..player:getName().."] is here?")
                    player:setStorageValue(10109, 0)
                  
                    if not SNOWBALL.muniInicial then
                        print("Error: SNOWBALL.muniInicial is not defined.")
                    end
                    player:setStorageValue(10108, SNOWBALL.muniInicial)
                  
                    if not STORAGEVALUE_EVENTS then
                        print("Error: STORAGEVALUE_EVENTS is not defined.")
                    end
                    player:setStorageValue(STORAGEVALUE_EVENTS, 1)
                  
                    if not CACHE_GAMEAREAPOSITIONS then
                        print("Error: CACHE_GAMEAREAPOSITIONS is not defined.")
                    end
                  
                    local randomSeed = math.random(1, #CACHE_GAMEAREAPOSITIONS)
                    if not CACHE_GAMEAREAPOSITIONS[randomSeed] then
                        print("Error: CACHE_GAMEAREAPOSITIONS[randomSeed] is not defined.")
                    end
                    player:teleportTo(CACHE_GAMEAREAPOSITIONS[randomSeed])
                end
BJqSgog.png
 
So CACHE_GAMEAREAPOSITIONS exists, but it fails to grab a random element from the table.
Could be the table exist but is empty, or that the element indexes are not iterative (ipairs) compliant which the random seed presumes.
Or perhaps we need to do math floor or something to make sure the math.random result creates an integer and not a float.

Lets have a look:

Replace:
Lua:
                    if not CACHE_GAMEAREAPOSITIONS[randomSeed] then
                        print("Error: CACHE_GAMEAREAPOSITIONS[randomSeed] is not defined.")
                    end

With:
Lua:
                    if not CACHE_GAMEAREAPOSITIONS[randomSeed] then
                        print("Error: CACHE_GAMEAREAPOSITIONS[randomSeed] is not defined.")
                        tdump("CACHE_GAMEAREAPOSITIONS ["..randomSeed.."]", {
                            ["seed"] = randomSeed,
                            ["table"] = CACHE_GAMEAREAPOSITIONS
                        })
                    end

Make sure you have the debugging dump function installed:
 
Last edited:
So CACHE_GAMEAREAPOSITIONS exists, but it fails to grab a random element from the table.
Could be the table exist but is empty, or that the element indexes are not iterative (ipairs) compliant which the random seed presumes.
Or perhaps we need to do math floor or something to make sure the math.random result creates an integer and not a float.

Lets have a look:

Replace:
Lua:
                    if not CACHE_GAMEAREAPOSITIONS[randomSeed] then
                        print("Error: CACHE_GAMEAREAPOSITIONS[randomSeed] is not defined.")
                    end

With:
Lua:
                    if not CACHE_GAMEAREAPOSITIONS[randomSeed] then
                        print("Error: CACHE_GAMEAREAPOSITIONS[randomSeed] is not defined.")
                        tdump("CACHE_GAMEAREAPOSITIONS ["..randomSeed.."]", {
                            ["seed"] = randomSeed,
                            ["table"] = CACHE_GAMEAREAPOSITIONS
                        })
                    end

Make sure you have the debugging dump function installed:
I added dump.lua, but i got this error
IC4y8rS.png
 
Lua:
                if player then
                    print("Log: startGame player is here?")
                    player:setStorageValue(10109, 0)
                    
                    if not SNOWBALL.muniInicial then
                        print("Error: SNOWBALL.muniInicial is not defined.")
                    end
                    player:setStorageValue(10108, SNOWBALL.muniInicial)
                    
                    if not STORAGEVALUE_EVENTS then
                        print("Error: STORAGEVALUE_EVENTS is not defined.")
                    end
                    player:setStorageValue(STORAGEVALUE_EVENTS, 1)
                    
                    if not CACHE_GAMEAREAPOSITIONS then
                        print("Error: CACHE_GAMEAREAPOSITIONS is not defined.")
                    end
                    
                    print("Log: Length of CACHE_GAMEAREAPOSITIONS: "..#CACHE_GAMEAREAPOSITIONS)
                    local randomSeed = math.random(1, #CACHE_GAMEAREAPOSITIONS)
                    print("Log: randomSeed is of type: ".. type(randomSeed))
                    if randomSeed ~= nil then
                        print("randomSeed is: "..randomSeed)
                    end
                    if not CACHE_GAMEAREAPOSITIONS[randomSeed] then
                        print("Error: CACHE_GAMEAREAPOSITIONS[randomSeed] is not defined.")
                        tdump("CACHE_GAMEAREAPOSITIONS ["..randomSeed.."]", {
                            ["seed"] = randomSeed,
                            ["table"] = CACHE_GAMEAREAPOSITIONS
                        })
                    end
                    player:teleportTo(CACHE_GAMEAREAPOSITIONS[randomSeed])
                end
 
The table CACHE_GAMEAREAPOSITIONS exist, but it is empty.
It was likely created in lib/events/snowball.lua

Lua:
CACHE_GAMEPLAYERS = {}
CACHE_GAMEAREAPOSITIONS = {}

function carregarEvento()
	for newX = SNOWBALL.posArena[1].x, SNOWBALL.posArena[2].x do
		for newY = SNOWBALL.posArena[1].y, SNOWBALL.posArena[2].y do
			local AreaPos = {x = newX, y = newY, z = SNOWBALL.posArena[1].z}
			if getTileThingByPos(AreaPos).itemid == 0 then
				print("".. SNOWBALL.prefixo .."(x = " .. AreaPos.x .. " - y = " .. AreaPos.y .." - z = " .. AreaPos.z .. "), it was not possible to load these positions.")
				return false
			elseif isWalkable(AreaPos) then
				table.insert(CACHE_GAMEAREAPOSITIONS, AreaPos)
			end
		end
	end
	
	if getTileThingByPos(SNOWBALL.posEspera).itemid == 0 then
		print("".. SNOWBALL.prefixo .."There was a problem checking the position of the waiting room, please check the conditions.")
		return false
	end

	if getTileThingByPos(SNOWBALL.posTpEntrarEvento).itemid == 0 then
		print("".. SNOWBALL.prefixo .."There was a problem when checking the existence of the position to create the event teleport, please check the conditions.")
		return false
	end
	return true
end

But maybe function carregarEvento() was never executed? This function must run somewhere to populate this table with available positions to teleport player.
 
Solution
The table CACHE_GAMEAREAPOSITIONS exist, but it is empty.
It was likely created in lib/events/snowball.lua

Lua:
CACHE_GAMEPLAYERS = {}
CACHE_GAMEAREAPOSITIONS = {}

function carregarEvento()
    for newX = SNOWBALL.posArena[1].x, SNOWBALL.posArena[2].x do
        for newY = SNOWBALL.posArena[1].y, SNOWBALL.posArena[2].y do
            local AreaPos = {x = newX, y = newY, z = SNOWBALL.posArena[1].z}
            if getTileThingByPos(AreaPos).itemid == 0 then
                print("".. SNOWBALL.prefixo .."(x = " .. AreaPos.x .. " - y = " .. AreaPos.y .." - z = " .. AreaPos.z .. "), it was not possible to load these positions.")
                return false
            elseif isWalkable(AreaPos) then
                table.insert(CACHE_GAMEAREAPOSITIONS, AreaPos)
            end
        end
    end
   
    if getTileThingByPos(SNOWBALL.posEspera).itemid == 0 then
        print("".. SNOWBALL.prefixo .."There was a problem checking the position of the waiting room, please check the conditions.")
        return false
    end

    if getTileThingByPos(SNOWBALL.posTpEntrarEvento).itemid == 0 then
        print("".. SNOWBALL.prefixo .."There was a problem when checking the existence of the position to create the event teleport, please check the conditions.")
        return false
    end
    return true
end

But maybe function carregarEvento() was never executed? This function must run somewhere to populate this table with available positions to teleport player.

Thanks bro, i found this script in brazil datapack and i don't find all files/lines, but now i check all files in globalevents and in startup.lua is "carregarEvento()", i added it and it work, but now i have problem with talkactions.. When i try use command to shot, i saw only info with how many snowballs i have, and everytime when i used command to shot i lose -1 ball, and error in console.
When i use command !snowball info, i got crash client

zPMFyDW.png


Code:
function onSay(player, words, param)
    if not isInArena(player) then
        return false
    end

    if param == SNOWBALL.comandoAtirar then

        if not SNOWBALL.muniInfinito then
            if player:getStorageValue(10108) > 0 then
                player:setStorageValue(10108, player:getStorageValue(10108) - 1)
                player:sendCancelMessage(SNOWBALL.prefixo .. (SNOWBALL.mensagemQntBolas):format(player:getStorageValue(10108)))
            else
                player:sendCancelMessage(SNOWBALL.prefixo .. SNOWBALL.mensagemNaoTemBola)
                return true
            end
        end

        enviarSnowball(player:getId(), player:getPosition(), SNOWBALL.muniDistancia, player:getDirection())
        return false
    elseif param == "info" then
        local str = "     ## -> Player Infos <- ##\n\nPontos: ".. player:getStorageValue(10109) .."\nBolas de neve: ".. player:getStorageValue(10108)

        str = str .. "\n\n          ## -> Ranking <- ##\n\n"
        for i = 1, 5 do
            if CACHE_GAMEPLAYERS[i] then
                str  = str .. i .. ". " .. Player(CACHE_GAMEPLAYERS[i]):getName() .."\n"
            end
        end
        for pos, players in ipairs(CACHE_GAMEPLAYERS) do
            if player:getId() == players then
                str = str .. "Minha posição no ranking: " .. pos
            end
        end

        player:showTextDialog(2111, str)
        return false
    end
end
 
Thanks bro, i found this script in brazil datapack and i don't find all files/lines, but now i check all files in globalevents and in startup.lua is "carregarEvento()", i added it and it work, but now i have problem with talkactions.. When i try use command to shot, i saw only info with how many snowballs i have, and everytime when i used command to shot i lose -1 ball, and error in console.
When i use command !snowball info, i got crash client

zPMFyDW.png


Code:
function onSay(player, words, param)
    if not isInArena(player) then
        return false
    end

    if param == SNOWBALL.comandoAtirar then

        if not SNOWBALL.muniInfinito then
            if player:getStorageValue(10108) > 0 then
                player:setStorageValue(10108, player:getStorageValue(10108) - 1)
                player:sendCancelMessage(SNOWBALL.prefixo .. (SNOWBALL.mensagemQntBolas):format(player:getStorageValue(10108)))
            else
                player:sendCancelMessage(SNOWBALL.prefixo .. SNOWBALL.mensagemNaoTemBola)
                return true
            end
        end

        enviarSnowball(player:getId(), player:getPosition(), SNOWBALL.muniDistancia, player:getDirection())
        return false
    elseif param == "info" then
        local str = "     ## -> Player Infos <- ##\n\nPontos: ".. player:getStorageValue(10109) .."\nBolas de neve: ".. player:getStorageValue(10108)

        str = str .. "\n\n          ## -> Ranking <- ##\n\n"
        for i = 1, 5 do
            if CACHE_GAMEPLAYERS[i] then
                str  = str .. i .. ". " .. Player(CACHE_GAMEPLAYERS[i]):getName() .."\n"
            end
        end
        for pos, players in ipairs(CACHE_GAMEPLAYERS) do
            if player:getId() == players then
                str = str .. "Minha posição no ranking: " .. pos
            end
        end

        player:showTextDialog(2111, str)
        return false
    end
end


refresh
 
Back
Top