DatAmazingCheese

Looping Gun Sound Example

Jan 6th, 2019
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. @name Looping Gun Sound Example
  2. @inputs [Trigger] [Gun]:entity
  3. @outputs [Fire]
  4. @trigger [Trigger]
  5.  
  6. #- This code example is provided by DatAmazingCheese for use with the machine gun sound library from Tank Sound Pack, which is available here:
  7. #- https://steamcommunity.com/sharedfiles/filedetails/?id=906654112
  8.  
  9. SOUND_SHOT = "acf_tank_sound_pack/guns/mg_12mm_m2_loop.wav"
  10. SOUND_LASTSHOT = "acf_tank_sound_pack/guns/mg_12mm_m2_lastshot.wav"
  11. SOUND_SHELL = "acf_tank_sound_pack/guns/shells_12mm_loop.wav"
  12. SOUND_LASTSHELL = "acf_tank_sound_pack/guns/shells_12mm_single.wav"
  13.  
  14. if (first()|dupefinished()) {
  15. #- Playing sounds and silencing them.
  16. Gun:soundPlay("shot", 0, SOUND_SHOT)
  17. Gun:soundPlay("shell", 0, SOUND_SHELL)
  18. soundVolume("shot", 0)
  19. soundVolume("shell", 0)
  20. }
  21.  
  22. if (~Trigger & Trigger) {
  23. #- Unsilencing sounds when finger is on the trigger.
  24. Fire = 1
  25.  
  26. soundVolume("shot", 1)
  27. soundVolume("shell", 1)
  28. }
  29.  
  30. if (~Trigger & !Trigger) {
  31. #- Silencing sounds when finger is off the trigger.
  32. Fire = 0
  33.  
  34. Gun:soundPlay("lastshot", 1, SOUND_LASTSHOT)
  35. Gun:soundPlay("lastshell", 1, SOUND_LASTSHELL)
  36.  
  37. soundVolume("shot", 0)
  38. soundVolume("shell", 0)
  39. }
  40.  
  41. if (!Trigger) {
  42. Fire = 0
  43. }
Advertisement
Add Comment
Please, Sign In to add comment