Comparing sensitive data, confidential files or internal emails?

Most legal and privacy policies prohibit uploading sensitive data online. Diffchecker Desktop ensures your confidential information never leaves your computer. Work offline and compare documents securely.

Untitled diff

Created Diff never expires
12 removals
340 lines
117 additions
439 lines
#include <amxmodx>
#include <amxmodx>
#include <amxmisc>
#include <amxmisc>


#define PLUGIN "End Round Music"
#define PLUGIN "End Round Music"
#define VERSION "2.0"
#define VERSION "2.0"
#define AUTHOR "Sho0ter"
#define AUTHOR "Sho0ter"


#define TRACKSNUM 100
#define TRACKSNUM 100


new ALLMusic[TRACKSNUM][128]
new ALLMusic[TRACKSNUM][128]
new CTMusic[TRACKSNUM][128]
new CTMusic[TRACKSNUM][128]
new TMusic[TRACKSNUM][128]
new TMusic[TRACKSNUM][128]
new DRAWMusic[TRACKSNUM][128]


new PlaylistSize
new PlaylistSize
new CTNum
new CTNum
new TNum
new TNum
new DRAWNum
new ALLNum
new ALLNum
new SayText
new SayText


new Mode[32]
new Mode[32]
new Configsdir[64]
new Configsdir[64]
new CurrentMap[64]
new CurrentMap[64]
new File[96]
new File[96]
new Playlist[128]
new Playlist[128]
new Play[128]
new Play[128]
new PlayCommand[128]
new PlayCommand[128]
new CheckFile[128]
new CheckFile[128]


new bool:Ermon[33]
new bool:Ermon[33]


new PcvarMode
new PcvarMode
new PcvarVol
new PcvarVol
new PcvarRadio
new PcvarRadio
new PcvarDelay
new PcvarDelay


public plugin_init()
public plugin_init()
{
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_plugin(PLUGIN, VERSION, AUTHOR)
register_dictionary("endroundmusic.txt")
register_dictionary("endroundmusic.txt")
register_event("SendAudio", "t_win", "a", "2&%!MRAD_terwin")
register_event("SendAudio", "t_win", "a", "2&%!MRAD_terwin")
register_event("SendAudio", "ct_win", "a", "2&%!MRAD_ctwin")
register_event("SendAudio", "ct_win", "a", "2&%!MRAD_ctwin")
PcvarMode = register_cvar("erm_mode", "1")
register_event("SendAudio", "draw", "a", "2&%!MRAD_rounddraw")
PcvarVol = register_cvar("erm_autovol", "0.5")
PcvarMode = register_cvar("erm_mode", "2")
PcvarVol = register_cvar("erm_autovol", "1.0")
PcvarRadio = register_cvar("erm_radio", "1")
PcvarRadio = register_cvar("erm_radio", "1")
PcvarDelay = register_cvar("erm_delay", "20.0")
PcvarDelay = register_cvar("erm_delay", "20.0")
register_clcmd("say /ermon", "cmd_ermon", 0, " - turn on end round music")
register_clcmd("say /ermon", "cmd_ermon", 0, " - turn on end round music")
register_clcmd("say /ermoff", "cmd_ermoff", 0, " - turn off end round music")
register_clcmd("say /ermoff", "cmd_ermoff", 0, " - turn off end round music")
SayText = get_user_msgid("SayText");
SayText = get_user_msgid("SayText");
return PLUGIN_CONTINUE
return PLUGIN_CONTINUE
}
}


public plugin_precache()
public plugin_precache()
{
{
get_configsdir(Configsdir, 63)
get_configsdir(Configsdir, 63)
get_mapname(CurrentMap, 63)
get_mapname(CurrentMap, 63)
formatex(Playlist, 127, "%s/endroundmusic/%s.ini", Configsdir, CurrentMap)
formatex(Playlist, 127, "%s/endroundmusic/%s.ini", Configsdir, CurrentMap)
new Index = 0
new Index = 0
while(CurrentMap[Index] != '_' && CurrentMap[Index] != '^0')
while(CurrentMap[Index] != '_' && CurrentMap[Index] != '^0')
{
{
Index++
Index++
}
}
if(!file_exists(Playlist) && CurrentMap[Index] == '_')
if(!file_exists(Playlist) && CurrentMap[Index] == '_')
{
{
CurrentMap[Index] = '^0'
CurrentMap[Index] = '^0'
formatex(Playlist, 127, "%s/endroundmusic/%s_.ini", Configsdir, CurrentMap)
formatex(Playlist, 127, "%s/endroundmusic/%s_.ini", Configsdir, CurrentMap)
}
}
if(!file_exists(Playlist))
if(!file_exists(Playlist))
{
{
formatex(Playlist, 127, "%s/endroundmusic/default.ini", Configsdir)
formatex(Playlist, 127, "%s/endroundmusic/default.ini", Configsdir)
}
}
if(!file_exists(Playlist))
if(!file_exists(Playlist))
{
{
log_amx("Playlist <%s> not found.", Playlist)
log_amx("Playlist <%s> not found.", Playlist)
set_fail_state("Playlist not found")
set_fail_state("Playlist not found")
return PLUGIN_CONTINUE
return PLUGIN_CONTINUE
}
}
PlaylistSize = file_size(Playlist, 1)
PlaylistSize = file_size(Playlist, 1)
for(new i = 0; i <= PlaylistSize; i++)
for(new i = 0; i <= PlaylistSize; i++)
{
{
new Buffer[128], len, Result
new Buffer[128], len, Result
Result = read_file(Playlist, i, Buffer, sizeof(Buffer)-1, len)
Result = read_file(Playlist, i, Buffer, sizeof(Buffer)-1, len)
if(!Result)
if(!Result)
{
{
continue
continue
}
}
parse(Buffer, File, 95, Mode, 31)
parse(Buffer, File, 95, Mode, 31)
if(File[0] == ';' || File[0] == '/' || File[0] == ' ' || equal(File, ""))
if(File[0] == ';' || File[0] == '/' || File[0] == ' ' || equal(File, ""))
{
{
continue
continue
}
}
formatex(CheckFile, 127, "sound/%s", File)
formatex(CheckFile, 127, "sound/%s", File)
if(!file_exists(CheckFile))
if(!file_exists(CheckFile))
{
{
log_amx("File not found <%s>", CheckFile)
log_amx("File not found <%s>", CheckFile)
continue
continue
}
}
if(equal(Mode, "CT"))
if(equal(Mode, "CT"))
{
{
formatex(CTMusic[CTNum], 127, "%s", File)
formatex(CTMusic[CTNum], 127, "%s", File)
CTNum++
CTNum++
precache_sound(File)
precache_sound(File)
}
}
else if(equal(Mode, "TER"))
else if(equal(Mode, "TER"))
{
{
formatex(TMusic[TNum], 127, "%s", File)
formatex(TMusic[TNum], 127, "%s", File)
TNum++
TNum++
precache_sound(File)
precache_sound(File)
}
}
else if(equal(Mode, "ALL"))
else if(equal(Mode, "ALL"))
{
{
formatex(ALLMusic[ALLNum], 127, "%s", File)
formatex(ALLMusic[ALLNum], 127, "%s", File)
ALLNum++
ALLNum++
precache_sound(File)
precache_sound(File)
}
}
else if(equal(Mode, "DRAW"))
{
formatex(ALLMusic[DRAWNum], 127, "%s", File)
DRAWNum++
precache_sound(File)
}
}
}
if(CTNum == 0 && TNum == 0 && ALLNum == 0)
if(CTNum == 0 && TNum == 0 && DRAWNum == 0 && ALLNum == 0)
{
{
log_amx("Not found tracks in playlist.")
log_amx("Not found tracks in playlist.")
set_fail_state("Playlist empty")
set_fail_state("Playlist empty")
return PLUGIN_CONTINUE
return PLUGIN_CONTINUE
}
}
log_amx("Loaded tracks: CT <%d> TER <%d> ALL <%d>", CTNum, TNum, ALLNum)
log_amx("Loaded tracks: CT <%d> TER <%d> DRAW <%d> ALL <%d>", CTNum, TNum, DRAWNum, ALLNum)
return PLUGIN_CONTINUE
return PLUGIN_CONTINUE
}
}


public client_disconnect(id)
public client_disconnect(id)
{
{
remove_task(id)
remove_task(id)
return PLUGIN_CONTINUE
return PLUGIN_CONTINUE
}
}


public client_putinserver(id)
public client_putinserver(id)
{
{
set_task(get_pcvar_float(PcvarDelay), "showerminfo", id)
set_task(get_pcvar_float(PcvarDelay), "showerminfo", id)
return PLUGIN_HANDLED
return PLUGIN_HANDLED
}
}



public t_win()
public t_win()
{
{
if(!get_pcvar_num(PcvarMode))
if(!get_pcvar_num(PcvarMode))
{
{
return PLUGIN_HANDLED
return PLUGIN_HANDLED
}
}
if((!CTNum || !TNum) && ALLNum && get_pcvar_num(PcvarMode) != 2)
{
set_pcvar_num(PcvarMode, 2)
}
switch(get_pcvar_num(PcvarMode))
switch(get_pcvar_num(PcvarMode))
{
{
case 1:
case 1:
{
{
formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
}
}
case 2:
case 2:
{
{
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
}
}
case 3:
case 3:
{
{
new Randomizer = random_num(1, 2)
new Randomizer = random_num(1, 2)
switch(Randomizer)
switch(Randomizer)
{
{
case 1:
case 1:
{
{
formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
}
}
case 2:
case 2:
{
{
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
}
}
}
}
}
}
case 4:
case 4:
{
{
new Randomizer = random_num(1, 3)
new Randomizer = random_num(1, 4)
switch(Randomizer)
switch(Randomizer)
{
{
case 1:
case 1:
{
{
formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
}
}
case 2:
case 2:
{
{
formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
}
}
case 3:
case 3:
{
{
formatex(Play, 127, "%s", DRAWMusic[random_num(0, ALLNum-1)])
}
case 4:
{
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
}
}
}
}
}
}
}
}
if(containi(Play, ".wav") != -1)
if(containi(Play, ".wav") != -1)
{
{
formatex(PlayCommand, 127, "spk %s", Play)
formatex(PlayCommand, 127, "spk %s", Play)
}
}
else if(containi(Play, ".mp3") != -1)
else if(containi(Play, ".mp3") != -1)
{
{
formatex(PlayCommand, 127, "mp3 play sound/%s", Play)
formatex(PlayCommand, 127, "mp3 play sound/%s", Play)
}
}
else
else
{
{
log_amx("Unsupported file type <%s>", Play)
log_amx("Unsupported file type <%s>", Play)
return PLUGIN_HANDLED
return PLUGIN_HANDLED
}
}
for(new id = 0; id <= get_maxplayers(); id++)
for(new id = 0; id <= get_maxplayers(); id++)
{
{
if(!is_user_connected(id) || !Ermon[id])
if(!is_user_connected(id) || !Ermon[id])
{
{
continue
continue
}
}
client_cmd(id, "stopsound")
client_cmd(id, "stopsound")
client_cmd(id, "%s", PlayCommand)
client_cmd(id, "%s", PlayCommand)
if(get_pcvar_num(PcvarRadio))
if(get_pcvar_num(PcvarRadio))
{
{
client_cmd(id, "spk radio/terwin")
client_cmd(id, "spk radio/terwin")
}
}
}
}
return PLUGIN_HANDLED
return PLUGIN_HANDLED
}
}



public ct_win()
public ct_win()
{
{
if(!get_pcvar_num(PcvarMode))
if(!get_pcvar_num(PcvarMode))
{
{
return PLUGIN_HANDLED
return PLUGIN_HANDLED
}
}
if((!CTNum || !TNum) && ALLNum && get_pcvar_num(PcvarMode) != 2)
{
set_pcvar_num(PcvarMode, 2)
}
switch(get_pcvar_num(PcvarMode))
switch(get_pcvar_num(PcvarMode))
{
{
case 1:
case 1:
{
{
formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
}
}
case 2:
case 2:
{
{
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
}
}
case 3:
case 3:
{
{
new Randomizer = random_num(1, 2)
new Randomizer = random_num(1, 2)
switch(Randomizer)
switch(Randomizer)
{
{
case 1:
case 1:
{
{
formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
}
}
case 2:
case 2:
{
{
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
}
}
}
}
}
}
case 4:
case 4:
{
{
new Randomizer = random_num(1, 3)
new Randomizer = random_num(1, 4)
switch(Randomizer)
switch(Randomizer)
{
{
case 1:
case 1:
{
{
formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
}
}
case 2:
case 2:
{
{
formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
}
}
case 3:
case 3:
{
{
formatex(Play, 127, "%s", DRAWMusic[random_num(0, ALLNum-1)])
}
case 4:
{
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
}
}
}
}
}
}
}
}
if(containi(Play, ".wav") != -1)
if(containi(Play, ".wav") != -1)
{
{
formatex(PlayCommand, 127, "spk %s", Play)
formatex(PlayCommand, 127, "spk %s", Play)
}
}
else if(containi(Play, ".mp3") != -1)
else if(containi(Play, ".mp3") != -1)
{
{
formatex(PlayCommand, 127, "mp3 play sound/%s", Play)
formatex(PlayCommand, 127, "mp3 play sound/%s", Play)
}
}
else
else
{
{
log_amx("Unsupported file type <%s>", PLUGIN, Play)
log_amx("Unsupported file type <%s>", PLUGIN, Play)
return PLUGIN_HANDLED
return PLUGIN_HANDLED
}
}
for(new id = 0; id <= get_maxplayers(); id++)
for(new id = 0; id <= get_maxplayers(); id++)
{
{
if(!is_user_connected(id) || !Ermon[id])
if(!is_user_connected(id) || !Ermon[id])
{
{
continue
continue
}
}
client_cmd(id, "stopsound")
client_cmd(id, "stopsound")
client_cmd(id, "%s", PlayCommand)
client_cmd(id, "%s", PlayCommand)
if(get_pcvar_num(PcvarRadio))
if(get_pcvar_num(PcvarRadio))
{
{
client_cmd(id, "spk radio/ctwin")
client_cmd(id, "spk radio/ctwin")
}
}
}
}
return PLUGIN_HANDLED
return PLUGIN_HANDLED
}
}



