Advertisement
Sugisaki

[DRS] Dynamic End Round Sound

Aug 14th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.51 KB | None | 0 0
  1. #include <amxmodx>
  2.  
  3. #define PLUGIN  "Dynamic End Round Sound"
  4. #define VERSION "1.0"
  5. #define AUTHOR  "Sugisaki"
  6.  
  7. #define SND_FOLDER  "mismusicas"
  8.  
  9. new Array:a_sound_tt
  10. new Array:a_sount_ct
  11.  
  12. new i_MaxPlayers
  13. new bool:b_listen[33]
  14.  
  15. public plugin_init()
  16. {
  17.     register_plugin(PLUGIN, VERSION, AUTHOR)
  18.     register_event("SendAudio", "win_ct", "a", "2&%!MRAD_ctwin")
  19.     register_event("SendAudio", "win_tt", "a", "2&%!MRAD_terwin")
  20.     register_clcmd("say /roundsound", "pfn_toggle_music")
  21.     i_MaxPlayers = get_maxplayers()
  22. }
  23. public client_putinserver(id)
  24. {
  25.     b_listen[id] = true
  26. }
  27. public pfn_toggle_music(id)
  28. {
  29.     b_listen[id] = !b_listen[id]
  30.     client_print(id, print_chat, "[DRS] Has %sactivado los sonidos de final de ronda", b_listen[id] == true ? "" : "des")
  31. }
  32. stock bool:check(file[])
  33. {
  34.     if(equal(file[strlen(file) - 3], "mp3"))
  35.         return true
  36.     return false
  37. }
  38. stock file_team_check(file[])
  39. {
  40.     if(file[0] == 't')
  41.         return 1
  42.     else if(file[0] == 'c' && file[1] == 't')
  43.         return 2
  44.     return 0
  45.  
  46. }
  47. stock PlayMusic(Array:which)
  48. {
  49.     new rand = random_num(0, ArraySize(which) - 1)
  50.     for(new i = 1 ; i <= i_MaxPlayers; i++)
  51.     {
  52.         if(!is_user_connected(i) || !b_listen[i])
  53.             continue;
  54.         client_cmd(i, "mp3 play ^"sound/%s/%a^"", SND_FOLDER, ArrayGetStringHandle(which, rand))
  55.     }
  56. }
  57. public plugin_precache()
  58. {
  59.     new temp[32], dh, file[64]
  60.     a_sound_tt = ArrayCreate(40)
  61.     a_sount_ct = ArrayCreate(40)
  62.  
  63.     formatex(temp, charsmax(temp), "sound/%s", SND_FOLDER)
  64.     dh = open_dir(temp, file, charsmax(file))
  65.  
  66.     while(next_file(dh, file, charsmax(file)))
  67.     {
  68.         if(!file[0] || !check(file))
  69.             continue
  70.  
  71.         switch(file_team_check(file))
  72.         {
  73.             case 0 :
  74.             {
  75.                 //format(file, charsmax(file), "%s/%s", temp, file)
  76.                 ArrayPushString(a_sount_ct, file)
  77.                 ArrayPushString(a_sound_tt, file)
  78.             }
  79.             case 1 :
  80.             {
  81.                 //format(file, charsmax(file), "%s/%s", temp, file)
  82.                 ArrayPushString(a_sound_tt, file)
  83.             }
  84.             case 2 :
  85.             {
  86.                 //format(file, charsmax(file), "%s/%s", temp, file)
  87.                 ArrayPushString(a_sount_ct, file)
  88.             }
  89.         }
  90.         format(file, charsmax(file), "%s/%s", temp, file)
  91.         precache_generic(file)
  92.  
  93.     }
  94.     close_dir(dh)
  95.    
  96. }
  97. public plugin_end()
  98. {
  99.     ArrayDestroy(a_sound_tt)
  100.     ArrayDestroy(a_sount_ct)
  101. }
  102. public win_ct()
  103. {
  104.     //new temp[32]
  105.     //ArrayGetString(a_sount_ct, random_num(0, ArraySize(a_sount_ct) - 1), temp, charsmax(temp))
  106.     PlayMusic(a_sount_ct)
  107. }
  108. public win_tt()
  109. {
  110.     //new temp[32]
  111.     //ArrayGetString(a_sound_tt, random_num(0, ArraySize(a_sound_tt) - 1), temp, charsmax(temp))
  112.     PlayMusic(a_sound_tt)
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement