Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*******************************************************************************
- * ---=== [S]imple [V]ote [K]ick ===--- *
- * By Luigi96 *
- * -+- Version 1.0 -+- *
- *******************************************************************************/
- #include <a_samp>
- #define MIN_PLAYERSCORE 10000
- #define VOTEKICKTIME 15
- #define DIALOG_VOTEKICK 560
- #define RED 0xFF0000FF
- #define YELLOW 0xFFFF00FF
- #define LIGHT_BLUE 0x00CCFFFF
- /*******************************************************************************
- * ~[Enum & Variable]~ *
- *******************************************************************************/
- enum vData
- {
- Started,
- Yes,
- No,
- PlayerID,
- Timer
- };
- new VoteKickInfo[vData],
- Text:TextDrawVoteKick[5],
- str[250];
- forward VoteKickEnd();
- /*******************************************************************************
- * ~[Callback & Function]~ *
- *******************************************************************************/
- public OnFilterScriptInit()
- {
- // ============== TEXTDRAEW VOTEKICK ============== //
- TextDrawVoteKick[1] = TextDrawCreate(104.000000, 161.000000, "~y~|~g~~h~A~w~s~r~E ~w~VoteKick~y~|~n~~n~~n~~n~");
- TextDrawAlignment(TextDrawVoteKick[1], 2);
- TextDrawBackgroundColor(TextDrawVoteKick[1], 255);
- TextDrawFont(TextDrawVoteKick[1], 1);
- TextDrawLetterSize(TextDrawVoteKick[1], 0.500000, 1.000000);
- TextDrawColor(TextDrawVoteKick[1], -1);
- TextDrawSetOutline(TextDrawVoteKick[1], 1);
- TextDrawSetProportional(TextDrawVoteKick[1], 1);
- TextDrawUseBox(TextDrawVoteKick[1], 1);
- TextDrawBoxColor(TextDrawVoteKick[1], 85);
- TextDrawTextSize(TextDrawVoteKick[1], 0.000000, 130.000000);
- TextDrawVoteKick[2] = TextDrawCreate(106.000000, 173.000000, "Vuoi ~r~Kickare ~w~Nome?");
- TextDrawAlignment(TextDrawVoteKick[2], 2);
- TextDrawBackgroundColor(TextDrawVoteKick[2], 255);
- TextDrawFont(TextDrawVoteKick[2], 1);
- TextDrawLetterSize(TextDrawVoteKick[2], 0.310000, 0.799999);
- TextDrawColor(TextDrawVoteKick[2], -1);
- TextDrawSetOutline(TextDrawVoteKick[2], 0);
- TextDrawSetProportional(TextDrawVoteKick[2], 1);
- TextDrawSetShadow(TextDrawVoteKick[2], 1);
- TextDrawVoteKick[3] = TextDrawCreate(103.000000, 186.000000, "Si (0) - No (0)");
- TextDrawAlignment(TextDrawVoteKick[3], 2);
- TextDrawBackgroundColor(TextDrawVoteKick[3], 255);
- TextDrawFont(TextDrawVoteKick[3], 1);
- TextDrawLetterSize(TextDrawVoteKick[3], 0.500000, 1.000000);
- TextDrawColor(TextDrawVoteKick[3], -1);
- TextDrawSetOutline(TextDrawVoteKick[3], 0);
- TextDrawSetProportional(TextDrawVoteKick[3], 1);
- TextDrawSetShadow(TextDrawVoteKick[3], 1);
- TextDrawVoteKick[4] = TextDrawCreate(104.000000, 196.000000, "Digita ~r~/vota~w~ per votare.");
- TextDrawAlignment(TextDrawVoteKick[4], 2);
- TextDrawBackgroundColor(TextDrawVoteKick[4], 255);
- TextDrawFont(TextDrawVoteKick[4], 1);
- TextDrawLetterSize(TextDrawVoteKick[4], 0.319999, 1.000000);
- TextDrawColor(TextDrawVoteKick[4], -171);
- TextDrawSetOutline(TextDrawVoteKick[4], 0);
- TextDrawSetProportional(TextDrawVoteKick[4], 1);
- TextDrawSetShadow(TextDrawVoteKick[4], 1);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/votekick", cmdtext, true, 10) == 0)
- {
- if(GetPlayerScore(playerid) < MIN_PLAYERSCORE)
- {
- ShowPlayerDialog(playerid, DIALOG_VOTEKICK+1, DIALOG_STYLE_INPUT, "{FF0000}V{FFFFFF}otekick", "{00FF00}D{FFFFFF}igita l'id del player da kickare", "Conferma", "Cancel");
- }
- else
- {
- format(str,sizeof(str),"** Errore: {FFFFFF}Devi avere %d+ di livello per poter avviare il VoteKick {FF0000}**", MIN_PLAYERSCORE);
- SendClientMessage(playerid,RED,str);
- }
- return 1;
- }
- if (strcmp("/vota", cmdtext, true, 10) == 0)
- {
- if(VoteKickInfo[Started])
- {
- if(VoteKickInfo[PlayerID] != playerid)
- {
- format(str,sizeof(str),"{00FF00}V{FFFFFF}uoi Kickare %s",PlayerName(VoteKickInfo[PlayerID]));
- ShowPlayerDialog(playerid, DIALOG_VOTEKICK, DIALOG_STYLE_MSGBOX, "{FF0000}V{FFFFFF}otekick", str, "Si", "No");
- }
- else
- {
- SendClientMessage(playerid,RED,"** Errore: {FFFFFF}Non puoi votare su questo VoteKick {FF0000}**");
- }
- }
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DIALOG_VOTEKICK:
- {
- if(VoteKickInfo[Started])
- {
- if(response)
- {
- VoteKickInfo[Yes]++;
- SendClientMessage(playerid, LIGHT_BLUE, "** VoteKick: {FFFFFF}Hai votato: {00CCFF}Si **");
- }
- else
- {
- VoteKickInfo[No]++;
- SendClientMessage(playerid, LIGHT_BLUE, "** VoteKick: {FFFFFF}Hai votato: {00CCFF}No **");
- }
- format(str,sizeof(str),"Si (%d) - No (%d)", VoteKickInfo[Yes], VoteKickInfo[No]);
- TextDrawSetString(TextDrawVoteKick[3],str);
- TextDrawShowForAll(TextDrawVoteKick[3]);
- }
- }
- case DIALOG_VOTEKICK+1:
- {
- if(response)
- {
- new id = strval(inputtext);
- if(!IsNumeric(inputtext) || id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) return SendClientMessage(playerid,RED,"** Errore: {FFFFFF}ID/Nome non valido {FF0000}**");
- if(playerid == id) return SendClientMessage(playerid,RED,"** Errore: {FFFFFF}Non puoi far partire un Votekick su te stesso {FF0000}**");
- if(VoteKickInfo[Started] != 0) return SendClientMessage(playerid,RED,"** Errore: {FFFFFF}E' possibile far partire un VoteKick alla volta {FF0000}**");
- VoteKickInfo[PlayerID] = id;
- format(str,sizeof(str),"** %s ha iniziato un Votekick contro %s, il votekick si concluderà tra %d secondi **",PlayerName(playerid),PlayerName(id),VOTEKICKTIME);
- SendClientMessageToAll(YELLOW,str);
- TextDrawShowForAll(TextDrawVoteKick[1]);
- format(str,sizeof(str),"Vuoi ~r~Kickare ~w~%s?",PlayerName(id));
- TextDrawSetString(TextDrawVoteKick[2],str);
- TextDrawShowForAll(TextDrawVoteKick[2]);
- TextDrawSetString(TextDrawVoteKick[3],"Si (0) - No (0)");
- TextDrawShowForAll(TextDrawVoteKick[3]);
- TextDrawShowForAll(TextDrawVoteKick[4]);
- VoteKickInfo[Started] = 1;
- VoteKickInfo[Timer] = SetTimer("VoteKickEnd", VOTEKICKTIME*1000, false);
- }
- }
- }
- return 1;
- }
- public VoteKickEnd()
- {
- VoteKickInfo[Started] = 0;
- if(VoteKickInfo[Yes] <= VoteKickInfo[No])
- {
- format(str,sizeof(str),"** %s non è stato kickato dal VoteKick per mancaza di voti positivi {FFFFFF}(Si[%d] - No[%d]) {E3B515}**",PlayerName(VoteKickInfo[PlayerID]),VoteKickInfo[Yes],VoteKickInfo[No]);
- SendClientMessageToAll(YELLOW,str);
- }
- else
- {
- format(str,sizeof(str),"** %s è stato Kickato a causa del VoteKick {FFFFFF}(Si[%d] - No[%d]) {E3B515}**",PlayerName(VoteKickInfo[PlayerID]),VoteKickInfo[Yes],VoteKickInfo[No]);
- SendClientMessageToAll(YELLOW,str);
- Kick(VoteKickInfo[PlayerID]);
- }
- TextDrawHideForAll(TextDrawVoteKick[1]);
- TextDrawHideForAll(TextDrawVoteKick[2]);
- TextDrawHideForAll(TextDrawVoteKick[3]);
- TextDrawHideForAll(TextDrawVoteKick[4]);
- VoteKickInfo[Yes] = 0;
- VoteKickInfo[No] = 0;
- return 1;
- }
- /*******************************************************************************
- * ~[Stock Utili]~ *
- *******************************************************************************/
- stock PlayerName(playerid)
- {
- new Name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Name, sizeof(Name));
- return Name;
- }
- stock IsNumeric(string[])
- {
- for (new i = 0, j = strlen(string);
- i < j; i++)
- {
- if (string[i] > '9' || string[i] < '0')
- return 0;
- }
- return 1;
- }
Add Comment
Please, Sign In to add comment