Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <sdkhooks>
  4.  
  5. bool OnMusic[64] = {true, ...};
  6.  
  7. char g_sSounds[][] =
  8. {
  9. "ideas/ambient/casapapell.mp3",
  10. "ideas/ambient/funkk.mp3",
  11. "ideas/ambient/marvell.mp3",
  12. "ideas/ambient/gogg3.mp3",
  13. "ideas/ambient/funkk.mp3",
  14. "ideas/ambient/gogg.mp3",
  15. "ideas/ambient/gogg2.mp3",
  16. "ideas/ambient/marvell2.mp3",
  17. "ideas/ambient/marvell4.mp3",
  18. }
  19.  
  20. public void OnPluginStart()
  21. {
  22. HookEvent("round_start", OnRoundStart);
  23. RegConsoleCmd("sm_music", sm_music)
  24. }
  25.  
  26. public Action sm_music(client, args)
  27. {
  28. OnMusic[client] = !OnMusic[client];
  29. PrintToChat(client, "[IDEAS] \x07 You turned %s music for the next rounds !", OnMusic[client] ? "on":"off");
  30. }
  31.  
  32. public void OnMapStart()
  33. {
  34. for(int i = 0; i < sizeof(g_sSounds); i++)
  35. {
  36. AddFileToDownloadsTable("sound/ideas/ambient/casapapell.mp3")
  37. AddFileToDownloadsTable("sound/ideas/ambient/funkk.mp3")
  38. AddFileToDownloadsTable("sound/ideas/ambient/funkk2.mp3")
  39. AddFileToDownloadsTable("sound/ideas/ambient/gogg.mp3")
  40. AddFileToDownloadsTable("sound/ideas/ambient/gogg2.mp3")
  41. AddFileToDownloadsTable("sound/ideas/ambient/gogg3.mp3")
  42. AddFileToDownloadsTable("sound/ideas/ambient/marvell.mp3")
  43. AddFileToDownloadsTable("sound/ideas/ambient/marvell2.mp3")
  44. AddFileToDownloadsTable("sound/ideas/ambient/marvell4.mp3")
  45.  
  46. PrecacheSound(g_sSounds[i], true); // Precache sound file...
  47. }
  48. }
  49. public Action OnRoundStart(Event event, const char[] name, bool db)
  50. {
  51. CreateTimer(1.0, tTimerRandomSound, _, TIMER_FLAG_NO_MAPCHANGE); // Start a timer on every map start that ends when map ends.
  52. }
  53.  
  54. public Action tTimerRandomSound(Handle timer)
  55. {
  56. // void EmitSoundToAll(const char[] sample, int entity, int channel, int level, int flags, float volume, int pitch, int speakerentity, const float origin[3], const float dir[3], bool updatePos, float soundtime)
  57. int random = GetRandomInt(0, sizeof(g_sSounds)-1);
  58. for (int i = 1; i <= MaxClients; i++)
  59. {
  60. if(!IsClientInGame(i) || !OnMusic[i]) continue;
  61. EmitSoundToClient(i, g_sSounds[random], _, _, _, _, 0.4);
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement