/* Plugin generated by
AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <tutor>
#include <ColorChat>
#define PLUGIN "RoundSound"
#define VERSION "2.0 BETA"
#define AUTHOR "speedkill"
new Array:g_PathCT,
Array:g_PathTT,
Array:g_SoundNameCT,
Array:g_SoundNameTT;
new bool:g_RoundSound[33],
bool:g_ShowAds[33],
bool:g_FirstPlay,
bool:g_MusicPlaying;
new g_LastSong[96],
g_Prefix[64],
g_ShowInfo[33],
g_ArraySize[4],
g_Pcvar[4],
g_ValueTeam[2],
g_ShowType,
g_MaxPlayers,
g_PlaylistType,
g_RandomMusic;
new const g_ShowNames[][]={
"Brak",
"Tutor",
"Czat"
};
new const g_CvarName[][]={
"Roundsound_ads_time",
"Roundsound_prefix",
"Roundsound_random_music",
"Roundsound_show_type"
};
new const g_CvarValue[][]={
"120",
"RoundSound",
"0",
"1"
};
new const g_LangCmd[][]={
"say /rs",
"say /roundsound",
"say_team /rs",
"say_team /roundsound"
};
new const g_LastLangCmd[][]={
"say /last",
"say_team /last"
};
enum{
Tutor_Msg = 1,
Chat_Msg
};
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
for(new i = 0; i < sizeof g_LangCmd; i++){
register_clcmd(g_LangCmd[i], "ShowRsMenu");
}
for(new i = 0; i < sizeof g_LastLangCmd; i++){
register_clcmd(g_LastLangCmd[i], "ShowLastSong");
}
register_event("SendAudio", "PlaySoundTT", "a", "2&%!MRAD_terwin");
register_event("SendAudio", "PlaySoundCT", "a", "2&%!MRAD_ctwin");
register_logevent("RoundStart", 2, "1=Round_Start");
tutorInit();
for(new i = 0; i < sizeof g_CvarName; i++){
g_Pcvar[i] = register_cvar(g_CvarName[i], g_CvarValue[i]);
}
}
public plugin_precache(){
g_PathCT = ArrayCreate(128);
g_PathTT = ArrayCreate(128);
g_SoundNameCT = ArrayCreate(96);
g_SoundNameTT = ArrayCreate(96);
LoadSounds();
tutorPrecache();
}
public plugin_cfg(){
get_pcvar_string(g_Pcvar[1], g_Prefix, charsmax(g_Prefix));
g_ShowType = get_pcvar_num(g_Pcvar[3]);
g_RandomMusic = get_cvar_num(g_Pcvar[2]);
g_MaxPlayers = get_maxplayers();
set_task(get_pcvar_float(g_Pcvar[0]), "ShowAds",.flags = "b");
g_ValueTeam[0] = g_ValueTeam[1] = -1;
}
public client_authorized(id){
g_RoundSound[id] = true;
g_ShowAds[id] = true;
g_ShowInfo[id] = g_ShowType;
}
public LoadSounds(){
new g_Path[128];
formatex(g_Path[ get_configsdir(g_Path, charsmax(g_Path)) ], charsmax(g_Path), "/RoundSound.ini");
if(file_exists(g_Path)){
new g_Line[256],
g_SoundPath[128],
g_Name[96],
g_Team[3],
g_Len;
for(new i = 0; read_file(g_Path, i, g_Line, charsmax(g_Line), g_Len); i++){
if(!g_Len || !g_Line[0] || g_Line[0] == ';'){
continue;
}
parse(g_Line, g_SoundPath, charsmax(g_SoundPath), g_Name, charsmax(g_Name), g_Team, charsmax(g_Team));
new g_Value = strlen(g_SoundPath) - 4;
log_amx("Path: %s | Title: %s | Team: %s | Format: %s", g_SoundPath, g_Name, g_Team, g_SoundPath[ g_Value ]);
if(equal(g_SoundPath[ g_Value ], ".mp3") || equal(g_SoundPath[ g_Value ], ".wav")){
if(equal(g_SoundPath[ g_Value ], ".mp3")){
format(g_SoundPath, charsmax(g_SoundPath), "sound/%s", g_SoundPath);
precache_generic(g_SoundPath);
}
else{
precache_sound(g_SoundPath);
}
/* Check team */
if(equal(g_Team, "CT")){
ArrayPushString(g_PathCT, g_SoundPath);
ArrayPushString(g_SoundNameCT, g_Name);
}
else if(equal(g_Team, "TT")){
ArrayPushString(g_PathTT, g_SoundPath);
ArrayPushString(g_SoundNameTT, g_Name);
}
log_amx("File %s has a good format", g_SoundPath);
}
else{
log_amx("File %s has a bad format", g_SoundPath);
}
}
}
else{
/* Houston, We've Got a Problem. */
set_fail_state("File RoundSound.ini not exist in configs/");
}
GetArraySize();
}
public GetArraySize(){
g_ArraySize[0] = ArraySize(g_PathCT);
g_ArraySize[1] = ArraySize(g_PathTT);
g_ArraySize[2] = ArraySize(g_SoundNameCT);
g_ArraySize[3] = ArraySize(g_SoundNameTT);
}
public ShowRsMenu(id){
new g_FormatText[64];
new g_Menu = menu_create("\wRoundSound ustawienia", "MenuChoose");
formatex(g_FormatText, charsmax(g_FormatText), "\yRoundsound: \r[\d%s\r]", g_RoundSound[id] ? "ON" : "OFF");
menu_additem(g_Menu, g_FormatText);
menu_additem(g_Menu, "\rOdsluchaj utwory \yCT \d[\yPlaylista\d]");
menu_additem(g_Menu, "\yOdsluchaj utwory \rTT \d[\rPlaylista\d]");
formatex(g_FormatText, charsmax(g_FormatText), "\rReklamy: \y[\d%s\y]", g_ShowAds[id] ? "ON" : "OFF");
menu_additem(g_Menu, g_FormatText);
formatex(g_FormatText, charsmax(g_FormatText), "\yWyswietlanie nazwy \rutworu: \y[\d%s\y]", g_ShowNames[ g_ShowInfo[id] ]);
menu_additem(g_Menu, g_FormatText);
menu_setprop(g_Menu, MPROP_EXITNAME, "Wyjscie");
menu_display(id, g_Menu);
}
public MenuChoose(id, g_Menu, g_Item){
if(g_Item == MENU_EXIT){
menu_destroy(g_Menu);
return PLUGIN_HANDLED;
}
switch(g_Item){
case 0:{
g_RoundSound[id] = !g_RoundSound[id];
ColorChat(id, TEAM_COLOR, "[%s]^x04 Roundsound:^x03 %s", g_Prefix, g_RoundSound[id] ? "wlaczony" : "wylaczony");
ShowRsMenu(id);
}
case 1..2:{
ShowPlaylist(id, g_Item);
}
case 3:{
g_ShowAds[id] = !g_ShowAds[id];
ColorChat(id, TEAM_COLOR, "[%s]^x04 Reklamy:^x03 %s", g_Prefix, g_ShowAds[id] ? "wlaczone" : "wylaczone");
ShowRsMenu(id);
}
case 4:{
if(g_ShowInfo[id] >= 2){
g_ShowInfo[id] = -1;
}
g_ShowInfo[id]++;
ShowRsMenu(id);