I have a working round timer and all that, but after the round ends it fails to call the function.
[code]
local MapChooser = nil
function GM:ShowMapChooser( gm_table )
if ( MapChooser ) then MapChooser:Remove() end
MapChooser = vgui.CreateFromTable( vgui_Splash )
MapChooser:SetHeaderText( "Which Map?" )
MapChooser:SetHoverText( "Which of these maps do you want to play this gamemode on?" );
for _, v in SortedPairs( gm_table.maps ) do
local func = function() RunConsoleCommand( "playgamemode", gm_table.name, v ) end
local btn = MapChooser:AddSelectButton( v, func )
btn.m_colBackground = Color( 120, 255, 100 )
end
MapChooser:AddCancelButton()
MapChooser:MakePopup()
MapChooser:NoFadeIn()
end
[/code]
That is the function above
Below is the round end function
[code]
function round.End()
function GM:ShowMapChooser() end
round.Broadcast("Round over! Next round in " .. round.Break .. " seconds!")
timer.Simple(round.Break, round.Begin)
end
[/code]
After the round ends I get this error.
[code]
Timer Failed! [Simple][@gamemodes/tdm/gamemode/init.lua (line 200)]
[ERROR] gamemodes/tdm/gamemode/init.lua:228: attempt to index global 'GM' (a nil value)
1. unknown - gamemodes/tdm/gamemode/init.lua:228
[/code]
I am still learning LUA, so if it is really obviously I apologize haha!
If someone would know how to fix that, that would be awesome! Thanks!
I think the problem is this bit:
[CODE]
function round.End()
function GM:ShowMapChooser() end
round.Broadcast("Round over! Next round in " .. round.Break .. " seconds!")
timer.Simple(round.Break, round.Begin)
end
[/CODE]
The way you're using functions is a bit strange and I have a feeling they're not being ended properly- try this:
[CODE]
function round.End()
GM:ShowMapChooser() -- you don't need to say it's a function or end it
round.Broadcast("Round over! Next round in " .. round.Break .. " seconds!")
timer.Simple(round.Break, round.Begin)
end
[/CODE]
[editline]25th May 2016[/editline]
If that still gives the same error, you may want to try using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/hook/Call]hook.Call[/url] instead
Sorry, you need to Log In to post a reply to this thread.