Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #define DEBUG
- #define PLUGIN_AUTHOR "Mily"
- #define PLUGIN_VERSION "1.00"
- #include <sourcemod>
- #include <sdktools>
- #include <multicolors>
- #pragma newdecls required
- #define DS_FLAG ADMFLAG_CUSTOM6
- #define TYPE_NULL 0
- #define TYPE_KICK 1
- #define TYPE_BAN 2
- #define NULL_PLAYER -2
- bool voteInProgress = false;
- int voteTypeInProgress = TYPE_NULL;
- int selectedPlayer = NULL_PLAYER;
- int yesVotes = 0;
- int noVotes = 0;
- Handle vTimer = INVALID_HANDLE;
- public Plugin myinfo =
- {
- name = "DS - Vote Kick/Ban",
- author = PLUGIN_AUTHOR,
- description = "VoteKick/VoteBan for Dedicated Supporters",
- version = PLUGIN_VERSION,
- url = "http://www.edge-gamers.com"
- };
- public void OnPluginStart()
- {
- RegConsoleCmd("sm_votekick", Command_VoteKick, "Initiate a vote to kick a player.");
- RegConsoleCmd("sm_voteban", Command_VoteBan, "Initiate a vote to ban a player for 30 minutes.");
- }
- public Action Command_VoteKick(int client, any args)
- {
- if (voteInProgress)
- {
- CPrintToChat(client, "{red}A vote is already in effect!");
- return Plugin_Handled;
- }
- if (!CheckCommandAccess(client, "sm_wtfisthisarealcommandlmao", DS_FLAG))
- {
- CPrintToChat(client, "{red}You must be a Dedicated Supporter to use this command!");
- return Plugin_Handled;
- }
- voteInProgress = true;
- voteTypeInProgress = TYPE_KICK;
- CreatePlayerMenu(client);
- return Plugin_Handled;
- }
- public Action Command_VoteBan(int client, any args)
- {
- CreatePlayerMenu(client);
- }
- public Action CreatePlayerMenu(int client)
- {
- if(!client) return Plugin_Handled;
- int playerCount = GetClientCount(true);
- char clientName[50];
- Menu menu = new Menu(Hndler_PlayerMenu);
- menu.SetTitle("Select a Player:\n ");
- for (int i = 0; i < playerCount; i++)
- {
- if(IsClientConnected(i) && IsClientInGame(i))
- {
- GetClientName(i, clientName, sizeof(clientName));
- AddMenuItem(menu, clientName, clientName);
- }
- }
- menu.ExitButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- return Plugin_Handled;
- }
- public Action Command_VoteBan(int client, any args)
- {
- CreatePlayerMenu(client);
- }
- public Action CreateKickBanVoteMenu()
- {
- if(!voteInProgress || !voteTypeInProgress == TYPE_NULL || selectedPlayer == NULL_PLAYER
- || !IsClientInGame(selectedPlayer) || IsClientConnected(selectedPlayer)) return Plugin_Handled;
- int playerCount = GetClientCount(true);
- char clientName[50];
- Menu menu = new Menu(Hndler_PlayerMenu);
- menu.SetTitle("Select a Player:\n ");
- AddMenuItem(menu, clientName, clientName);
- menu.ExitButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- return Plugin_Handled;
- }
- public int Hndler_PlayerMenu( Menu menu, MenuAction action, int client, int index )
- {
- if(action == MenuAction_Select)
- {
- selectedPlayer = index;
- HandleSelection();
- }
- else if(action == MenuAction_End)
- {
- delete menu;
- }
- return 0;
- }
- public void HandleSelection()
- {
- if(selectedPlayer != NULL_PLAYER && voteInProgress)
- {
- if(voteTypeInProgress == TYPE_KICK)
- {
- vTimer = CreateTimer(30.0, Timer_Vote);
- }
- if(voteTypeInProgress == TYPE_BAN)
- {
- vTimer = CreateTimer(30.0, Timer_Vote);
- }
- }
- }
- public Action Timer_Vote(Handle timer, any client)
- {
- return Plugin_Continue;
- }
- public void reset()
- {
- voteInProgress = false;
- voteTypeInProgress = TYPE_NULL;
- selectedPlayer = NULL_PLAYER;
- yesVotes = 0;
- noVotes = 0;
- vTimer = INVALID_HANDLE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement