Код
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <colorchat>
#define PLUGIN "Fake Votekick/Voteban"
#define VERSION "1.0"
#define AUTHOR "BorJomi"
new bool:start_vote,votes,punishment,vote_mode
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd( "say /votekick","votekick", ADMIN_ALL)
register_clcmd( "say /voteban","voteban", ADMIN_ALL)
register_clcmd( "say votekick","votekick", ADMIN_ALL)
register_clcmd( "say voteban","voteban", ADMIN_ALL)
punishment = register_cvar("fakevote_punishment","1")
register_menucmd(register_menuid("fakemenu"), 1023, "fakekey");
}
public votekick(id)
{
fake_vote(id,1)
}
public voteban(id)
{
fake_vote(id,2)
}
public fake_vote(id,mode)
{
if(!start_vote)
{
start_vote=true
votes=0
vote_mode=mode
new vote_name[33]
get_user_name(id,vote_name,32)
new iPlayers[32],iNum
get_players(iPlayers,iNum,"ch")
for(new i=0;i<iNum;i++)
{
new ids=iPlayers[i]
show_menu_players(ids,vote_name)
}
new task_data[2]
task_data[0] = iNum
task_data[1] = id
set_task(10.0,"end_vote",_,task_data,2)
}
else
{
switch(mode)
{
case 1:
client_print_color(id, DontChange, "[^4VoteKick^1] Wait! Another Vote in Progress")
case 2:
client_print_color(id, DontChange, "[^4VoteBan^1] Wait! Another Vote in Progress")
}
}
}
public end_vote(args[])
{
new inum = args[0]
new start_id = args[1]
new vote_percent=(votes*100)/inum
new vote_name[33]
get_user_name(start_id,vote_name,32)
if(vote_percent>50)
{
new tmp_str[128]
if(get_pcvar_num(punishment) && vote_mode==1)
{
formatex(tmp_str,sizeof tmp_str - 1,"Hey %s, other Players decided to kick you:D",vote_name)
kick_function(start_id,tmp_str)
}
else if(get_pcvar_num(punishment) && vote_mode==2)
{
formatex(tmp_str,sizeof tmp_str - 1,"Hey %s, other Players decided to ban you. But we just kick you:D",vote_name)
kick_function(start_id,tmp_str)
}
switch(vote_mode)
{
case 1:
{
client_print_color(id, DontChange,"[^4VoteKick^1] Vote finished! Other Players^3(%d%%)^1 decided to ^4kick %s",vote_percent,vote_name)
if(!get_pcvar_num(punishment))
client_print_color(id, DontChange,"[^4VoteKick^1] But it's fake vote:D")
}
case 2:
{
client_print_color(id, DontChange,"[^4VoteBan^1] Vote finished! Other Players^3(%d%%)^1 decided to ban ^4%s",vote_percent,vote_name)
if(!get_pcvar_num(punishment))
client_print_color(id, DontChange,"[^4VoteBan^1] But it's fake vote:D")
else
client_print_color(id, DontChange,"[^4VoteBan^1] But it's fake vote. So we Just kick him:D")
}
}
}
else
{
switch(vote_mode)
{
case 1:
client_print_color(id, DontChange,"[^4VoteKick^1] Vote finished! Lucky ^3%s,^1 other Players^4(%d%%)^1 doesn't want kick him!",vote_name,100-vote_percent)
case 2:
{
client_print_color(id, DontChange,"[^4VoteBan^1] Vote finished! Lucky ^3%s,^1 other Players^4(%d%%)^1 doesn't want ban him!",vote_name,100-vote_percent)
}
}
}
start_vote=false
votes=0
vote_mode=0
}
public kick_function(id,szReason[])
{
emessage_begin(MSG_ONE,SVC_DISCONNECT,_,id)
ewrite_string(szReason)
emessage_end()
}
public show_menu_players(id,vote_name[])
{
new MenuBody[1024], len, keys;
switch(vote_mode)
{
case 1:
{
len = format(MenuBody, 1023, "\dVoteKick Menu^n^n");
len += format(MenuBody[len], 1023-len, "\wHey people \y%s\w wants to kick yourself. \rKick\w him?",vote_name);
}
case 2:
{
len = format(MenuBody, 1023, "\dVoteBan Menu^n^n");
len += format(MenuBody[len], 1023-len, "\wHey people \y%s\w wants to ban yourself. \rBan\w him?",vote_name);
}
}
len += format(MenuBody[len], 1023-len, "^n\r1. \wYes");
keys |= (1<<0);
len += format(MenuBody[len], 1023-len, "^n\r2. \wNo");
keys |= (1<<1);
len += format(MenuBody[len], 1023-len, "^n^n\r0. \wExit");
keys |= (1<<9);
show_menu(id, keys, MenuBody, -1, "fakemenu");
return PLUGIN_CONTINUE;
}
public fakekey(id, key)
{
new name[33]
get_user_name(id,name,32)
switch((key+1))
{
case 1:
{
if(start_vote)
{
votes++
switch(vote_mode)
{
case 1:
client_print_color(id, DontChange,"[^4VoteKick^1] ^3%s^1 vote for Yes",name)
case 2:
client_print_color(id, DontChange,"[^4VoteBan^1] ^3%s^1 vote for Yes",name)
}
}
}
case 2:
{
if(start_vote)
{
switch(vote_mode)
{
case 1:
client_print_color(id, DontChange,"[^4VoteKick^1] ^3%s^1 vote for No",name)
case 2:
client_print_color(id, DontChange,"[^4VoteBan^1] ^3%s^1vote for No",name)
}
}
}
}
return PLUGIN_HANDLED;
}