Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ================================================================================
- Phanto's Script
- ________________________________________________________________________________
- •Script: PVoteKick •Scripter: Phanto90
- •Type: FS •File size: 6 Kb
- •Lines: 261 •Version: 1.0v
- ________________________________________________________________________________
- * Description *
- Have you problems when there are no admin on your server? Hare a simple votekick
- system that permits to normal players to start a votekick for a player.
- Thanks for choosing Pawnoscripter!
- http://pawnoscripter.forumfree.it
- Phanto90
- ________________________________________________________________________________
- Do not remove credits.
- ================================================================================
- */
- //===============INCLUDE
- #include <a_samp>
- //===============COLORI
- #define COLOR_ERROR 0xCB544EFF
- #define COLOR_OK 0x50C94EFF
- //===============DIALOG
- #define DIALOG_VOTEKICK 1945
- //===============VAR
- new bool:IsVoteKickStarted,
- bool:HasPlayerVoted[MAX_PLAYERS];
- new PlayerToKick=-1,
- Yes,No,
- seconds=60;
- new string[135],
- name[24],
- name2[24];
- new Text: Background,
- Text: VoteKickTitle,
- Text: VoteKickName,
- Text: VoteKickVote,
- Text: VoteKickTime;
- //============================================================ONFILTERSCRIPTINIT
- public OnFilterScriptInit()
- {
- Background = TextDrawCreate(493.000000, 230.000000, "Background");
- TextDrawBackgroundColor(Background, 0);
- TextDrawFont(Background, 1);
- TextDrawLetterSize(Background, 0.500000, 6.099999);
- TextDrawColor(Background, 0);
- TextDrawSetOutline(Background, 0);
- TextDrawSetProportional(Background, 1);
- TextDrawSetShadow(Background, 1);
- TextDrawUseBox(Background, 1);
- TextDrawBoxColor(Background, 1010580580);
- TextDrawTextSize(Background, 616.000000, 0.000000);
- VoteKickTitle = TextDrawCreate(497.000000, 211.000000, "~>~Votekick~<~");
- TextDrawBackgroundColor(VoteKickTitle, 255);
- TextDrawFont(VoteKickTitle, 0);
- TextDrawLetterSize(VoteKickTitle, 0.660000, 2.599999);
- TextDrawColor(VoteKickTitle, -1);
- TextDrawSetOutline(VoteKickTitle, 1);
- TextDrawSetProportional(VoteKickTitle, 1);
- VoteKickVote = TextDrawCreate(555.000000, 254.000000, "~g~~h~Yes~w~: 0 ~r~No~w~: 0");
- TextDrawAlignment(VoteKickVote, 2);
- TextDrawBackgroundColor(VoteKickVote, 255);
- TextDrawFont(VoteKickVote, 2);
- TextDrawLetterSize(VoteKickVote, 0.390000, 2.199999);
- TextDrawColor(VoteKickVote, -1);
- TextDrawSetOutline(VoteKickVote, 1);
- TextDrawSetProportional(VoteKickVote, 1);
- VoteKickTime = TextDrawCreate(601.000000, 273.000000, "60");
- TextDrawBackgroundColor(VoteKickTime, 255);
- TextDrawFont(VoteKickTime, 2);
- TextDrawLetterSize(VoteKickTime, 0.250000, 1.500000);
- TextDrawColor(VoteKickTime, -926365441);
- TextDrawSetOutline(VoteKickTime, 1);
- TextDrawSetProportional(VoteKickTime, 1);
- VoteKickName = TextDrawCreate(555.000000, 241.000000, "Player_Name");
- TextDrawAlignment(VoteKickName, 2);
- TextDrawBackgroundColor(VoteKickName, 255);
- TextDrawFont(VoteKickName, 1);
- TextDrawLetterSize(VoteKickName, 0.280000, 1.300000);
- TextDrawColor(VoteKickName, -1);
- TextDrawSetOutline(VoteKickName, 1);
- TextDrawSetProportional(VoteKickName, 1);
- return 1;
- }
- //===============================================================ONPLAYERCONNECT
- public OnPlayerConnect(playerid)
- {
- if(IsVoteKickStarted == true)
- {
- TextDrawShowForPlayer(playerid, Background); //Prevent bugs in case a player connects while a votekick is started
- TextDrawShowForPlayer(playerid, VoteKickTitle);
- TextDrawShowForPlayer(playerid, VoteKickName);
- TextDrawShowForPlayer(playerid, VoteKickVote);
- TextDrawShowForPlayer(playerid, VoteKickTime);
- return 1;
- }
- return 1;
- }
- //===========================================================ONPLAYERCOMMANDTEXT
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp("/votekick", cmdtext, true))
- {
- if(IsVoteKickStarted == true) return SendClientMessage(playerid, COLOR_ERROR,"[ERROR:] {BBBBBB}A votekick has been already started. Wait until it finish to ask for a new one");
- ShowPlayerDialog(playerid, DIALOG_VOTEKICK, DIALOG_STYLE_INPUT, "{C14124}V{BBBBBB}otekick", "{BBBBBB}Type player's {C14124}ID{BBBBBB} or {C14124}Nick{BBBBBB} you want to votekick.", "VoteKick", "Cancel");
- return 1;
- }
- return 1;
- }
- //============================================================ONPLAYERDISCONNECT
- public OnPlayerDisconnect(playerid)
- {
- if(PlayerToKick == playerid)
- {
- GetPlayerName(playerid, name, sizeof(name));
- format(string, sizeof(string), "{C14124}%s{BBBBBB} exited the server, so the votekick has been closed automatically.", name);
- SendClientMessageToAll(COLOR_OK, string);
- Yes=0,No=0,PlayerToKick=-1, seconds=60, IsVoteKickStarted=false;
- TextDrawHideForAll(Background);
- TextDrawHideForAll(VoteKickTitle);
- TextDrawHideForAll(VoteKickName);
- TextDrawHideForAll(VoteKickVote);
- TextDrawSetString(VoteKickVote,"~g~~h~Yes~w~: 0 ~r~No~w~: 0");
- TextDrawHideForAll(VoteKickTime);
- return 1;
- }
- return 1;
- }
- //==============================================================ONDIALOGRESPONSE
- public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
- {
- if(dialogid==DIALOG_VOTEKICK && response)
- {
- if(IsVoteKickStarted == true) return SendClientMessage(playerid, COLOR_ERROR,"[ERROR:] {BBBBBB}A votekick has been already started. Wait until it finish to ask for a new one");
- if(IsNumeric(inputtext)) StartVoteKick(strval(inputtext));
- else
- {
- for(new i = 0; i<MAX_PLAYERS; i++)
- {
- GetPlayerName(playerid, name, sizeof(name));
- if(!strcmp(inputtext, name, true))
- {
- StartVoteKick(i);
- break;
- }
- }
- }
- if(PlayerToKick == -1) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR:] {BBBBBB}Player not found.");
- GetPlayerName(playerid, name2, sizeof(name2));
- format(string, sizeof(string), "{C14124}%s{BBBBBB} has started a votekick for {C14124}%s{BBBBBB}. Type {60B149}Yes{BBBBBB} or {B35349}No{BBBBBB} to vote.", name2, name);
- SendClientMessageToAll(COLOR_OK, string);
- return 1;
- }
- return 1;
- }
- //=================================================================STARTVOTEKICK
- stock StartVoteKick(playerid)
- {
- if(!IsPlayerConnected(playerid)) return 0;
- PlayerToKick = playerid;
- IsVoteKickStarted = true;
- TextDrawShowForAll(Background);
- TextDrawShowForAll(VoteKickTitle);
- TextDrawShowForAll(VoteKickName);
- GetPlayerName(playerid,name,sizeof(name));
- TextDrawSetString(VoteKickName,name);
- TextDrawShowForAll(VoteKickVote);
- TextDrawShowForAll(VoteKickTime);
- for(new i = 0; i<MAX_PLAYERS; i++)
- HasPlayerVoted[i] = false;
- SetTimer("KickTimer",1000,false);
- return 1;
- }
- //======================================================================KICKTIME
- forward KickTimer();
- public KickTimer()
- {
- if(PlayerToKick == -1) return 1;
- if(seconds == 0) return EndVoteKick();
- seconds--;
- format(string,sizeof(string),"%02d",seconds);
- TextDrawHideForAll(VoteKickTime);
- TextDrawSetString(VoteKickTime, string);
- TextDrawShowForAll(VoteKickTime);
- SetTimer("KickTimer",1000,false);
- return 1;
- }
- //===================================================================ENDVOTEKICK
- stock EndVoteKick()
- {
- GetPlayerName(PlayerToKick, name, sizeof(name));
- if(Yes>No)
- {
- format(string, sizeof(string), "{C14124}%s {BBBBBB}has been votekicked. [%d Yes | %d No]", name, Yes, No);
- Kick(PlayerToKick);
- }
- else
- {
- format(string, sizeof(string), "{C14124}%s {BBBBBB}has not been kicked. [%d Yes | %d No]", name, Yes, No);
- }
- SendClientMessageToAll(COLOR_OK, string);
- Yes=0,No=0,PlayerToKick=-1, seconds=60, IsVoteKickStarted=false;
- TextDrawHideForAll(Background);
- TextDrawHideForAll(VoteKickTitle);
- TextDrawHideForAll(VoteKickName);
- TextDrawHideForAll(VoteKickVote);
- TextDrawSetString(VoteKickVote,"~g~~h~Yes~w~: 0 ~r~No~w~: 0");
- TextDrawHideForAll(VoteKickTime);
- return 1;
- }
- //=====================================================================ISNUMERIC
- stock IsNumeric(str[])
- {
- for(new i=0; i<strlen(str); i++)
- {
- if(str[i]<'0' || str[i]>'9')
- return 0;
- }
- return 1;
- }
- //==================================================================ONPLAYERTEXT
- public OnPlayerText(playerid, text[])
- {
- if(!strcmp("Yes", text, true) && strlen(text)==strlen("Yes") && IsVoteKickStarted == true && HasPlayerVoted[playerid] == false)
- {
- Yes++;
- HasPlayerVoted[playerid]= true;
- SendClientMessage(playerid, COLOR_OK, "[VOTE:] {BBBBBB}Thanks for voting!");
- format(string,sizeof(string), "~g~~h~Yes~w~: %d ~r~No~w~: %d", Yes, No);
- TextDrawHideForAll(VoteKickVote);
- TextDrawSetString(VoteKickVote,string);
- TextDrawShowForAll(VoteKickVote);
- return 0;
- }
- if(!strcmp("No", text, true) && strlen(text)==strlen("No") && IsVoteKickStarted == true && HasPlayerVoted[playerid] == false)
- {
- No++;
- HasPlayerVoted[playerid]= true;
- SendClientMessage(playerid, COLOR_OK, "[VOTE:] {BBBBBB}Thanks for voting!");
- format(string,sizeof(string), "~g~~h~Yes~w~: %d ~r~No~w~: %d", Yes, No);
- TextDrawHideForAll(VoteKickVote);
- TextDrawSetString(VoteKickVote,string);
- TextDrawShowForAll(VoteKickVote);
- return 0;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement