• How to add win,lose,draw sound multigames gamemode
    8 replies, posted
this minigame mode https://steamcommunity.com/sharedfiles/filedetails/?id=637780897
Extract the source files from the GMA and reverse engineer it. Then use surface.PlaySound to play sounds.
if CurrentMapSettings["TeamType"] == 2 or CurrentMapSettings["TeamType"] == 3 then local str if winner == TEAM_RED then str = "RedWon" elseif winner == TEAM_BLUE then str = "BlueWon" end if str then SendNotification(str) end for _, v in pairs(players) do if v:Team() == winner then if CurrentMapSettings["WinPoints"] != 0 then if v:Alive() then SendPoints(v, math.Round(CurrentMapSettings["WinPoints"] * 1.25)) surface.PlaySound( "items/ammo_pickup.wav" ) else SendPoints(v, CurrentMapSettings["WinPoints"]) surface.PlaySound( "items/ammo_pickup.wav" ) end end elseif CurrentMapSettings["LossPoints"] != 0 then surface.PlaySound( "items/ammo_pickup.wav" ) SendPoints(v, CurrentMapSettings["LossPoints"]) end end end end } Is that right? Does not work
Do you want the sound to play for all players?
how to run it through Client side
That is literally the first thing most tutorials teach you. You can have different files that run clientside, serverside or shared which means you run it on both. I guess that code you are running is running serverside so this means you need to network it to the client. Here's a great tutorial on something similar: https://www.youtube.com/watch?v=ODlGyS6lR1M
if CurrentMapSettings["TeamType"] == 2 or CurrentMapSettings["TeamType"] == 3 then local str if winner == TEAM_RED then str = "RedWon" elseif winner == TEAM_BLUE then str = "BlueWon" end if str then SendNotification(str) end for _, v in pairs(players) do if v:Team() == winner then if CurrentMapSettings["WinPoints"] != 0 then if v:Alive() then SendPoints(v, math.Round(CurrentMapSettings["WinPoints"] * 1.25)) net.Receive("SendSounds", function(len, ply)      surface.PlaySound("music/HL2_song14.mp3") end) else net.Receive("SendSounds", function(len, ply)     surface.PlaySound("music/HL2_song14.mp3") end) SendPoints(v, CurrentMapSettings["WinPoints"]) end end elseif CurrentMapSettings["LossPoints"] != 0 then net.Receive("SendSounds", function(len, ply)     surface.PlaySound("music/HL2_song14.mp3") end) SendPoints(v, CurrentMapSettings["LossPoints"]) end end end end } i try some net.Receive this way no more pop up "surface" nil value error message but still i can't hear sounds sorry my english level is suck so i can't understand video perfectly  
Nobody can debug this because we don't know where this code comes from and on what real it's executed. net.Receive should be called from the root of the file, not in a function or in a condition. If you don't understand how the net library works, you can read up about it right here: Net Library Usage
oh yeah i fixd that thx guys
Sorry, you need to Log In to post a reply to this thread.