public draw()
{
if(!get_pcvar_num(PcvarMode))
{
return PLUGIN_HANDLED
}
switch(get_pcvar_num(PcvarMode))
{
case 1:
{
formatex(Play, 127, "%s", DRAWMusic[random_num(0, CTNum-1)])
}
case 2:
{
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
}
case 3:
{
new Randomizer = random_num(1, 2)
switch(Randomizer)
{
case 1:
{
formatex(Play, 127, "%s", DRAWMusic[random_num(0, CTNum-1)])
}
case 2:
{
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
}
}
}
case 4:
{
new Randomizer = random_num(1, 4)
switch(Randomizer)
{
case 1:
{
formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
}
case 2:
{
formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
}
case 3:
{
formatex(Play, 127, "%s", DRAWMusic[random_num(0, ALLNum-1)])
}
case 4:
{
formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
}
}
}
}
if(containi(Play, ".wav") != -1)
{
formatex(PlayCommand, 127, "spk %s", Play)
}
else if(containi(Play, ".mp3") != -1)
{
formatex(PlayCommand, 127, "mp3 play sound/%s", Play)
}
else
{
log_amx("Unsupported file type <%s>", PLUGIN, Play)
return PLUGIN_HANDLED
}
for(new id = 0; id <= get_maxplayers(); id++)
{
if(!is_user_connected(id) || !Ermon[id])
{
continue
}
client_cmd(id, "stopsound")
client_cmd(id, "%s", PlayCommand)
if(get_pcvar_num(PcvarRadio))
{
client_cmd(id, "spk radio/rounddraw")
}
}
return PLUGIN_HANDLED
}



public cmd_ermon(id)
public cmd_ermon(id)
{
{
Ermon[id] = true
Ermon[id] = true
client_cmd(id, "mp3volume %f", get_pcvar_float(PcvarVol))
client_cmd(id, "mp3volume %f", get_pcvar_float(PcvarVol))
client_cmd(id, "spk vox/activated")
client_cmd(id, "spk vox/activated")
green_print(id, "ERMON_MSG")
green_print(id, "ERMON_MSG")
return PLUGIN_CONTINUE
return PLUGIN_CONTINUE
}
}




public cmd_ermoff(id)
public cmd_ermoff(id)
{
{
Ermon[id] = false
Ermon[id] = false
client_cmd(id, "mp3 stop")
client_cmd(id, "mp3 stop")
client_cmd(id, "spk vox/deactivated")
client_cmd(id, "spk vox/deactivated")
green_print(id, "ERMOFF_MSG")
green_print(id, "ERMOFF_MSG")
return PLUGIN_CONTINUE
return PLUGIN_CONTINUE
}
}


public showerminfo(id)
public showerminfo(id)
{
{
Ermon[id] = true
Ermon[id] = true
client_cmd(id, "mp3volume %f", get_pcvar_float(PcvarVol))
client_cmd(id, "mp3volume %f", get_pcvar_float(PcvarVol))
green_print(id, "ERMINFO_MSG")
green_print(id, "ERMINFO_MSG")
}
}


stock green_print(index, const message[])
stock green_print(index, const message[])
{
{
new finalmsg[192];
new finalmsg[192];
formatex(finalmsg, 191, "^x04[ERM] ^x01%L", index, message);
formatex(finalmsg, 191, "^x04[ERM] ^x01%L", index, message);
message_begin(MSG_ONE, SayText, _, index);
message_begin(MSG_ONE, SayText, _, index);
write_byte(index);
write_byte(index);
write_string(finalmsg);
write_string(finalmsg);
message_end();
message_end();
}
}