• 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 Snowball War Event Error

Larb

New Member
Joined
Nov 26, 2016
Messages
85
Reaction score
1
TFS 1.2 10.98
Error
Code:
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
attempt to index a nil value
stack traceback:
        [C]: at 0x013f7489e0
        [C]: in function 'teleportTo'
        data/globalevents/scripts/SnowBall_Event.lua:12: in function <data/globa
levents/scripts/SnowBall_Event.lua:1>
Script
 
Solution
You are most likely missing CACHE_GAMEAREAPOSITIONS, missing lib file?
Might work with just adding
Lua:
CACHE_GAMEAREAPOSITIONS = {}
to global.lua or something but you might be missing more things aswell.

But also change things like this;
Lua:
                Player(players):setStorageValue(10109, 0)
                Player(players):setStorageValue(10108, SnowBall_Configurations.Ammo_Configurations.Ammo_Start)
                Player(players):teleportTo(CACHE_GAMEAREAPOSITIONS[math.random(1, #CACHE_GAMEAREAPOSITIONS)])

To this;
Lua:
                local player = Player(players)
                if player then
                    player:setStorageValue(10109, 0)
                    player:setStorageValue(10108...
You are most likely missing CACHE_GAMEAREAPOSITIONS, missing lib file?
Might work with just adding
Lua:
CACHE_GAMEAREAPOSITIONS = {}
to global.lua or something but you might be missing more things aswell.

But also change things like this;
Lua:
                Player(players):setStorageValue(10109, 0)
                Player(players):setStorageValue(10108, SnowBall_Configurations.Ammo_Configurations.Ammo_Start)
                Player(players):teleportTo(CACHE_GAMEAREAPOSITIONS[math.random(1, #CACHE_GAMEAREAPOSITIONS)])

To this;
Lua:
                local player = Player(players)
                if player then
                    player:setStorageValue(10109, 0)
                    player:setStorageValue(10108, SnowBall_Configurations.Ammo_Configurations.Ammo_Start)
                    player:teleportTo(CACHE_GAMEAREAPOSITIONS[math.random(1, #CACHE_GAMEAREAPOSITIONS)])
                end

Same with Items(..) etc, if the player or item is removed the server might crash or you will get an error about it.
 
Solution
You are most likely missing CACHE_GAMEAREAPOSITIONS, missing lib file?
Might work with just adding
Lua:
CACHE_GAMEAREAPOSITIONS = {}
to global.lua or something but you might be missing more things aswell.

But also change things like this;
Lua:
                Player(players):setStorageValue(10109, 0)
                Player(players):setStorageValue(10108, SnowBall_Configurations.Ammo_Configurations.Ammo_Start)
                Player(players):teleportTo(CACHE_GAMEAREAPOSITIONS[math.random(1, #CACHE_GAMEAREAPOSITIONS)])

To this;
Lua:
                local player = Player(players)
                if player then
                    player:setStorageValue(10109, 0)
                    player:setStorageValue(10108, SnowBall_Configurations.Ammo_Configurations.Ammo_Start)
                    player:teleportTo(CACHE_GAMEAREAPOSITIONS[math.random(1, #CACHE_GAMEAREAPOSITIONS)])
                end

Same with Items(..) etc, if the player or item is removed the server might crash or you will get an error about it.
CACHE_GAMEAREAPOSITIONS = {} on in lib
Lib
 
CACHE_GAMEAREAPOSITIONS = {} on in lib
Lib

Is the lib loaded in that case?
Should be a function like this in most likely global.lua OR check other files that are linked with this function
Lua:
dofile("path_to_file")
 
Is the lib loaded in that case?
Should be a function like this in most likely global.lua OR check other files that are linked with this function
Lua:
dofile("path_to_file")
I add in global.lua docile(data/lid/snowconfiguration.lua)
Not more erro but don't work
 
I add in global.lua docile(data/lid/snowconfiguration.lua)
Not more erro but don't work

Add print("1") (change the number out for each if statment or before functions / returns.
That way you can see what code is loaded and what statment returns false and "ends" the script.
 
Back
Top