Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #define PLUGIN "Dynamic End Round Sound"
- #define VERSION "1.0"
- #define AUTHOR "Sugisaki"
- #define SND_FOLDER "mismusicas"
- new Array:a_sound_tt
- new Array:a_sount_ct
- new i_MaxPlayers
- new bool:b_listen[33]
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- register_event("SendAudio", "win_ct", "a", "2&%!MRAD_ctwin")
- register_event("SendAudio", "win_tt", "a", "2&%!MRAD_terwin")
- register_clcmd("say /roundsound", "pfn_toggle_music")
- i_MaxPlayers = get_maxplayers()
- }
- public client_putinserver(id)
- {
- b_listen[id] = true
- }
- public pfn_toggle_music(id)
- {
- b_listen[id] = !b_listen[id]
- client_print(id, print_chat, "[DRS] Has %sactivado los sonidos de final de ronda", b_listen[id] == true ? "" : "des")
- }
- stock bool:check(file[])
- {
- if(equal(file[strlen(file) - 3], "mp3"))
- return true
- return false
- }
- stock file_team_check(file[])
- {
- if(file[0] == 't')
- return 1
- else if(file[0] == 'c' && file[1] == 't')
- return 2
- return 0
- }
- stock PlayMusic(Array:which)
- {
- new rand = random_num(0, ArraySize(which) - 1)
- for(new i = 1 ; i <= i_MaxPlayers; i++)
- {
- if(!is_user_connected(i) || !b_listen[i])
- continue;
- client_cmd(i, "mp3 play ^"sound/%s/%a^"", SND_FOLDER, ArrayGetStringHandle(which, rand))
- }
- }
- public plugin_precache()
- {
- new temp[32], dh, file[64]
- a_sound_tt = ArrayCreate(40)
- a_sount_ct = ArrayCreate(40)
- formatex(temp, charsmax(temp), "sound/%s", SND_FOLDER)
- dh = open_dir(temp, file, charsmax(file))
- while(next_file(dh, file, charsmax(file)))
- {
- if(!file[0] || !check(file))
- continue
- switch(file_team_check(file))
- {
- case 0 :
- {
- //format(file, charsmax(file), "%s/%s", temp, file)
- ArrayPushString(a_sount_ct, file)
- ArrayPushString(a_sound_tt, file)
- }
- case 1 :
- {
- //format(file, charsmax(file), "%s/%s", temp, file)
- ArrayPushString(a_sound_tt, file)
- }
- case 2 :
- {
- //format(file, charsmax(file), "%s/%s", temp, file)
- ArrayPushString(a_sount_ct, file)
- }
- }
- format(file, charsmax(file), "%s/%s", temp, file)
- precache_generic(file)
- }
- close_dir(dh)
- }
- public plugin_end()
- {
- ArrayDestroy(a_sound_tt)
- ArrayDestroy(a_sount_ct)
- }
- public win_ct()
- {
- //new temp[32]
- //ArrayGetString(a_sount_ct, random_num(0, ArraySize(a_sount_ct) - 1), temp, charsmax(temp))
- PlayMusic(a_sount_ct)
- }
- public win_tt()
- {
- //new temp[32]
- //ArrayGetString(a_sound_tt, random_num(0, ArraySize(a_sound_tt) - 1), temp, charsmax(temp))
- PlayMusic(a_sound_tt)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement