• Print

Author Topic: Help with superadmin death sound.  (Read 5903 times)

0 Members and 1 Guest are viewing this topic.

Offline jacob428

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Help with superadmin death sound.
« on: December 17, 2013, 10:12:39 am »
I am trying to make it so a custom sound plays when a superadmin dies instead of the default death sounds. The wav is 44100/1441. It currently still plays from the regular deathsounds table. Any help would be appreciated! Also there are no errors currently.

From player.lua:
Code: Lua
  1. local admindeathsound = Sound( "sound/fail.wav" )
  2.  
  3. local function PlayDeathSound(victim)
  4.    if not IsValid(victim) then return end
  5.         if victim:IsSuperAdmin() then
  6.         sound.Play(admindeathsound, victim:GetShootPos(), 90, 100)  
  7.         end
  8.         sound.Play(table.Random(deathsounds), victim:GetShootPos(), 90, 100)  
  9. end
« Last Edit: December 17, 2013, 10:16:07 am by jacob428 »

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Help with superadmin death sound.
« Reply #1 on: December 17, 2013, 11:20:54 am »
There was an 'end' where the 'else' was suppose to be.

Code: Lua
  1. local admindeathsound = Sound( "sound/fail.wav" )
  2.  
  3. function PlayDeathSound( victim )
  4.  
  5. if not IsValid( victim ) then
  6.         return
  7. end
  8.  
  9. if victim:IsSuperAdmin() then
  10.         sound.Play( admindeathsound, victim:GetShootPos(), 90, 100 )  
  11. else
  12.         sound.Play( table.Random( deathsounds ), victim:GetShootPos(), 90, 100 )  
  13. end
  14.  
  15. end
  16.  
« Last Edit: December 17, 2013, 11:22:55 am by Cobalt77 »

Offline jacob428

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Help with superadmin death sound.
« Reply #2 on: December 17, 2013, 11:25:54 am »
There was an 'end' where the 'else' was suppose to be.

Code: Lua
  1. local admindeathsound = Sound( "sound/fail.wav" )
  2.  
  3. function PlayDeathSound( victim )
  4.  
  5. if not IsValid( victim ) then
  6.         return
  7. end
  8.  
  9. if victim:IsSuperAdmin() then
  10.         sound.Play( admindeathsound, victim:GetShootPos(), 90, 100 )  
  11. else
  12.         sound.Play( table.Random( deathsounds ), victim:GetShootPos(), 90, 100 )  
  13. end
  14.  
  15. end
  16.  

With this I get no sound on death, but still no errors. Do the wavs have to be somewhere special for sound.Play?

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Help with superadmin death sound.
« Reply #3 on: December 17, 2013, 11:28:36 am »
With this I get no sound on death, but still no errors. Do the wavs have to be somewhere special for sound.Play?
You have to put the file in the sound/ directory, run a websync/whatever fastdl thing you have, and do a resource.AddFile for the filename anywhere in lua/autorun
Just to be sure, you have this function hooked, right? I assumed you already had it hooked somewhere else in your file.

Offline jacob428

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Help with superadmin death sound.
« Reply #4 on: December 17, 2013, 11:36:05 am »
You have to put the file in the sound/ directory, run a websync/whatever fastdl thing you have, and do a resource.AddFile for the filename anywhere in lua/autorun
Just to be sure, you have this function hooked, right? I assumed you already had it hooked somewhere else in your file.

It is hooked, synced and resourced. The wav works fine with the ulx playsound command, but doesn't play on death.
« Last Edit: December 17, 2013, 11:55:00 am by jacob428 »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Help with superadmin death sound.
« Reply #5 on: December 17, 2013, 04:44:04 pm »
Reasonably sure Sound() and sound.Play default to the ./sound/ folder, yet, you have the folder specified in the variable.
I'm surprised you're not seeing a 'unable to precache file fail.wav' at client connect on the client side.
My theory, you're trying to play gmod/sound/sound/fail.wav when it should be gmod/sound/fail.wav
Try Sound( "fail.wav" ) instead of Sound( "sound/fail.wav" )
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline jacob428

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Help with superadmin death sound.
« Reply #6 on: December 17, 2013, 06:31:29 pm »
Reasonably sure Sound() and sound.Play default to the ./sound/ folder, yet, you have the folder specified in the variable.
I'm surprised you're not seeing a 'unable to precache file fail.wav' at client connect on the client side.
My theory, you're trying to play gmod/sound/sound/fail.wav when it should be gmod/sound/fail.wav
Try Sound( "fail.wav" ) instead of Sound( "sound/fail.wav" )

My friend, you've hit the nail on the head. Just changed sound/fail.wav to fail.wav and it works perfectly. Thank you so much!

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Help with superadmin death sound.
« Reply #7 on: December 17, 2013, 07:52:37 pm »
Welcome. Glad our community could be of assistance.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print