#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>
#define MAX_players 32
#define MAX_menudata 1024
new ga_PlayerName[MAX_players][32]
new ga_PlayerAuthID[MAX_players][35]
new ga_PlayerID[MAX_players]
new ga_PlayerIP[MAX_players][16]
new ga_MenuData[MAX_menudata]
new ga_Choice[2]
new gi_VoteStarter
new gi_MenuPosition
new gi_Sellection
new gi_TotalPlayers
new gi_SysTimeOffset = 0
new i
new idol
new idoll[32]
//pcvars
new gi_LastTime
new gi_DelayTime
new gf_Ratio
new gf_MinVoters
new gf_BF_Ratio
new gi_BanTime
new gi_Disable
new gi_BanType
new szArgs[512]
public plugin_init()
{
register_plugin("VoteBan_by_SLIMSHADY","1.5","RAF_SLIMSHADY_MOD")
register_clcmd("say /voteban","SayIt" )
register_clcmd("say voteban","SayIt" )
register_menucmd(register_menuid("ChoosePlayer"),1023,"ChooseMenu")
register_menucmd(register_menuid("VoteMenu"),1023,"CountVotes")
register_clcmd("messagemode5", "ClCmdMessageMode3")
register_clcmd("say5", "xax")
gi_LastTime=register_cvar("amx_voteban_lasttime","0")
gi_DelayTime=register_cvar("amxx_voteban_delaytime","500")
gf_Ratio=register_cvar("amxx_voteban_ratio","0.70")
gf_MinVoters=register_cvar("amxx_voteban_minvoters","0.0")
gf_BF_Ratio=register_cvar("amxx_voteban_bf_ratio","0.0")
gi_Disable=register_cvar("amxx_voteban_disable","0")
gi_BanType=register_cvar("amxx_voteban_type","0")
}
public ClCmdMessageMode3(id)
{
client_cmd(id, "messagemode say5")
ColorChat(id, RED, "[VOTEBAN] Введите причину голосования для этого игрока наверху.")
}
public xax(id)
{
read_args(szArgs, 511)
remove_quotes(szArgs)
while (replace(szArgs, 511, "q", "й")) {}
while (replace(szArgs, 511, "w", "ц")) {}
while (replace(szArgs, 511, "e", "у")) {}
while (replace(szArgs, 511, "r", "к")) {}
while (replace(szArgs, 511, "t", "е")) {}
while (replace(szArgs, 511, "y", "н")) {}
while (replace(szArgs, 511, "u", "г")) {}
while (replace(szArgs, 511, "i", "ш")) {}
while (replace(szArgs, 511, "o", "щ")) {}
while (replace(szArgs, 511, "p", "з")) {}
while (replace(szArgs, 511, "[", "х")) {}
while (replace(szArgs, 511, "]", "ъ")) {}
while (replace(szArgs, 511, "a", "ф")) {}
while (replace(szArgs, 511, "s", "ы")) {}
while (replace(szArgs, 511, "d", "в")) {}
while (replace(szArgs, 511, "f", "а")) {}
while (replace(szArgs, 511, "g", "п")) {}
while (replace(szArgs, 511, "h", "р")) {}
while (replace(szArgs, 511, "j", "о")) {}
while (replace(szArgs, 511, "k", "л")) {}
while (replace(szArgs, 511, "l", "д")) {}
while (replace(szArgs, 511, ";", "ж")) {}
while (replace(szArgs, 511, "'", "э")) {}
while (replace(szArgs, 511, "z", "я")) {}
while (replace(szArgs, 511, "x", "ч")) {}
while (replace(szArgs, 511, "c", "с")) {}
while (replace(szArgs, 511, "v", "м")) {}
while (replace(szArgs, 511, "b", "и")) {}
while (replace(szArgs, 511, "n", "т")) {}
while (replace(szArgs, 511, "m", "ь")) {}
while (replace(szArgs, 511, ",", "б")) {}
while (replace(szArgs, 511, ".", "ю")) {}
while (replace(szArgs, 511, "Q", "Й")) {}
while (replace(szArgs, 511, "W", "Ц")) {}
while (replace(szArgs, 511, "E", "У")) {}
while (replace(szArgs, 511, "R", "К")) {}
while (replace(szArgs, 511, "T", "Е")) {}
while (replace(szArgs, 511, "Y", "Н")) {}
while (replace(szArgs, 511, "U", "Г")) {}
while (replace(szArgs, 511, "I", "Ш")) {}
while (replace(szArgs, 511, "O", "Щ")) {}
while (replace(szArgs, 511, "P", "З")) {}
while (replace(szArgs, 511, "{", "Х")) {}
while (replace(szArgs, 511, "}", "Ъ")) {}
while (replace(szArgs, 511, "A", "Ф")) {}
while (replace(szArgs, 511, "S", "Ы")) {}
while (replace(szArgs, 511, "D", "В")) {}
while (replace(szArgs, 511, "F", "А")) {}
while (replace(szArgs, 511, "G", "П")) {}
while (replace(szArgs, 511, "H", "Р")) {}
while (replace(szArgs, 511, "J", "О")) {}
while (replace(szArgs, 511, "K", "Л")) {}
while (replace(szArgs, 511, "L", "Д")) {}
while (replace(szArgs, 511, ":", "Ж")) {}
while (replace(szArgs, 511, "Z", "Я")) {}
while (replace(szArgs, 511, "X", "Ч")) {}
while (replace(szArgs, 511, "C", "С")) {}
while (replace(szArgs, 511, "V", "М")) {}
while (replace(szArgs, 511, "B", "И")) {}
while (replace(szArgs, 511, "N", "Т")) {}
while (replace(szArgs, 511, "M", "Ь")) {}
while (replace(szArgs, 511, "<", "Б")) {}
while (replace(szArgs, 511, ">", "Ю")) {}
timed(id)
}
public SayIt(id)
{
if(get_pcvar_num(gi_Disable))
{
client_print(id,print_chat,"VoteBan off.")
return 0
}
new Elapsed=get_systime(gi_SysTimeOffset) - get_pcvar_num(gi_LastTime)
new Delay=get_pcvar_num(gi_DelayTime)
if((Delay > Elapsed) && !is_user_admin(id))
{
new seconds = Delay - Elapsed
ColorChat(id,RED,"[VOTEBAN] Голосование возможно через %d секунд.",seconds)
return 0
}
get_players(ga_PlayerID,gi_TotalPlayers)
for(i=0;i<gi_TotalPlayers;i++)
{
new TempID = ga_PlayerID[i]
if(get_user_flags(TempID) & ADMIN_RCON)
{
}
if(TempID == id)
gi_VoteStarter=i
get_user_name(TempID,ga_PlayerName[i],31)
get_user_authid(TempID,ga_PlayerAuthID[i],34)
get_user_ip(TempID,ga_PlayerIP[i],15,1)
}
gi_MenuPosition = 0
ShowPlayerMenu(id)
return 0
}
public timed(id)
{
new i_Menu = menu_create("\rВыбери время бана:", "server_menu")
menu_additem(i_Menu, "\r15 \wминут", "1", 0)
menu_additem(i_Menu, "\r30 \wминут", "2", 0)
menu_additem(i_Menu, "\r1 \wчас", "3", 0)
menu_additem(i_Menu, "\r2 \wчаса", "4", 0)
menu_additem(i_Menu, "\r3 \wчаса", "5", 0)
menu_setprop(i_Menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, i_Menu, 0)
return PLUGIN_HANDLED
}
public server_menu(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new s_Data[6], s_Name[64], i_Access, i_Callback
menu_item_getinfo(menu, item, i_Access, s_Data, charsmax(s_Data), s_Name, charsmax(s_Name), i_Callback)
new i_Key = str_to_num(s_Data)
switch(i_Key)
{
case 1:
{
gi_BanTime = 15
run_vote()
}
case 2:
{
gi_BanTime = 30
run_vote()
}
case 3:
{
gi_BanTime = 60
run_vote()
}
case 4:
{
gi_BanTime = 120
run_vote()
}
case 5:
{
gi_BanTime = 180
run_vote()
}
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
public ShowPlayerMenu(id)
{
new arrayloc = 0
new keys = (1<<9)
arrayloc = format(ga_MenuData,(MAX_menudata-1),"\r[\wVOTEBAN\r] \wУкажи игрока:^n")
for(i=0;i<8;i++)
if( gi_TotalPlayers>(gi_MenuPosition+i))
{
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"\y%d.\w%s^n",i+1,ga_PlayerName[gi_MenuPosition+i])
keys |= (1<<i)
}
if( gi_TotalPlayers>(gi_MenuPosition+8))
{
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"^n\y9.\r[\wДалее\r]")
keys |= (1<<8)
}
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"^n\y0.\r[\wВыход\r]")
show_menu(id,keys,ga_MenuData,20,"ChoosePlayer")
return PLUGIN_HANDLED
}
public ChooseMenu(id,key)
{
switch(key)
{
case 8:
{
gi_MenuPosition=gi_MenuPosition+8
ShowPlayerMenu(id)
}
case 9:
{
if(gi_MenuPosition>=8)
{
gi_MenuPosition=gi_MenuPosition-8
ShowPlayerMenu(id)
}
else
return 0
}
default:
{
gi_Sellection=gi_MenuPosition+key
new admin = get_user_index(ga_PlayerName[gi_Sellection])
if (get_user_flags(admin) & ADMIN_LEVEL_H)
{
ColorChat(0, RED, "[VOTEBAN] ^x04%s ^x03является админом!", ga_PlayerName[gi_Sellection])
return 0
}
else
{
ClCmdMessageMode3(id)
return 0
}
}
}
return PLUGIN_HANDLED
}
public run_vote()
{
new Now=get_systime(gi_SysTimeOffset)
idol = get_user_index(ga_PlayerName[gi_Sellection])
set_pcvar_num(gi_LastTime, Now)
get_user_ip(idol,idoll,15,1)
log_amx("VoteBan Запустил %s против %s %s.=D.",ga_PlayerName[gi_VoteStarter],ga_PlayerName[gi_Sellection],ga_PlayerAuthID
[gi_Sellection])
ColorChat(0, RED, "[VOTEBAN] Голосование запустил ^x04%s ^x03против ^x04%s", ga_PlayerName[gi_VoteStarter],ga_PlayerName[gi_Sellection])
format(ga_MenuData,(MAX_menudata-1),"Инициатор голосования \y%s^n\wПричина: \r%s^n\wЗабанить \r%s \wна \r%d \wминут?^n(\y%d \wфрагов | \y%d \wсмертей)^n\y1.\wДа^n\y2.\wНет",ga_PlayerName[gi_VoteStarter],szArgs,ga_PlayerName[gi_Sellection],gi_BanTi
me,get_user_frags(idol),get_user_deaths(idol))
ga_Choice[0] = 0
ga_Choice[1] = 0
show_menu(0,(1<<0)|(1<<1),ga_MenuData,15,"VoteMenu" )
set_task(20.0,"outcom")
return 0
}
public CountVotes(id,key)
{
++ga_Choice[key]
return PLUGIN_HANDLED
}
public outcom()
{
new TotalVotes = ga_Choice[0] + ga_Choice[1]
new Float:result = (float(ga_Choice[0]) / float(TotalVotes))
if(get_pcvar_float(gf_MinVoters) >= (float(TotalVotes) / float(gi_TotalPlayers)))
{
ColorChat(0,RED,"[VOTEBAN] Недостаточно голосов за Бан ^x04%s!",ga_PlayerName[gi_Sellection])
return 0
}
else
{
if(result < get_pcvar_float(gf_BF_Ratio))
{
ColorChat(0,RED,"[VOTEBAN] ^x04%s ^x03забанен на ^x04%d ^x03минут.",ga_PlayerName[gi_VoteStarter],gi_BanTime)
ActualBan(gi_VoteStarter)
log_amx("[AMXX] %s was Banned for %d minutes.",ga_PlayerName[gi_VoteStarter],gi_BanTime)
}
if( result >= get_pcvar_float(gf_Ratio) )
{
ColorChat(0,RED,"[VOTEBAN] ^x04%s ^x03забанен на ^x04%d ^x03минут.",ga_PlayerName[gi_Sellection],gi_BanTime)
log_amx("[AMXX] %s was Banned for %d minutes.",ga_PlayerAuthID[gi_Sellection],gi_BanTime)
ActualBan(gi_Sellection)
}
else
{
ColorChat(0,RED,"[VOTEBAN] Голосование не состоялось. Недостаточно голосов.")
log_amx("[AMXX] The VoteBan dit not sucseed.")
}
}
ColorChat(0,RED,"[VOTEBAN] Проголосовало ^x04%d ^x03игроков, ^x04%d ^x03За.",gi_TotalPlayers,ga_Choice[0])
return 0
}
public ActualBan(Selected)
{
new Type = get_pcvar_num(gi_BanType)
get_user_name(idol, idoll, 31)
switch(Type)
{
case 1:
server_cmd("addip %d %s",gi_BanTime,ga_PlayerIP[Selected])
case 2:
server_cmd("amx_ban %d %s Voteban",gi_BanTime, idoll)
case 3:
server_cmd("amx_bancs %s %d Voteban",ga_PlayerName[gi_Sellection], gi_BanTime)
default:
server_cmd("banid %d %s kick",gi_BanTime,ga_PlayerAuthID[Selected])
}
return 0
}