• Print

Author Topic: I'm new to server making. How do I add sounds?  (Read 4904 times)

0 Members and 1 Guest are viewing this topic.

Offline N00bModder

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
I'm new to server making. How do I add sounds?
« on: March 17, 2017, 06:30:09 pm »
I'm trying to add a sound in TTT for when the round ends. I didn't have a sound folder, so I created one, I added some .wav files. I tried to test it out by playsound: sound/MW2.wav. But it said: That sound doesn't exist on the server. I don't know what to do I did added this LUA file in the

C:\GMOD\garrysmod\addons\End of Round Music\lua\autorun directory.

Here is the inside of the LUA file:

-- You can add up to 3 sounds for this. Add or delete resource.addfile as you need
resource.AddFile("sound/MW2.wav")
resource.AddFile("sound/Traffic.wav")
resource.AddFile("sound/Mission.wav")

-- Remember to change the name of the sounds to the sound you want from above
local function PlayMusic(wintype)
   if wintype == WIN_INNOCENT then
      BroadcastLua('surface.PlaySound("MW2.wav")')

   elseif wintype == WIN_TRAITOR then
      BroadcastLua('surface.PlaySound("Traffic.wav")')

   elseif wintype == WIN_TIMELIMIT then
      BroadcastLua('surface.PlaySound("Mission.wav")')
   end
end
hook.Add("TTTEndRound", "MyMusic", PlayMusic)





Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: I'm new to server making. How do I add sounds?
« Reply #1 on: March 18, 2017, 10:26:52 am »
surface.PlaySound plays a sound relative to the sound/ folder. So if you have a file "sound/MW2.Wav" then
Code: Lua
  1. surface.PlaySound( "MW2.wav" )
should work just fine. Are you getting any errors server or client side?
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

  • Print