Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ========================================================================
- ~> Sistema de Vote Kick - TextDraw's @simples@
- By: @Riichard
- ========================================================================
- */
- // ========== [Includes] ========== //
- #include <a_samp>
- #include <zcmd>
- // ========== [Defines] ========== //
- #define rdMotivo 2803 // DIALOGID #conflitos, cuidado.
- #define kSegundos 60 // 60 segundos | 1 minuto.
- // ========== [Variaveis] ========== //
- new
- rVotosPos,
- rVotosNeg,
- bool:rVotou[MAX_PLAYERS],
- rTempo = kSegundos,
- pID,
- VoteKickEx
- ;
- // ========== [TextDraw's] ========== //
- new
- Text:rVote[10]
- ;
- // ================================== //
- public OnFilterScriptInit()
- {
- rVotosPos = 0;
- rVotosNeg = 0;
- CriarTDs();
- return print(" [FilterScript] @r - Vote Kick [TextDraw's] #CARREGADO.");
- }
- public OnFilterScriptExit()
- {
- ExcluirTDs();
- return print(" [FilterScript] @r - Vote Kick [TextDraw's] #DESCARREGADO.");
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(rTempo < kSegundos)
- {
- if(rVotou[playerid] == true) return 1;
- if(playerid == pID) return 1;
- if(newkeys & KEY_YES)
- {
- rVotosPos += 1;
- TextDrawHideForPlayer(playerid, rVote[3]);
- TextDrawSetString(rVote[4], "~r~~h~Voto confirmado!");
- rVotou[playerid] = true;
- }
- if(newkeys & KEY_NO)
- {
- rVotosNeg += 1;
- TextDrawHideForPlayer(playerid, rVote[3]);
- TextDrawSetString(rVote[4], "~r~~h~Voto confirmado!");
- rVotou[playerid] = true;
- }
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new
- tString[100]
- ;
- if (dialogid == rdMotivo)
- {
- if(response)
- {
- if(!strlen(inputtext))
- return ShowPlayerDialog(playerid, rdMotivo, DIALOG_STYLE_INPUT, "(@r) Vote Kick", "Digite o motivo:", "Abrir", "Cancelar");
- format(tString, sizeof(tString), "%s", rNome(pID));
- TextDrawSetString(rVote[1], tString);
- format(tString, sizeof(tString), "Motivo: ~b~~h~%s", inputtext);
- TextDrawSetString(rVote[2], tString);
- format(tString, sizeof(tString), "~g~~h~%d segundos", rTempo);
- TextDrawSetString(rVote[6], tString);
- TextDrawSetString(rVote[3], "~w~~h~Pressione ~y~Y~w~~h~ para ~y~SIM");
- TextDrawSetString(rVote[4], "~w~~h~Pressione ~r~N~w~~h~ para ~r~NAO");
- for (new r = 0; r <MAX_PLAYERS; r++)
- {
- if(IsPlayerConnected(r))
- {
- for (new rr = 0; rr <7; rr++)
- {
- TextDrawShowForPlayer(r, rVote[rr]);
- }
- }
- }
- TextDrawHideForPlayer(pID, rVote[3]);
- TextDrawHideForPlayer(pID, rVote[4]);
- KillTimer(VoteKickEx);
- VoteKickEx = SetTimer("VoteKickTempo", 1000, true);
- }
- }
- return false;
- }
- // ====================================================================
- CMD:votekick(playerid, params[])
- {
- if(rTempo < kSegundos)
- return SendClientMessage(playerid, -1, "-ERRO- Já contém um VoteKick em aberto.");
- if(!strlen(params) || !isNumeric(params))
- return SendClientMessage(playerid, -1, "-INFO- > /VoteKick [playerid]");
- if(!IsPlayerConnected(strval(params)))
- return SendClientMessage(playerid, -1, "-ERRO- Jogador offline.");
- if(strval(params) == playerid)
- return SendClientMessage(playerid, -1, "-ERRO- Você não pode kickar você mesmo.");
- new
- String[100]
- ;
- format(String, sizeof(String), "{F8F8FF} Desejá kickar o jogador {32CD32}%s{F8F8FF}, por qual motivo?", rNome(strval(params)));
- ShowPlayerDialog(playerid, rdMotivo, DIALOG_STYLE_INPUT, "(@r) Vote Kick", String, "Abrir", "Cancelar");
- pID = strval(params);
- return true;
- }
- stock CriarTDs()
- {
- rVote[0] = TextDrawCreate(10.000000, 159.000000, "~>~ Vote Kick");
- TextDrawFont(rVote[0], 2);
- TextDrawLetterSize(rVote[0], 0.220000, 2.200000);
- TextDrawSetOutline(rVote[0], 1);
- rVote[1] = TextDrawCreate(10.000000, 181.000000, "Nome_Player");
- TextDrawLetterSize(rVote[1], 0.380000, 1.999999);
- TextDrawSetOutline(rVote[1], 1);
- rVote[2] = TextDrawCreate(13.000000, 200.000000, "Motivo: ~b~~h~MOTIVO");
- TextDrawFont(rVote[2], 2);
- TextDrawLetterSize(rVote[2], 0.200000, 1.299999);
- TextDrawSetOutline(rVote[2], 1);
- rVote[3] = TextDrawCreate(11.000000, 240.000000, "~w~~h~Pressione ~y~Y~w~~h~ para ~y~SIM");
- TextDrawFont(rVote[3], 1);
- TextDrawLetterSize(rVote[3], 0.350000, 1.799999);
- TextDrawSetOutline(rVote[3], 1);
- rVote[4] = TextDrawCreate(11.000000, 258.000000, "~w~~h~Pressione ~r~N~w~~h~ para ~r~NAO");
- TextDrawLetterSize(rVote[4], 0.350000, 1.799999);
- TextDrawSetOutline(rVote[4], 1);
- rVote[5] = TextDrawCreate(11.000000, 221.000000, "Tempo restante:");
- TextDrawLetterSize(rVote[5], 0.220000, 1.300000);
- TextDrawSetOutline(rVote[5], 1);
- rVote[6] = TextDrawCreate(78.000000, 216.000000, "~g~~h~- segundos");
- TextDrawFont(rVote[6], 2);
- TextDrawLetterSize(rVote[6], 0.220000, 2.100000);
- TextDrawSetOutline(rVote[6], 1);
- rVote[7] = TextDrawCreate(14.000000, 259.000000, "Nome_Player foi kickado.");
- TextDrawLetterSize(rVote[7], 0.250000, 1.599999);
- TextDrawColor(rVote[7], -65281);
- TextDrawSetOutline(rVote[7], 1);
- rVote[8] = TextDrawCreate(11.000000, 221.000000, "Votos positivos: ~y~-");
- TextDrawFont(rVote[8], 2);
- TextDrawLetterSize(rVote[8], 0.250000, 1.500000);
- TextDrawSetOutline(rVote[8], 1);
- rVote[9] = TextDrawCreate(11.000000, 239.000000, "Votos negativos: ~r~~h~-");
- TextDrawFont(rVote[9], 2);
- TextDrawLetterSize(rVote[9], 0.250000, 1.500000);
- TextDrawSetOutline(rVote[9], 1);
- return true;
- }
- stock rNome(id)
- {
- new pnome[MAX_PLAYER_NAME];
- GetPlayerName(id, pnome, sizeof(pnome));
- return pnome;
- }
- stock isNumeric(const string[])
- {
- new length=strlen(string);
- if (length==0) return false;
- for (new i = 0; i < length; i++)
- {
- if (
- (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+')
- || (string[i]=='-' && i!=0)
- || (string[i]=='+' && i!=0)
- ) return false;
- }
- if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
- return true;
- }
- forward VoteKickTempo();
- public VoteKickTempo()
- {
- new tString[60];
- rTempo -= 1;
- format(tString, sizeof(tString), "~g~~h~%02d segundos", rTempo);
- TextDrawSetString(rVote[6], tString);
- if (rTempo == 0)
- {
- KillTimer(VoteKickEx);
- format(tString, sizeof(tString), "Votos positivos: ~y~%02d", rVotosPos);
- TextDrawSetString(rVote[8], tString);
- format(tString, sizeof(tString), "Votos negativos: ~r~%02d", rVotosNeg);
- TextDrawSetString(rVote[9], tString);
- if(rVotosPos > rVotosNeg)
- {
- format(tString, sizeof(tString), "%s foi kickado.", rNome(pID));
- TextDrawSetString(rVote[7], tString);
- if(rVotosPos > 1) SetTimerEx("PlayerKick", 100, false, "i", pID);
- else TextDrawSetString(rVote[7], "Tentativa de vote kick, falhou.");
- }
- else if(rVotosNeg > rVotosPos)
- {
- TextDrawSetString(rVote[7], "Tentativa de vote kick, falhou.");
- }
- else if(rVotosPos == rVotosNeg)
- {
- TextDrawSetString(rVote[7], "Tentativa de vote kick, falhou.");
- }
- for (new r = 0; r <MAX_PLAYERS; r++)
- {
- if(IsPlayerConnected(r))
- {
- for (new rr = 0; rr <sizeof(rVote); rr++)
- {
- TextDrawShowForPlayer(r, rVote[rr]);
- }
- TextDrawHideForPlayer(r, rVote[3]);
- TextDrawHideForPlayer(r, rVote[4]);
- TextDrawHideForPlayer(r, rVote[5]);
- TextDrawHideForPlayer(r, rVote[6]);
- }
- }
- SetTimer("ExcluirTDs", 5000, false);
- }
- return true;
- }
- forward ExcluirTDs();
- public ExcluirTDs()
- {
- for (new r = 0; r <MAX_PLAYERS; r++)
- {
- if(IsPlayerConnected(r))
- {
- for (new rr = 0; rr <sizeof(rVote); rr++)
- {
- TextDrawHideForPlayer(r, rVote[rr]);
- }
- rVotou[r] = false;
- }
- }
- rVotosPos = 0;
- rVotosNeg = 0;
- pID = EOS;
- rTempo = kSegundos;
- return true;
- }
- forward PlayerKick(id); public PlayerKick(id) return Kick(id);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement