125 lines
3.1 KiB
SourcePawn
125 lines
3.1 KiB
SourcePawn
/* Plugin Template generated by Pawn Studio */
|
|
|
|
#include <sourcemod>
|
|
#include <adminmenu>
|
|
|
|
new kickclients[MAXPLAYERS+1];
|
|
new banclients[MAXPLAYERS+1];
|
|
new muteclients[MAXPLAYERS+1];
|
|
new alreadyvoted_kick[MAXPLAYERS+1];
|
|
new alreadyvoted_ban[MAXPLAYERS+1];
|
|
new alreadyvoted_mute[MAXPLAYERS+1];
|
|
|
|
public Plugin:myinfo =
|
|
{
|
|
name = "Basic Votes",
|
|
author = "Chefe",
|
|
description = "<- Description ->",
|
|
version = "1.1",
|
|
url = "<- URL ->"
|
|
}
|
|
|
|
public OnPluginStart()
|
|
{
|
|
RegConsoleCmd("sm_votekick", Command_VoteKick, "Vote for kick a client.")
|
|
RegConsoleCmd("sm_voteban", Command_VoteBan, "Vote for ban a client.")
|
|
}
|
|
|
|
public OnClientConnected(client)
|
|
{
|
|
alreadyvoted_kick[client] = 0;
|
|
alreadyvoted_ban[client] = 0;
|
|
alreadyvoted_mute[client] = 0;
|
|
}
|
|
|
|
public OnClientDisconnect(client)
|
|
{
|
|
alreadyvoted_kick[client] = 0;
|
|
alreadyvoted_ban[client] = 0;
|
|
alreadyvoted_mute[client] = 0;
|
|
}
|
|
|
|
public Action:Command_VoteKick(client, args)
|
|
{
|
|
new Handle:votekick = CreateMenu(Menu_VoteKick);
|
|
SetMenuTitle(votekick, "Select Player to Vote")
|
|
AddTargetsToMenu(votekick, 0, true, false);
|
|
DisplayMenu(votekick, client, MENU_TIME_FOREVER);
|
|
|
|
return Plugin_Handled;
|
|
}
|
|
|
|
public Action:Command_VoteBan(client, args)
|
|
{
|
|
new Handle:voteban = CreateMenu(Menu_VoteBan);
|
|
SetMenuTitle(voteban, "Select Player to Vote");
|
|
AddTargetsToMenu(voteban, 0, true, false);
|
|
DisplayMenu(voteban, client, MENU_TIME_FOREVER);
|
|
|
|
return Plugin_Handled;
|
|
}
|
|
|
|
public Menu_VoteKick(Handle:menu, MenuAction:action, param1, param2)
|
|
{
|
|
if (action == MenuAction_Select)
|
|
{
|
|
new String:info[32];
|
|
GetMenuItem(menu, param2, info, sizeof(info));
|
|
new client = GetClientOfUserId(StringToInt(info));
|
|
new required = (60 * GetClientCount(true) / 100);
|
|
|
|
if (alreadyvoted_kick[param1] != client)
|
|
{
|
|
kickclients[client]++;
|
|
alreadyvoted_kick[param1] = client;
|
|
PrintToChatAll(" [SM] Register votekicks against %N (%i registered, %i required)", client, kickclients[client], required);
|
|
}
|
|
else
|
|
{
|
|
PrintToChat(param1, "[SM] You have already voted for %N", client);
|
|
}
|
|
|
|
if (kickclients[client] >= required)
|
|
{
|
|
KickClient(client, "You are kicked by Vote!");
|
|
PrintToChatAll("[SM] Kicked %N by %i votes.", client, kickclients[client]);
|
|
}
|
|
}
|
|
else if (action == MenuAction_End)
|
|
{
|
|
CloseHandle(menu);
|
|
}
|
|
}
|
|
|
|
public Menu_VoteBan(Handle:menu, MenuAction:action, param1, param2)
|
|
{
|
|
if (action == MenuAction_Select)
|
|
{
|
|
new String:info[32];
|
|
GetMenuItem(menu, param2, info, sizeof(info));
|
|
new client = GetClientOfUserId(StringToInt(info));
|
|
new required = (60 * GetClientCount(true) / 100);
|
|
|
|
if (alreadyvoted_ban[param1] != client)
|
|
{
|
|
banclients[client]++;
|
|
alreadyvoted_ban[param1] = client;
|
|
PrintToChatAll(" [SM] Register voteban against %N (%i registered, %i required)", client, banclients[client], required);
|
|
}
|
|
else
|
|
{
|
|
PrintToChat(param1, "[SM] You have already voted for %N", client);
|
|
}
|
|
|
|
if (banclients[client] >= required)
|
|
{
|
|
BanClient(client, 3600, BANFLAG_AUTHID, "Voteban.", "You are banned by Vote for %i seconds!");
|
|
PrintToChatAll("[SM] Banned %N for %i seconds by %i votes.", client, 3600, kickclients[client]);
|
|
}
|
|
}
|
|
else if (action == MenuAction_End)
|
|
{
|
|
CloseHandle(menu);
|
|
}
|
|
}
|