#include <amxmodx>
#include <amxmisc>
#include <ColorChat>
new player_name[32]
new player_steam[50]
new g_lastVote
new g_menuPosition[33]
new g_menuPlayers[33][32]
new g_menuPlayersNum[33]
new g_VotePlayer[2]
//Параметры
new g_TimeLastVote = 300 //время, между банами.
new g_BanTimePl = 30 //время бана.
public plugin_init()
{
register_plugin("VoTeBan Player Menu", "4.9", "Sutar")
register_clcmd("say /voteban", "cmdPlayerMenu")
register_clcmd("say voteban", "cmdPlayerMenu")
register_menucmd(register_menuid("Active Voteban"), 1023, "actionPlayerMenu")
register_menucmd(register_menuid("VoteMenu"), 1023, "CountVotbanPlayer")
}
public cmdPlayerMenu(id)
{
if(g_TimeLastVote > (get_systime(0) - g_lastVote))
{
new seconds = g_TimeLastVote - (get_systime(0) - g_lastVote)
ColorChat(id, RED, "^x04•^x03 Подождите ^x04%d^x01 секунд(ы) для нового^x03 голосования", seconds)
return PLUGIN_HANDLED
}
new iPlayers[32], iNum
get_players(iPlayers, iNum)
for(new i = 0; i < iNum; i++)
{
if(get_user_flags(iPlayers[i]) & ADMIN_LEVEL_A)
{
if(!(get_user_flags(id) & ADMIN_LEVEL_A))
{
ColorChat(id, RED, "^x04•^x03 На сервере есть ^x03привилегированный игрок")
return PLUGIN_CONTINUE
}
}
}
displayPlayerMenu(id, g_menuPosition[id] = 0)
return PLUGIN_CONTINUE
}
displayPlayerMenu(id, pos)
{
if(pos < 0)
return
get_players(g_menuPlayers[id], g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 8
if(start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 511, "\yВыберите игрока [ %d | %d ]^n^n", pos + 1, (g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0)))
new end = start + 8
new keys = MENU_KEY_0
if(end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for(new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i, name, 31)
if(get_user_flags(i) & ADMIN_IMMUNITY || i == id)
len += format(menuBody[len], 511-len, "\d%d. %s \r*^n", ++b, name)
else
{
keys |= (1<<b)
if(is_user_admin(i))
len += format(menuBody[len], 511-len, "\r%d.\w %s \r*^n", ++b, name)
else
len += format(menuBody[len], 511-len, "\r%d.\w %s^n", ++b, name)
}
}
if(end != g_menuPlayersNum[id])
{
format(menuBody[len], 511-len, "^n\w9. Дальше...^n\r0.\w %s", pos ? "Назад" : "Выход")
keys |= MENU_KEY_9
}
else
format(menuBody[len], 511-len, "^n\r0.\w %s", pos ? "Назад" : "Выход")
show_menu(id, keys, menuBody, -1, "Active Voteban")
}
public actionPlayerMenu(id, key)
{
switch(key)
{
case 8: displayPlayerMenu(id, ++g_menuPosition[id])
case 9: displayPlayerMenu(id, --g_menuPosition[id])
default:
{
new g_banPlayer = g_menuPlayers[id][g_menuPosition[id] * 8 + key]
get_user_name(g_banPlayer, player_name, 31)
get_user_authid(g_banPlayer, player_steam, 49)
run_vote(id)
}
}
return PLUGIN_CONTINUE
}
run_vote(id)
{
g_lastVote = get_systime(0)
g_VotePlayer[0] = 0
g_VotePlayer[1] = 0
new menuBody[512]
new iPlayers[32], iNum
get_players(iPlayers, iNum)
new g_playervote[32]
get_user_name(id, g_playervote, 31)
ColorChat(0, RED, "^x04• ^x03%s^x01 создает голосование за бан ^x03%s", g_playervote, player_name)
format(menuBody, 511, "\yЗабанить %s на %d минут?^n^n\r1.\w Да.^n\r2.\w Нет.", player_name, g_BanTimePl)
for(new i; i < iNum; i++)
show_menu(iPlayers[i], (1<<0)|(1<<1), menuBody, 15, "VoteMenu")
set_task(15.1, "endVotebanPlayer", id)
return PLUGIN_CONTINUE
}
public CountVotbanPlayer(id, key)
{
g_VotePlayer[key]++
/* new player[32]
get_user_name(id, player, 31)
ColorChat(0, GREEN, "^x01[^x04Voteban!^x01] Игрок ^x04%s^x01 проголосовал ^x04%s^x01.", player, key ? "против бана игрока" : "за бан игрока")*/
return PLUGIN_CONTINUE
}
public endVotebanPlayer(id)
{
new Float:result = (float(g_VotePlayer[0]) / float(g_VotePlayer[0] + g_VotePlayer[1]))
if(0.60 > result)
ColorChat(0, RED, "^x04• ^x03Недостаточно голосов, чтобы забанить ^x04%s", player_name)
else
{
ColorChat(0, RED, "^x04•^x01 %s ^x03забанен на ^x04%d минут", player_name, g_BanTimePl)
set_user_flags(id, ADMIN_BAN)
client_cmd(id, "amx_ban ^"%d^" ^"%s^" ^"Voteban^"", g_BanTimePl, player_steam)
remove_user_flags(id, ADMIN_BAN)
}
return PLUGIN_CONTINUE
}