Код
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "End Round Music"
#define VERSION "2.0"
#define AUTHOR "Eazy*"
new g_SizeLineTFile, g_SizeLineCTFile, SayText
new g_configfileT[128], g_configfileCT[128]
new g_checkErminf[33][32]
new logdate[64], logfile[64]
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")
register_cvar("amx_erm_autovol", "0.5")
register_cvar("amx_erm_radio", "1")
register_cvar("amx_erm_log", "1")
register_clcmd("say /musicon", "cmd_ermon", 0, " - turn on end round music")
register_clcmd("say /musicoff", "cmd_ermoff", 0, " - turn off end round music")
SayText = get_user_msgid("SayText");
return PLUGIN_CONTINUE
}
public plugin_precache()
{
new config[64]
get_configsdir(config, 63)
get_time("20%y.%m.%d", logdate, 63)
formatex(logfile, 63, "endroundmusicmp3_%s.log", logdate)
format(g_configfileT, 127, "%s/musicendround_t.ini", config)
format(g_configfileCT, 127, "%s/musicendround_ct.ini", config)
if(file_exists(g_configfileT) && file_exists(g_configfileCT))
{
g_SizeLineTFile = file_size(g_configfileT, 1)
g_SizeLineCTFile = file_size(g_configfileCT, 1)
}
else
{
server_print("[ERM MP3 ERROR] Could not find config file!")
if(get_cvar_num("amx_erm_log") == 1)
{
log_to_file(logfile, "[ERM MP3 ERROR] [Could not find config file!]")
log_to_file(logfile, "[ERM MP3 ERROR] [You should put musicendround_t.ini in addons/amxmodx/configs/]")
log_to_file(logfile, "[ERM MP3 ERROR] [You should put musicendround_ct.ini in addons/amxmodx/configs/]")
}
return PLUGIN_CONTINUE
}
new BufferFileName[160], len, index
index=0
while (read_file(g_configfileT, index, BufferFileName, sizeof(BufferFileName)-1, len) )
{
index++
precache_sound(BufferFileName)
}
index=0
while (read_file(g_configfileCT, index, BufferFileName, sizeof(BufferFileName)-1, len) )
{
index++
precache_sound(BufferFileName)
}
return PLUGIN_CONTINUE
}
public client_disconnect(id)
{
remove_task(id)
return PLUGIN_CONTINUE
}
public t_win()
{
new players[32], inum, id
new buffer[160],len
new random_line = random(g_SizeLineTFile)
read_file(g_configfileT, random_line, buffer, sizeof(buffer)-1, len)
get_players(players, inum, "c")
for(new a=0;a<inum;++a)
{
id=players[a]
if (equali(g_checkErminf[id],"ON"))
{
client_cmd(id,"stopsound")
client_cmd(id,"mp3 play sound/%s", buffer)
if(get_cvar_num("amx_erm_radio") == 1)
{
client_cmd(id, "spk radio/terwin")
}
}
}
if(get_cvar_num("amx_erm_log") == 1)
{
new map[32]
get_mapname(map, 31)
get_time("20%y.%m.%d", logdate, 63)
formatex(logfile, 63, "endroundmusicmp3_%s.log", logdate)
log_to_file(logfile, "[T PLAY] [%s] [%s] [%d] [%s]", buffer, g_configfileT, g_SizeLineTFile, map)
}
return PLUGIN_HANDLED
}
public ct_win()
{
new players[32], inum, id
new buffer[160],len
new random_line = random(g_SizeLineCTFile)
read_file(g_configfileCT, random_line, buffer, sizeof(buffer)-1, len)
get_players(players, inum, "c")
for(new a=0;a<inum;++a)
{
id=players[a]
if (equali(g_checkErminf[id],"ON"))
{
client_cmd(id,"stopsound")
client_cmd(id, "mp3 play sound/%s",buffer)
if(get_cvar_num("amx_erm_radio") == 1)
{
client_cmd(id, "spk radio/ctwin")
}
}
}
if(get_cvar_num("amx_erm_log") == 1)
{
new map[32]
get_mapname(map, 31)
get_time("20%y.%m.%d", logdate, 63)
formatex(logfile, 63, "endroundmusicmp3_%s.log", logdate)
log_to_file(logfile, "[CT PLAY] [%s] [%s] [%d] [%s]", buffer, g_configfileCT, g_SizeLineCTFile, map)
}
return PLUGIN_HANDLED
}
public cmd_ermon(id)
{
client_cmd(id, "setinfo erm ON")
g_checkErminf[id]= "ON"
client_cmd(id, "mp3volume %f", get_cvar_float("amx_erm_autovol"))
client_cmd(id, "spk vox/activated")
print_col_chat(id, "^1[^4Информация^1] Музыка в конце раунда ^4включена^1. ^3Наслаждайся :)");
if(get_cvar_num("amx_erm_log") == 1)
{
new map[32]
get_mapname(map, 31)
new name[32]
get_user_name(id, name, 31)
get_time("20%y.%m.%d", logdate, 63)
formatex(logfile, 63, "endroundmusicmp3_%s.log", logdate)
log_to_file(logfile, "[ERM MP3 ON] [%s] [%s]", name, map)
}
return PLUGIN_CONTINUE
}
public cmd_ermoff(id)
{
client_cmd(id, "setinfo erm OFF")
g_checkErminf[id]= "OFF"
client_cmd(id, "mp3 stop")
client_cmd(id, "spk vox/deactivated")
print_col_chat(id, "^1[^4Информация^1] Музыка в конце раунда ^3выключена^1. ^3:(");
if(get_cvar_num("amx_erm_log") == 1)
{
new map[32]
get_mapname(map, 31)
new name[32]
get_user_name(id, name, 31)
get_time("20%y.%m.%d", logdate, 63)
formatex(logfile, 63, "endroundmusicmp3_%s.log", logdate)
log_to_file(logfile, "[ERM MP3 OFF] [%s] [%s]", name, map)
}
return PLUGIN_CONTINUE
}
stock print_col_chat(const id, const input[], any:...)
{
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!g", "^4"); // зеленый цвет чата
replace_all(msg, 190, "!y", "^1"); // обычный цвет чата (желтый)
replace_all(msg, 190, "!t", "^3"); // комадный цвет чата (КТ - синий, ТТ - красный)
if (id) players[0] = id; else get_players(players, count, "ch");
{
for ( new i = 0; i < count; i++ )
{
if ( is_user_connected(players[i]) )
{
message_begin(MSG_ONE_UNRELIABLE, SayText, _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
public client_putinserver(id)
{
client_cmd(id, "setinfo erm ON")
g_checkErminf[id]= "ON"
client_cmd(id, "mp3volume %f", get_cvar_float("amx_erm_autovol"))
}