#include <amxmodx>
#include <dhudmessage>
#include <fakemeta>
/**===========================================================================================
?????????
=============================================================================================*/
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"}
/**===========================================================================================
???????
=============================================================================================*/
#define TimeVote 30 // ¿Cuánto durará la votación?
/**===========================================================================================
?????????????
=============================================================================================*/
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", "[No definido]");
set_cvar_string("amx_nextmap", "[No definido]");
LoadMapsInVote();
}
/**===========================================================================================
?????????? ????????? ?????.
=============================================================================================*/
public Show_Nextmap(id)
{
new cmd[127];
get_cvar_string("amx_nextmap", cmd, 126)
ChatColor(0, "!g[OFF] !teamSiguiente mapa: !g%s", cmd)
}
/**===========================================================================================
????? ??????
=============================================================================================*/
public RoundEnd()
if(g_LastRound)
set_task(1.0, "changelevel");
/**===========================================================================================
????????? ????? ?????
=============================================================================================*/
public RockTheVote(id)
{
if(g_Vote)
{
ChatColor(id, "!g[OFF] !teamLa Votacion Ha Comenzado. !g*RTV*")
return PLUGIN_CONTINUE;
}
if(b_HasRTV[id])
{
ChatColor(id, "!g[OFF] !teamYa Ha Votado. !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, "!teamTodo Los Jugadores !g(%d) !teamQuieren Hacer Un Cambio De Mapa!. !g*RTV*", g_iNumRTV)
set_task(5.0, "ClCmdVote");
}
else
ChatColor(0, "!teamPara comenzar a votar necesitas !g%d !teamVotos", iNum-g_iNumRTV)
return PLUGIN_HANDLED;
}
/**===========================================================================================
?????? ????? ??? ???????????
=============================================================================================*/
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_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), -1.0, -0.80, 2, 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;
set_cvar_string("amx_nextmap", "[Hay Un Voto]");
}
default:
{
get_ending(timer, szSec, "?")
show_dhudmessage(0, "[OFF] La votacion comenzara en %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, "\y[OFFCommnunity] Es Hora de Elejir El Siguienet Mapa^n\dy Usted \r%d \ds, pensar^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. \wNada")
}
iLen += format(szMenu[iLen], charsmax(szMenu)-iLen, "^n^n\yVotado: \r%d \dPersonas", 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 !teamNo participar en la votacion de mapa.", szName);
b_HasAlreadyVoted[id] = true
return PLUGIN_CONTINUE;
}
iAllVoted++;
g_Votes[iKey]++, b_HasAlreadyVoted[id] = true;
ChatColor(0, "!g%s !teamElijio !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, "!teamposponer votación.")
return PLUGIN_CONTINUE;
}
format(szDirFile, 126, "maps/%s.bsp", g_szWinMap);
if(!file_exists(szDirFile))
{
LoadMapsInVote();
set_task(5.0, "ClCmdVote");
ChatColor(0, "!teamVoto pospuesta debido a la falta de tarjeta.")
return PLUGIN_CONTINUE;
}
set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), -1.0, -0.70, 2, 4.0, 11.0, 0.01, 1.5 )
show_dhudmessage(0, "Siguiente mapa: %s^nEl mas elejido por los jugadores.",g_szWinMap, win)
ChatColor(0, "!teamSiguiente mapa: !g%s", g_szWinMap)
set_cvar_string("amx_nextmap", g_szWinMap);
set_cvar_float("mp_timelimit", 0.0)
g_LastRound = true;
return PLUGIN_HANDLED;
}
/**===========================================================================================
?????? ?????.
=============================================================================================*/
public changelevel()
{
set_cvar_float("mp_timelimit", 0.0);
set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), -1.0, -0.40, 2, 11.0, 6.0, 0.1, 1.5 )
show_dhudmessage(0, "Gracias a todos por votar^nSiguiente mapa ganador sera %s", g_szWinMap)
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, "Segundos");
else if(num10==1) format(output, 31, "Segundos%s", l);
else if(num10>=2&&num10<=4) format(output, 31, "Segundos");
}
/**================================================================================
??????? ???
===================================================================================*/
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[^4Residents Of Warriors^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();
}
}
}
}