• Server cleanup stops all sounds, which breaks some lua. Yay!
    2 replies, posted
Ok, so. Lets get right to it. Hive365 is a digital radio for many games, including Garrys Mod. The developer of the Garrys Mod Hive365 addon has left the team. Therefore, they have outsourced the problem to me. So, in game, you can type !tune and it tunes you in, right? BUUUUUUUUUT, If the server does a cleanup, for example, after a game of prophunt. It stops all sounds. Stopping the music. I have made an in game fix using the PostCleanupMap() hook. This is my code: [CODE] function PostCleanupMap() -- Runs the function hook [FUNC:1] for k, ply in pairs( player.GetAll() ) do -- Loops through everyone in the server, the following: [PAIRS:1] clientvalue = ply:GetInfoNum( hive_tuned, 1 ) -- Checks if the concommand hive_tuned = 1 if clientvalue => 1 then -- If it is equal, or greater then 1, it's supposed to do this: [IF:1] ply:ConCommand("hive_tune") -- Tune out (Cos even though the music has stopped, no one has told the addon, so it still thinks hive_tuned = 1 ply:ConCommand("hive_tune") -- Tune back in (This will begin the music again) end -- Ends [IF:1] end -- Ends [PAIRS:1] end -- Ends [FUNC:1] [/CODE] It doesn't work! Also, the code is messy, cos in the chat it goes: You are now tuned in =D You are now tuned out :( You are now tuned in =D You are now tuned out :( What I want, is it to do this: (Behold my code paraphrase [CAPITALS MEAN IT IS PARAPHRASED) [CODE] function PostCleanupMap() for k, ply in pairs( player.GetAll() ) do IF ply:HIVE_TUNED = 1 THEN ply:PLAY MUSIC end end end [/CODE] IF you need the original code, im not sure if it is open source or not. So I will need to contact the Hive365 team first. If you do think you have a solution. Add me on steam. [url]http://steamcommunity.com/id/theoneandonlygenetical[/url] FINAL NOTES: hive_tune is a console command which can be run by the client to toggle music on and off !tune is a chat command which can be run by the client to toggle music on and off hive_tuned is a console command which doesn't affect the playing of the music, but lets it record whether or not a player is tuned in. NOTE: The code is run serverside. Tuning in looks like this [CLIENTSIDE]: [CODE] function TuneIn () if rValid() then Music:Stop() end sound.PlayURL(streamUrl,"play", function(chan) if chan !=nil then Music = chan Music:SetVolume(hive_volume:GetInt() / 100) end end ) RunConsoleCommand("hive_tuned", 1) chat.AddText("You are now tuned in =D") end [/CODE] Thnx
[QUOTE=Genetical;52298797]snip[/QUOTE] As far as I know the only code you need to add to achieve this is the following: [CODE]hook.Add("PostCleanupMap", "hive_music", function() if hive_tuned:GetBool() then if rValid() then Music:Play() else sound.PlayURL(streamUrl, "play", function(chan) if chan !=nil then Music = chan Music:SetVolume(hive_volume:GetInt() / 100) end end) end end end)[/CODE] This uses their code that I wrapped inside the cleanupmap hook. The thing you are doing wrong is checking on the server if the user is playing the music or not. You should use the client itself.
[QUOTE=darkjacky;52298831]As far as I know the only code you need to add to achieve this is the following: [CODE]hook.Add("PostCleanupMap", "hive_music", function() if hive_tuned:GetBool() then if rValid() then Music:Play() else sound.PlayURL(streamUrl, "play", function(chan) if chan !=nil then Music = chan Music:SetVolume(hive_volume:GetInt() / 100) end end) end end end)[/CODE] This uses their code that I wrapped inside the cleanupmap hook. The thing you are doing wrong is checking on the server if the user is playing the music or not. You should use the client itself.[/QUOTE] [ERROR] lua/autorun/client/hive_sound_hotfix.lua:2: attempt to index global 'hive_tuned' (a nil value) 1. fn - lua/autorun/client/hive_sound_hotfix.lua:2
Sorry, you need to Log In to post a reply to this thread.