#include <amxmodx>
#include <amxmisc>
#define Plugin "End Round Sounds"
#define Version "1.2"
#define Author "Doombringer"
#define MAX_SOUNDS 132
#define T 0
#define CT 1
new t_sounds[MAX_SOUNDS][92], ct_sounds[MAX_SOUNDS][92], num_of_sounds[2]
new bool:is_wav[MAX_SOUNDS][2], bool:has_sounds_enabled[32]
new cvar, ads_time, toggle_allowed, message_mode
public plugin_init()
{
register_plugin(Plugin, Version, Author)
register_event("SendAudio", "t_win", "a", "2&%!MRAD_terwin")
register_event("SendAudio", "ct_win", "a", "2&%!MRAD_ctwin")
cvar = register_cvar("ES_enabled", "1")
ads_time = register_cvar("ES_ads_time", "145")
toggle_allowed = register_cvar("ES_toggle_allowed", "1")
message_mode = register_cvar("ES_message_mode", "2")
register_clcmd("say /sounds", "cmd_toggle")
register_clcmd("say_team /sounds", "cmd_toggle")
set_task(get_pcvar_float(ads_time), "show_ad")
}
public client_putinserver(id) has_sounds_enabled[id] = true
public print_client(id, arg[], { Float, Sql, Result, _ }:...)
{
new args[94]
vformat(args, 93, arg, 3)
if(get_pcvar_num(message_mode) == 2)
{
new message[94]
formatex(message, 93, "^x04[ERS] ^x01%s", args)
if(id)
{
message_begin(MSG_ONE, get_user_msgid("SayText"), _, id)
write_byte(id)
write_string(message)
message_end()
}
else
{
new players[32], num
get_players(players, num)
new player
for(new i = 0; i < num; i++)
{
player = players[i]
message_begin(MSG_ONE, get_user_msgid("SayText"), _, player)
write_byte(player)
write_string(message)
message_end()
}
}
}
else if(get_pcvar_num(message_mode) == 1)
{
set_hudmessage(170, 212, 255, -1.0, 0.32, 0, 2.0, 6.0)
show_hudmessage(id, "%s", args)
}
else
{
client_print(id, print_chat, "%s", args)
}
}
public show_ad()
{
if(!get_pcvar_num(ads_time))
return
print_client(0, "%L", LANG_SERVER, "AD")
set_task(get_pcvar_float(ads_time), "show_ad")
}
public cmd_toggle(id)
{
if(!get_pcvar_num(toggle_allowed))
{
print_client(id, "%L", id, "TOGGLE_DISABLED")
return PLUGIN_CONTINUE
}
has_sounds_enabled[id] = has_sounds_enabled[id] ? false:true
print_client(id, "%L", id, !has_sounds_enabled[id] ? "TOGGLE_OFF":"TOGGLE_ON", Plugin)
return PLUGIN_CONTINUE
}
stock sound_exists(file[])
{
new temp[92]
format(temp, 91, "sound/%s", file)
return file_exists(temp)
}
stock map_file_exists(path[])
{
new temp[92]
new map[32]
get_mapname(map, 31)
format(temp, 131, "%s/round_sounds/%s.ini", path, map)
return file_exists(temp)
}
public load_sounds()
{
new path[132]
get_configsdir(path, 131)
if(map_file_exists(path))
{
new map[32]
get_mapname(map, 31)
format(path, 131, "%s/round_sounds/%s.ini", path, map)
}
else
format(path, 131, "%s/sounds.ini", path)
new file = fopen(path, "rt")
if(!file)
{
server_print("%L", LANG_SERVER, "ERROR", Plugin)
return PLUGIN_CONTINUE
}
new text[95], t_team[3], t_path[92]
while(!feof(file))
{
fgets(file, text, 94)
if(!text[0] || text[0] == ';')
continue
parse(text, t_team, 2, t_path, 91)
if(!sound_exists(t_path))
{
server_print("%L", LANG_SERVER, "NOT_FOUND", Plugin, t_path)
continue
}
if(equali(t_team, "CT"))
{
ct_sounds[++num_of_sounds[CT]] = t_path
is_wav[num_of_sounds[CT]][CT] = containi(t_path, ".wav") != -1 ? true:false
}
else if(equali(t_team, "T"))
{
t_sounds[++num_of_sounds[T]] = t_path
is_wav[num_of_sounds[T]][T] = containi(t_path, ".wav") != -1 ? true:false
}
else
{
server_print("%L", LANG_SERVER, "INVALID_TAG", Plugin, t_path)
continue
}
}
fclose(file)
server_print("%L", LANG_SERVER, "LOAD_SUCCESS", Plugin, num_of_sounds[T], num_of_sounds[CT], num_of_sounds[T] + num_of_sounds[CT])
return PLUGIN_CONTINUE
}
play_sound(team)
{
new players[32], num
get_players(players, num, "c")
new player, sound_num = random_num(1, num_of_sounds[team])
for(new i = 0; i < num; i++)
{
player = players[i]
if(!has_sounds_enabled[player])
continue
client_cmd(player, "stopsound")
client_cmd(player, is_wav[sound_num][team] ? "spk %s" : "mp3 play sound/%s", team == T ? t_sounds[sound_num]:ct_sounds[sound_num])
}
}
public t_win()
{
if(!get_pcvar_num(cvar))
return
play_sound(T)
}
public ct_win()
{
if(!get_pcvar_num(cvar))
return
play_sound(CT)
}
public plugin_precache()
{
register_dictionary("roundsounds.txt")
load_sounds()
for(new i = 0; i < num_of_sounds[T] + num_of_sounds[CT]; ++i)
{
//precache_sound(strlen(sounds[i][CT]) ? sounds[i][CT]:sounds[i][T])
if(ct_sounds[i][0])
{
is_wav[i][CT] ? precache_sound(ct_sounds[i]) : precache_generic(ct_sounds[i])
server_print("%L", LANG_SERVER, "PRECACHED", Plugin, ct_sounds[i])
}
if(t_sounds[i][0])
{
is_wav[i][T] ? precache_sound(t_sounds[i]) : precache_generic(t_sounds[i])
server_print("%L", LANG_SERVER, "PRECACHED", Plugin, t_sounds[i])
}
}
}
und wie? hab das hier drauf
http://forums.alliedmods.net/showthr...d+Round+Sounds