Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. #pragma semicolon 1
  2.  
  3. #include <sourcemod>
  4. #include <sdktools>
  5. #include <emitsoundany>
  6.  
  7. #include <timer>
  8. #include <timer-logging>
  9.  
  10. #define MAX_FILE_LEN 128
  11.  
  12. new Handle:Sound_TimerFinish = INVALID_HANDLE;
  13. new String:SND_TIMER_FINISH[MAX_FILE_LEN];
  14.  
  15. new Handle:Sound_TimerResume = INVALID_HANDLE;
  16. new String:SND_TIMER_RESUME[MAX_FILE_LEN];
  17.  
  18. new Handle:Sound_TimerPause = INVALID_HANDLE;
  19. new String:SND_TIMER_PAUSE[MAX_FILE_LEN];
  20.  
  21. new Handle:Sound_TimerWorldRecord = INVALID_HANDLE;
  22. new String:SND_TIMER_WORLDRECORD[MAX_FILE_LEN];
  23.  
  24. new Handle:Sound_TimerWorldRecordAll = INVALID_HANDLE;
  25. new String:SND_TIMER_WORLDRECORD_ALL[MAX_FILE_LEN];
  26.  
  27. new Handle:Sound_TimerPersonalBest = INVALID_HANDLE;
  28. new String:SND_TIMER_PERSONALBEST[MAX_FILE_LEN];
  29.  
  30. public Plugin:myinfo =
  31. {
  32. name = "[TIMER] Sounds",
  33. author = "Zipcore, Jason Bourne, DR. API Improvements",
  34. description = "[Timer] Sounds for timer events",
  35. version = PL_VERSION,
  36. url = "forums.alliedmods.net/showthread.php?p=2074699"
  37. };
  38.  
  39. public OnPluginStart()
  40. {
  41. Sound_TimerFinish = CreateConVar("timer_sound_finish", "ui/freeze_cam.wav", "");
  42. Sound_TimerWorldRecord = CreateConVar("timer_sound_worldrecord", "ui/freeze_cam.wav", "");
  43. Sound_TimerWorldRecordAll = CreateConVar("timer_sound_worldrecord_all", "ui/freeze_cam.wav", "");
  44. Sound_TimerPause = CreateConVar("timer_sound_pause", "ui/freeze_cam.wav", "");
  45. Sound_TimerResume = CreateConVar("timer_sound_resume", "ui/freeze_cam.wav", "");
  46. Sound_TimerPersonalBest = CreateConVar("timer_sound_personalbest", "ui/freeze_cam.wav", "");
  47.  
  48. AutoExecConfig(true, "timer/timer-sounds");
  49. }
  50.  
  51. public OnConfigsExecuted()
  52. {
  53. CacheSounds();
  54. Timer_LogTrace("[Sound] Sounds cached OnConfigsExecuted");
  55. }
  56.  
  57. public CacheSounds()
  58. {
  59. GetConVarString(Sound_TimerFinish, SND_TIMER_FINISH, sizeof(SND_TIMER_FINISH));
  60. PrepareSound(SND_TIMER_FINISH);
  61.  
  62. GetConVarString(Sound_TimerPause, SND_TIMER_PAUSE, sizeof(SND_TIMER_PAUSE));
  63. PrepareSound(SND_TIMER_PAUSE);
  64.  
  65. GetConVarString(Sound_TimerResume, SND_TIMER_RESUME, sizeof(SND_TIMER_RESUME));
  66. PrepareSound(SND_TIMER_FINISH);
  67.  
  68. GetConVarString(Sound_TimerWorldRecord, SND_TIMER_WORLDRECORD, sizeof(SND_TIMER_WORLDRECORD));
  69. PrepareSound(SND_TIMER_WORLDRECORD);
  70.  
  71. GetConVarString(Sound_TimerWorldRecordAll, SND_TIMER_WORLDRECORD_ALL, sizeof(SND_TIMER_WORLDRECORD_ALL));
  72. PrepareSound(SND_TIMER_WORLDRECORD_ALL);
  73.  
  74. GetConVarString(Sound_TimerPersonalBest, SND_TIMER_PERSONALBEST, sizeof(SND_TIMER_PERSONALBEST));
  75. PrepareSound(SND_TIMER_PERSONALBEST);
  76. }
  77.  
  78. public PrepareSound(String: sound[MAX_FILE_LEN])
  79. {
  80. decl String:fileSound[MAX_FILE_LEN];
  81.  
  82. FormatEx(fileSound, MAX_FILE_LEN, "sound/%s", sound);
  83.  
  84. if (FileExists(fileSound))
  85. {
  86. PrecacheSoundAny(sound, true);
  87. AddFileToDownloadsTable(fileSound);
  88. Timer_LogTrace("[Sound] File '%s' added to downloads table.", fileSound);
  89. }
  90. }
  91.  
  92. public OnTimerPaused(client)
  93. {
  94. EmitSoundToClientAny(client, SND_TIMER_PAUSE);
  95. }
  96.  
  97. public OnTimerResumed(client)
  98. {
  99. EmitSoundToClientAny(client, SND_TIMER_RESUME);
  100. }
  101.  
  102. public OnTimerWorldRecord(client)
  103. {
  104. //Stop the sound first
  105. EmitSoundToAllAny(SND_TIMER_WORLDRECORD_ALL, _, _, _, SND_STOPLOOPING);
  106.  
  107. EmitSoundToAllAny(SND_TIMER_WORLDRECORD_ALL);
  108. }
  109.  
  110. public OnTimerPersonalRecord(client)
  111. {
  112. EmitSoundToClientAny(client, SND_TIMER_PERSONALBEST);
  113. }
  114.  
  115. public OnTimerRecord(client)
  116. {
  117. EmitSoundToClientAny(client, SND_TIMER_FINISH);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement