I am trying to add a client side option to disable EOR music. (cobalt wrote most of my edits just not where they go)
I'm going to post the whole document in the next post so it isn't so cluttered here too big, here's pastebin
http://pastebin.com/AGnLEPg1So I am creating the convar with
CreateConVar("ttt_eor_disabled", "0", FCVAR_ARCHIVE)
and adding it into the f1 menu with
local function BasedRejax( dtabs )
local musicsettings = vgui.Create("DPanelList", dtabs)
musicsettings:StretchToParent(0,0,padding,0)
musicsettings:EnableVerticalScrollbar(true)
musicsettings:SetPadding(10)
musicsettings:SetSpacing(10)
local setting = nil
local Music = vgui.Create("DForm", musicsettings)
Music:SetName( "End Round Music" )
setting = Music:CheckBox( "Disable End Round Music", "ttt_eor_disabled")
setting:SetTooltip("Disable EOR Music")
musicsettings:AddItem(Music)
dtabs:AddSheet("EOR Music", musicsettings, "icon16/music.png", false, false, "End Round Music Settings")
end
hook.Add( "TTTSettingsTabs", "Rejax2Based", BasedRejax )
That part is entirely functional.
I've narrowed it down the convar needs to go in
-- Serverside Networking
if ( SERVER ) then so I believe it should be similar to this.
-- Serverside Networking
if (ttt_eor_disabled == 0 ) then
if ( SERVER ) then
util.AddNetworkString( "RequestTables" )
util.AddNetworkString( "RequestTablesCallback" )
util.AddNetworkString( "SendQueueInfo" )
util.AddNetworkString( "RequestQueue" )
util.AddNetworkString( "RequestQueueCallback" )
util.AddNetworkString( "Queue_Remove" )
util.AddNetworkString( "SendCooldownInfo" )
local QueueTable = {}
hook.Add( "TTTEndRound", "PlayMusicOnEndRound", function( win )
if table.Count( QueueTable ) > 0 then
local toPlay = QueueTable[ 1 ]
umsg.Start( "playurl", player.GetAll() )
umsg.String( toPlay[ 3 ] )
umsg.End()
umsg.Start( "SendSongName", player.GetAll() )
umsg.String( toPlay[ 2 ] )
umsg.End()
ulx.fancyLog( player.GetAll(), "Playing queued song #s requested by #s", toPlay[ 2 ], toPlay[ 1 ] )
table.remove( QueueTable, 1 )
else
if win == WIN_INNOCENT then
local toPlay = table.Random( innowinsounds )
umsg.Start( "playurl", player.GetAll() )
umsg.String( toPlay[ 1 ] )
umsg.End()
umsg.Start( "SendSongName", player.GetAll() )
umsg.String( toPlay[ 2 ] )
umsg.End()
elseif win == WIN_TRAITOR then
local toPlay = table.Random( traitorwinsounds )
umsg.Start( "playurl", player.GetAll() )
umsg.String( toPlay[ 1 ] )
umsg.End()
umsg.Start( "SendSongName", player.GetAll() )
umsg.String( toPlay[ 2 ] )
umsg.End()
elseif win == WIN_TIMELIMIT then
local toPlay = table.Random( timelimitsounds )
umsg.Start( "playurl", player.GetAll() )
umsg.String( toPlay[ 1 ] )
umsg.End()
umsg.Start( "SendSongName", player.GetAll() )
umsg.String( toPlay[ 2 ] )
umsg.End()
end
end
end )
end
elseif (ttt_eor_disabled == 1 ) then
return
end
But for some reason no matter what it doesn't play music if I leave it like that, works perfect without the convar check.
It also presents this error now(doesn't without convar)
[ERROR] addons/ulx/lua/ulx/modules/sh/endroundmusic.lua:243: attempt to index global 'umsg' (a nil value)
1. oldFunc - addons/ulx/lua/ulx/modules/sh/endroundmusic.lua:243
2. fn - addons/dbugr-master/lua/dbugr/util/modules/sh_func.lua:77
3. Call - addons/ulib/lua/ulib/shared/hook.lua:183
4. RoundStateChange - gamemodes/terrortown/gamemode/cl_init.lua:136
5. oldFunc - gamemodes/terrortown/gamemode/cl_init.lua:214
6. func - addons/dbugr-master/lua/dbugr/util/modules/sh_func.lua:77
7. unknown - lua/includes/modules/net.lua:31
[/s]
line 241-249 =
hook.Add( "TTTPrepareRound", "StopSounds", function()
umsg.Start( "stop_preround", player.GetAll() )
umsg.End()
umsg.Start( "StopHUDPaint", player.GetAll() )
umsg.End()
end )
Can anyone PLEASE help me, this is driving me crazy haha
edit: attempt 7236286283
http://pastebin.com/kc7m1iyF I tried making both the if server and if client toggleable so the whole thing could just be bypassed and it did the same thing but has no errors.
I figured out the error.
But now it doesn't work AND doesn't have an error =/