Ok, for whatever reason, I now get an error saying this: “Timer Error: ZombieSurvival\gamemode\sv_mapchangehandler.lua:27: attempt to index field ‘?’ (a nil value)”
This occurs in this area of code:
local g_PlayableGamemodes = {"ZombieSurvival"}
fretta_votesneeded = CreateConVar( "fretta_votesneeded", "0.7", { FCVAR_ARCHIVE } )
fretta_votetime = CreateConVar( "fretta_votetime", "20", { FCVAR_ARCHIVE } )
fretta_votegraceperiod = CreateConVar( "fretta_votegraceperiod", "30", { FCVAR_ARCHIVE } )
function GetRandomGamemodeMap( gm )
return table.Random( g_PlayableGamemodes[ gm ].maps )
end
function GetNumberOfGamemodeMaps( gm )
print("More debugging...")
print("Number of children in g_PlayableGamemodes: "..#g_PlayableGamemodes)
print("The last object's name is: "..tostring(g_PlayableGamemodes[#g_PlayableGamemodes]))
return table.Count( g_PlayableGamemodes[gm].maps )
end
function setup() --This is the first function run in the entire file, it starts up necessary things for voting.
print("Setup has been called, starting up!")
local AllMaps = file.Find( "../maps/*.bsp" )
for key, map in pairs( AllMaps ) do
AllMaps[ key ] = string.gsub( map, ".bsp", "" )
end
gm = gmod.GetGamemode()
print("The current gamemode.name is: "..tostring(GAMEMODE.Name))
local info = file.Read( "../gamemodes/"..gm.Name.."/info.txt" )
if ( info ) then
local info = KeyValuesToTable( info )
if ( info.selectable == 1 ) then
g_PlayableGamemodes[ gm.Name ] = {}
g_PlayableGamemodes[ gm.Name ].name = gm.Name
g_PlayableGamemodes[ gm.Name ].label = info.name
g_PlayableGamemodes[ gm.Name ].description = info.description
g_PlayableGamemodes[ gm.Name ].author = info.author_name
g_PlayableGamemodes[ gm.Name ].authorurl = info.author_url
g_PlayableGamemodes[ gm.Name ].maps = {}
(The maps get filled later on, my main focus is at
return table.Count(g_PlayableGamemodes[gm].maps ).
I don’t really know why it’s nil. There should be something in it.