Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < a_samp > //samp natives -- Kye
- #include < zcmd > //command processor -- ZeeX
- #include < sscanf2_5 > //sscanf "unformat" v2.5 -- Y_Less
- new
- bool:player_HasVoted[MAX_PLAYERS] = false,
- bool:global_Cooldown = false,
- player_VotingPlayer[MAX_PLAYERS] = -1,
- global_PlayerBeingVoted = -1,
- global_VoteYes = 0,
- global_VoteNo = 0
- ;
- #define DIALOG_TEXT_REASONS "Use of Cheats\nFlaming\nSpawn Killing"
- /*
- Edit this string with your available reasons to kick a player.
- Put \n between reasons.
- Example: Cheating\nFlaming would display: Cheating
- Flaming
- After editing this, go down to OnDialogResponse, and add a new 'case' for it.
- */
- #define DIALOG_VOTEKICK 1000
- /*
- Edit this number to your preferred dialog ID,
- This is easily editable in order to prevent confrontations (issues) with your gamemode.
- */
- #define VOTEKICK_TIME 30
- /*
- Edit this number to your preferred vote-kick time.
- This number is in seconds, therefore a 30 here would mean it would take 30 seconds before a vote is made.
- */
- #define VOTEKICK_COOLDOWN 5*60000
- /*
- Edit this number to your preferred vote-kick cooldown time.
- After someone is voted, this timer will start and prevent other users from votekicking them until it resets the variable.
- By default, this cooldown is on 5 minutes.
- */
- public OnFilterScriptInit() {
- print("2K-VOTE has been loaded.");
- for( new gPlayers; gPlayers < MAX_PLAYERS; gPlayers++ )
- {
- if(IsPlayerConnected(gPlayers))
- {
- player_HasVoted[gPlayers] = false;
- //The filterscript just got loaded, how would someone vote beforehand?
- }
- }
- return true;
- }
- public OnPlayerConnect(playerid) {
- player_HasVoted[playerid] = false;
- return true;
- }
- CMD:votekick(playerid, params[]) {
- new
- p_ID;
- if(sscanf(params, "u", p_ID))
- return SendClientMessage(playerid, 0xA31414FF, "< /votekick < Player ID >");
- if(player_VotingPlayer[playerid] == INVALID_PLAYER_ID)
- return SendClientMessage(playerid, 0xA31414FF, "< /votekick: Invalid Player ID!");
- if(global_Cooldown == true)
- return SendClientMessage(playerid, 0xA31414FF, "< /votekick: Someone has already been votekicked recently!");
- player_VotingPlayer[playerid] = p_ID;
- global_PlayerBeingVoted = p_ID;
- ShowPlayerDialog(playerid, DIALOG_VOTEKICK, DIALOG_STYLE_LIST, "{09C6DB}2K-VOTE: Select a reason", "{FFFFFF}"DIALOG_TEXT_REASONS"", "Select", "Cancel");
- return true;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch( dialogid )
- {
- case DIALOG_VOTEKICK:
- {
- if( response )
- {
- if( player_VotingPlayer[playerid] != INVALID_PLAYER_ID ) //Checking once again to see if the player is valid.
- {
- new
- c_Name[MAX_PLAYER_NAME],
- p_Name[MAX_PLAYER_NAME],
- vStr[128],
- vStr2[156]
- ;
- GetPlayerName(player_VotingPlayer[playerid], c_Name, sizeof(c_Name));
- GetPlayerName(playerid, p_Name, sizeof(p_Name));
- switch( listitem )
- {
- case 0:
- {
- //Use of Cheats
- format(vStr, sizeof(vStr), "<ATN> %s is being votekicked by %s, Reason: Use of Cheats!", c_Name, p_Name);
- format(vStr2, sizeof(vStr2), "{FFFFFF}%s has started a votekick against %s.\nREASON: Use of Cheats!\n{6BE012}Would you like to vote to kick this player?", p_Name, c_Name);
- for ( new gPlayers; gPlayers < MAX_PLAYERS; gPlayers++ )
- {
- if ( gPlayers == player_VotingPlayer[playerid]) return 0;
- SendClientMessage(gPlayers, 0xFFFFFFFF, vStr);
- ShowPlayerDialog(gPlayers, DIALOG_VOTEKICK+1, DIALOG_STYLE_MSGBOX, "{09C6DB}2K-VOTE: Votekick?", vStr2, "No", "Yes");
- SetTimer("VoteKick", VOTEKICK_TIME*1000, false);
- }
- global_Cooldown = true;
- }
- case 1:
- {
- //Flaming
- format(vStr, sizeof(vStr), "<ATN> %s is being votekicked by %s, Reason: Flaming!", c_Name, p_Name);
- format(vStr2, sizeof(vStr2), "{FFFFFF}%s has started a votekick against %s.\nREASON: Flaming!\n{6BE012}Would you like to vote to kick this player?", p_Name, c_Name);
- for ( new gPlayers; gPlayers < MAX_PLAYERS; gPlayers++ )
- {
- if ( gPlayers == player_VotingPlayer[playerid]) return 0;
- SendClientMessage(gPlayers, 0xFFFFFFFF, vStr);
- ShowPlayerDialog(gPlayers, DIALOG_VOTEKICK+1, DIALOG_STYLE_MSGBOX, "{09C6DB}2K-VOTE: Votekick?", vStr2, "No", "Yes");
- SetTimer("VoteKick", VOTEKICK_TIME*1000, false);
- }
- global_Cooldown = true;
- }
- case 2:
- {
- //Spawn-Killing
- format(vStr, sizeof(vStr), "<ATN> %s is being votekicked by %s, Reason: Spawn Killing!", c_Name, p_Name);
- format(vStr2, sizeof(vStr2), "{FFFFFF}%s has started a votekick against %s.\nREASON: Spawn Killing!\n{6BE012}Would you like to vote to kick this player?", p_Name, c_Name);
- for ( new gPlayers; gPlayers < MAX_PLAYERS; gPlayers++ )
- {
- if ( gPlayers == player_VotingPlayer[playerid]) return 0;
- SendClientMessage(gPlayers, 0xFFFFFFFF, vStr);
- ShowPlayerDialog(gPlayers, DIALOG_VOTEKICK+1, DIALOG_STYLE_MSGBOX, "{09C6DB}2K-VOTE: Votekick?", vStr2, "No", "Yes");
- SetTimer("VoteKick", VOTEKICK_TIME*1000, false);
- }
- global_Cooldown = true;
- }
- }
- }
- }
- }
- case DIALOG_VOTEKICK+1:
- {
- if( response ) //They voted no!
- {
- global_VoteNo++;
- SendClientMessage(playerid, 0xFFFFFFFF, "< You have voted no on the votekick!");
- }
- else if( !response )
- {
- global_VoteYes++;
- SendClientMessage(playerid, 0xFFFFFFFF, "< You have voted yes on the votekick!");
- }
- }
- }
- return true;
- }
- forward VoteKick();
- public VoteKick()
- {
- new
- vStr[128],
- c_Name[MAX_PLAYER_NAME]
- ;
- GetPlayerName(global_PlayerBeingVoted, c_Name, sizeof(c_Name));
- if(global_VoteNo < global_VoteYes) {
- //They have successfully votekicked the user.
- format(vStr, sizeof(vStr), "{09C6DB}<ATN> {FFFFFF}%s has been votekicked.", c_Name);
- SendClientMessageToAll(0xFFFFFFFF, vStr);
- Kick(global_PlayerBeingVoted);
- }
- else if(global_VoteYes < global_VoteNo) {
- //The Votekick has failed.
- format(vStr, sizeof(vStr), "{09C6DB}<ATN> {FFFFFF}%s has not been votekicked.", c_Name);
- SendClientMessageToAll(0xFFFFFFFF, vStr);
- }
- global_VoteNo = 0, global_VoteYes = 0;
- global_PlayerBeingVoted = -1;
- return true;
- }
- public OnPlayerDisconnect(playerid, reason) {
- return true;
- }
- public OnFilterScriptExit() {
- print("2K-VOTE has been unloaded.");
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement