
Code: Select all
new const szSoundVote[3][] = {"sound/MapManager_by_BlackSmoke/g_start.mp3", "sound/MapManager_by_BlackSmoke/g_end.mp3", "sound/MapManager_by_BlackSmoke/g_sps.wav"}
Code: Select all
client_cmd(0, "+showscores;wait;wait;wait;mp3 stop;stopsound;spk %s", szSoundVote[2])
Code: Select all
new g_szMaps[5][64];new g_Votes[5];new g_iTimerVote[33];new g_szWinMap[64];new g_iNumRTV;new g_iPlayerProcc;new bool:g_LastRound;new b_HasRTV[33];new Float:g_iLastSec[33];new bool:g_Vote;new bool:b_HasAlreadyVoted[33];new iAllVoted; new const szSoundTimer[6][] = {"","fvox/one","fvox/two","fvox/three","fvox/four","fvox/five"}new const szSoundVote[3][] = {"sound/MapManager_by_BlackSmoke/g_start.mp3", "sound/MapManager_by_BlackSmoke/g_end.mp3", "sound/MapManager_by_BlackSmoke/g_sps.wav"} /**=========================================================================================== Макросы=============================================================================================*/#define TimeVote 30 // Сколько будет длится голосование /**=========================================================================================== Инициализация=============================================================================================*/public plugin_init(){ register_plugin("MapManager", "1.0", "BlackSmoke"); register_clcmd("say /rtv", "RockTheVote") register_clcmd("say /rockthevote", "RockTheVote") register_clcmd("say rtv", "RockTheVote") register_clcmd("say rockthevote", "RockTheVote") register_clcmd("say nextmap", "Show_Nextmap") register_clcmd("say /nextmap", "Show_Nextmap") register_menucmd(register_menuid("VoteMenu"), 1023, "ActionVoteMenu"); register_logevent("RoundEnd", 2, "1=Round_End") set_task(121.0, "ClCmdVote", _, _, _, "d") register_cvar("amx_nextmap", "[Не определена]"); set_cvar_string("amx_nextmap", "[Не определена]"); LoadMapsInVote();} /**=========================================================================================== Показываем следующую карту.=============================================================================================*/public Show_Nextmap(id){ new cmd[127]; get_cvar_string("amx_nextmap", cmd, 126) ChatColor(0, "!teamSekantis zemelapis: !g%s", cmd)} /**=========================================================================================== Конец раунда=============================================================================================*/public RoundEnd() if(g_LastRound) set_task(1.0, "changelevel"); /**=========================================================================================== Досрочная смена карты=============================================================================================*/public RockTheVote(id){ if(g_Vote) { ChatColor(id, "!teamBalsavimas jau prasidejo. !g*RTV*") return PLUGIN_CONTINUE; } if(b_HasRTV[id]) { ChatColor(id, "!teamJus jau balsavote. !g*RTV*") return PLUGIN_CONTINUE; } new iNum, szPlayers[32]; get_players(szPlayers, iNum, "hc") g_iNumRTV++; b_HasRTV[id] = true; if(g_iNumRTV == iNum) { ChatColor(0, "!teamВсе игроки !g(%d) !teamPer Anksti keisti kita zemelapi. !g*RTV*", g_iNumRTV) set_task(5.0, "ClCmdVote"); } else ChatColor(0, "!teamZemelapiui pakeisti reike !g%d !teambalsu. !g*RTV*", iNum-g_iNumRTV) return PLUGIN_HANDLED;} /**=========================================================================================== Загрузки плагина=============================================================================================*/public plugin_precache(){ for(new i; i < sizeof(szSoundVote); i++) precache_generic(szSoundVote[i])} /**=========================================================================================== Ставим карты для голосования=============================================================================================*/public LoadMapsInVote(){ new szFileName[64], Len, iNumRandomMap, q, iRepeat, szMapName[32], szDirMaps[127]; get_mapname(szMapName, 31); format(szFileName, 63, "addons/amxmodx/configs/maps.ini") q = random_num(0, file_size(szFileName, 1)-1) while(read_file(szFileName, q ,g_szMaps[iNumRandomMap], 63, Len)) { q = random_num(0, file_size(szFileName, 1)-1) if(iRepeat == q) continue; iRepeat = q; if(g_szMaps[iNumRandomMap][0] == ';' || Len == 0) continue format(szDirMaps, 126, "maps/%s.bsp", g_szMaps[iNumRandomMap]); if(!equali(szMapName, g_szMaps[iNumRandomMap]) && file_exists(szDirMaps)) iNumRandomMap++ if(iNumRandomMap > 4) break; }} /**=========================================================================================== Включаем отсчёт до голосования=============================================================================================*/public ClCmdVote() set_task(1.0, "ValueVote", _, _, _, "a", 6); /**=========================================================================================== Отсчёт до голосования=============================================================================================*/public ValueVote(){ new szSec[32]; set_dhudmessage( 255,255,0, -1.0, -0.80, 0, 6.0, 0.001, 0.1, 1.5 ) static timer = 6 timer-- switch(timer) { case 0: { g_Vote = true; startvote() arrayset(g_Votes, 0, sizeof(g_Votes)); arrayset(g_iTimerVote, TimeVote-10, 33); arrayset(b_HasAlreadyVoted, false, 33); set_task(float(TimeVote), "endvote"); timer = 6; client_cmd(0, "mp3 play %s", szSoundVote[0]) set_cvar_string("amx_nextmap", "[Идёт голосование]"); } default: { get_ending(timer, szSec, "у") show_dhudmessage(0, "Balsavimas prasides po %d %s", timer, szSec) client_cmd(0, "spk %s", szSoundTimer[timer]) } }} /**=========================================================================================== Голосование=============================================================================================*/public startvote(){ if(!g_Vote) return PLUGIN_CONTINUE; new szPlayers[32], iNum; get_players(szPlayers, iNum); iAllVoted = 0; for(new i; i < iNum; i++) ChooseMap(szPlayers[i]) return PLUGIN_HANDLED;} /**=========================================================================================== Меню выбора карт.=============================================================================================*/public ChooseMap(id){ if(!g_Vote) return PLUGIN_CONTINUE; new szMenu[512], iLen, iKey, szSec[32] get_ending(g_iTimerVote[id], szSec, "а"); iLen = format(szMenu[iLen], charsmax(szMenu)-iLen, "\yLaikas pasirinkti kita zemelapi.^n\djums \r%d \ds galvoti^n", g_iTimerVote[id], szSec) for(new q; q < 5; q++) { if(!b_HasAlreadyVoted[id]) iLen += format(szMenu[iLen], charsmax(szMenu)-iLen, "^n\r%d. \w%s \d[\y%d%%\d]",q+1, g_szMaps[q], g_Votes[q] * g_iPlayerProcc) else iLen += format(szMenu[iLen], charsmax(szMenu)-iLen, "^n\d%s [\y%d%%\d]", g_szMaps[q], g_Votes[q] * g_iPlayerProcc) } if(!b_HasAlreadyVoted[id]) { iKey |= MENU_KEY_0; iLen += format(szMenu[iLen], charsmax(szMenu)-iLen, "^n^n\r0. \wNieko") } iLen += format(szMenu[iLen], charsmax(szMenu)-iLen, "^n^n\yPrabalsavo: \r%d \dzmoniu", iAllVoted) iKey |= MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5 if(b_HasAlreadyVoted[id]) iKey &= ~(MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5); show_menu(id, iKey, szMenu, -1, "VoteMenu"); return PLUGIN_HANDLED;} /**=========================================================================================== Игрок голосует=============================================================================================*/public ActionVoteMenu(id, iKey){ if(!g_Vote) return PLUGIN_CONTINUE; new szName[32] get_user_name(id, szName, 31) if(iKey == 9) { if(!b_HasAlreadyVoted[id]) ChatColor(0, "!g%s !teamNe dalivavo balsavime.", szName); b_HasAlreadyVoted[id] = true return PLUGIN_CONTINUE; } iAllVoted++; g_Votes[iKey]++, b_HasAlreadyVoted[id] = true; ChatColor(0, "!g%s !team issirinko!g%s", szName, g_szMaps[iKey]); return PLUGIN_HANDLED;} /**=========================================================================================== Конец голосования=============================================================================================*/public endvote(){ g_Vote = false; new win = 0, szDirFile[127]; for(new i; i < sizeof(g_Votes); i++) { if(win < g_Votes[i]) { win = i format(g_szWinMap, 63, g_szMaps[win]) } } if(win < g_Votes[0]) { win = 0; format(g_szWinMap, 63, g_szMaps[win]); } if(!g_szWinMap[0]) { LoadMapsInVote(); set_task(5.0, "ClCmdVote"); ChatColor(0, "!teamBalsavimas atidetas.") return PLUGIN_CONTINUE; } format(szDirFile, 126, "maps/%s.bsp", g_szWinMap); if(!file_exists(szDirFile)) { LoadMapsInVote(); set_task(5.0, "ClCmdVote"); ChatColor(0, "!teamГолосование отложено из за отсутствующей карты.") return PLUGIN_CONTINUE; } set_dhudmessage( 149,68,0, -1.0, -0.70, 2, 4.0, 11.0, 0.01, 1.5 ) show_dhudmessage(0, ":Zemelapis %s^n bus pakeistas raundo pabaigoje",g_szWinMap, win) ChatColor(0, "!teamСледующая карта: !g%s", g_szWinMap) set_cvar_string("amx_nextmap", g_szWinMap); set_cvar_float("mp_timelimit", 0.0) g_LastRound = true; client_cmd(0, "mp3 play %s", szSoundVote[1]) return PLUGIN_HANDLED;} /**=========================================================================================== Меняем карту.=============================================================================================*/public changelevel(){ set_cvar_float("mp_timelimit", 0.0); set_dhudmessage( 0,255,0, -1.0, -0.40, 0, 11.0, 6.0, 0.1, 1.5 ) show_dhudmessage(0, "Aciu jums^nMap pakeistas i %s", g_szWinMap) client_cmd(0, "+showscores;wait;wait;wait;mp3 stop;stopsound;spk %s", szSoundVote[2]) new iNum, szPlayers[32]; get_players(szPlayers, iNum) for(new i; i < iNum; i++) { client_cmd(szPlayers[i], "drop;wait;wait;wait;wait;wait;drop;wait;wait;wait;wait;wait;drop"); set_pev(szPlayers[i], pev_flags, pev(szPlayers[i], pev_flags) | FL_FROZEN) } set_task(4.0, "changelevel1")} /**=========================================================================================== Меняем карту=============================================================================================*/public changelevel1(){ server_cmd("changelevel %s", g_szWinMap);} /**=========================================================================================== Синк=============================================================================================*/public client_PreThink(id){ if(!g_Vote) return; if(g_iTimerVote[id] <= -1) return; if(iAllVoted) g_iPlayerProcc = 100 / iAllVoted; else g_iPlayerProcc = 0; if((get_gametime() - g_iLastSec[id]) >= 1.0) if(g_iTimerVote[id] != 0) g_iTimerVote[id]--, ChooseMap(id), g_iLastSec[id] = get_gametime(); else show_menu(id, 0, "^n"), g_iTimerVote[id] = -1;} /**================================================================================ Получение Окончания Секунд=================================================================================*/stock get_ending(num, output[32], const l[]){ new num100=num%100, num10=num%10; if(num100>=5&&num100<=20||num10==0||num10>=5&&num10<=9) format(output, 31, "секунд"); else if(num10==1) format(output, 31, "seconds%s", l); else if(num10>=2&&num10<=4) format(output, 31, "секунды");} /**================================================================================ Цветной чат===================================================================================*/stock ChatColor(const id, const input[], any:...){ new count = 1, players[32] static msg[191] vformat(msg, 190, input, 3) format(msg, sizeof(msg), "^1[^4Balsavimas^1] %s", msg) replace_all(msg, 190, "!g", "^4") // Green Color replace_all(msg, 190, "!y", "^1") // Default Color replace_all(msg, 190, "!team", "^3") // Team Color 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, get_user_msgid("SayText"), _, players[i]) write_byte(players[i]); write_string(msg); message_end(); } } }