Author Topic: Modifying Cobalt's EOR system  (Read 2250 times)

0 Members and 2 Guests are viewing this topic.

Offline pants

  • Newbie
  • *
  • Posts: 33
  • Karma: 4
Modifying Cobalt's EOR system
« on: March 26, 2014, 11:05:42 PM »
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/AGnLEPg1

So I am creating the convar with

Code: [Select]
CreateConVar("ttt_eor_disabled", "0", FCVAR_ARCHIVE)
and adding it into the f1 menu with

Code: [Select]
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.

Code: [Select]
-- 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)
Code: [Select]
[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 =

Code: [Select]
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 7236286283http://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 =/
« Last Edit: March 27, 2014, 12:37:08 AM by pants »

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Modifying Cobalt's EOR system
« Reply #1 on: March 27, 2014, 08:11:30 AM »
Why are you making a client side convar on the server? I can help you when I get home later, don't worry.

Offline pants

  • Newbie
  • *
  • Posts: 33
  • Karma: 4
Re: Modifying Cobalt's EOR system
« Reply #2 on: March 27, 2014, 11:02:16 AM »
I was trying to have it check the client's convar to see if it should do it or not.
alright, cool. Hired you on the CH job too. :)