KOD SMA
#include <amxmodx>
#include <amxmisc>
new PLUGIN[]="EndRoundSoundsMP3"
new AUTHOR[]="ntfs & Sn!ff3r"
new VERSION[]="1.0"
new soundfile[128]
new cached
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar("endroundsounds", VERSION, FCVAR_SERVER)
register_event("SendAudio", "soundplay", "a", "2&%!MRAD_terwin")
register_event("SendAudio", "soundplay", "a", "2&%!MRAD_ctwin")
}
public plugin_precache()
{
new txtlen
new loop
new line
new config[64]
get_configsdir(config, 63)
format(config, 63, "%s/endroundsounds.cfg", config)
new lines = file_size(config, 1)
if (file_exists(config))
{
while(cached != 1 && loop < 10)
{
line = random_num(0,lines)
read_file(config,line,soundfile,128,txtlen)
if(containi(soundfile,".mp3") != -1)
{
if((file_exists(soundfile) == 1) && (equal(soundfile[0],";",1) != 1))
{
precache_generic(soundfile)
server_print("[AMX] Przetwarzanie ^"%s^".", soundfile)
cached = 1
}
else
server_print("[AMX] Pomijanie ^"%s^".", soundfile)
}
loop += 1
}
}
else
write_file(config,"",-1)
}
public soundplay()
{
if(cached == 1)
client_cmd(0, "mp3 play %s", soundfile)
else
server_print("[AMX] Brak plikow dzwiekowych!")
}