Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- //----
- #define LARANJA 0xFF6600AA
- #define VERDECLARO 0x00FF0CAA
- #define VERDEMEDIO 0xa5b1A3AA
- #define BRANCO 0xFFFFFFAA
- #define VERMELHO 0xFF0000AA
- #define VERDEFRACO 0x80cf80AA
- //----
- #define NUTZ1 1
- #pragma tabsize 0
- //----
- enum e_votacao
- {
- bool:iniciada,
- sim,
- nao,
- total
- }
- new votacao[e_votacao];
- new votou[MAX_PLAYERS];
- //----
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new string[256];
- if(!strcmp(cmdtext, "/votacao", true,5))
- {
- if(IsPlayerAdmin(playerid))
- {
- if(!votacao[iniciada])
- {
- if(!strlen(cmdtext[6]))
- return SendClientMessage(playerid,0xFFFFFFAA, "Use: /votacao [texto]");
- SendClientMessageToAll(LARANJA,"====================================");
- format(string, sizeof string, "==> Nova Votação: %s?", cmdtext[6]);
- SendClientMessageToAll(VERDECLARO, string);
- SendClientMessageToAll(LARANJA,"Para votar:");
- SendClientMessageToAll(VERDEMEDIO, "Digite /votar e escolha uma das opções Sim e Não");
- SendClientMessageToAll(LARANJA,"====================================");
- votacao[iniciada] = true;
- votacao[sim] = 0;
- votacao[nao] = 0;
- GameTextForAll("~w~Nova ~r~votacao~w~ foi~b~ iniciada!",6000,3);
- for(new i; i <MAX_PLAYERS; i++)
- {
- votou[i] = false;
- }
- } else {
- SendClientMessage(playerid,BRANCO,"Ja existe uma votação em andamento!");
- }
- } else {
- SendClientMessage(playerid,BRANCO,"Você não tem permissão para usar este comando!");
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/votar", cmdtext, true) == 0)
- {
- ShowPlayerDialog(playerid, NUTZ1, DIALOG_STYLE_LIST, "Votação - By Lucky", "Sim \nNão \nEncerrar Votação", "Selecionar", "Sair");
- return 1;
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(response)
- {
- if(dialogid == NUTZ1) // GPS Dialog
- {
- if(listitem == 0) // Sim
- {
- if(votacao[iniciada] && !votou[playerid])
- {
- SendClientMessage(playerid,LARANJA, "Seu voto foi enviado com sucesso!");
- votacao[sim]++;
- votacao[total]++;
- votou[playerid] = true;
- return 1;
- }
- }
- else if(listitem == 1) // Não
- {
- if(votacao[iniciada] && !votou[playerid])
- {
- SendClientMessage(playerid,LARANJA, "Seu voto foi enviado com sucesso!");
- votacao[nao]++;
- votacao[total]++;
- votou[playerid] = true;
- return 1;
- }
- }
- else if(listitem == 2) // Encerrar Votação
- {
- if(IsPlayerAdmin(playerid))
- {
- if(votacao[iniciada])
- {
- SendClientMessageToAll(LARANJA,"====================================");
- SendClientMessageToAll(LARANJA, "==> Votacão encerrada! <<==");
- format(string, sizeof string, "> %d jogador(es) concordaram com a pergunta.", votacao[sim]);
- SendClientMessageToAll(VERDEMEDIO,string);
- format(string, sizeof string, "> %d jogador(es) discordaram com a pergunta.", votacao[nao]);
- SendClientMessageToAll(VERDEMEDIO, string);
- format(string, sizeof string, "> Esta votação teve %d votos!",votacao[total]);
- SendClientMessageToAll(BRANCO, string);
- if(votacao[sim] == votacao[nao])
- {
- SendClientMessageToAll(VERMELHO, "==> Houve um empate!");
- } else if(votacao[sim] > votacao[nao])
- {
- SendClientMessageToAll(VERMELHO, "==> A maioria CONCORDA com a pergunta.");
- } else if(votacao[sim] < votacao[nao])
- {
- SendClientMessageToAll(VERMELHO, "==> A maioria DISCORDA com a pergunta.");
- }
- SendClientMessageToAll(LARANJA,"====================================");
- GameTextForAll("~r~Votacao~w~ foi~r~ encerrada!",6000,3);
- votacao[iniciada] = false;
- votacao[sim] = 0;
- votacao[nao] = 0;
- votacao[total] = 0;
- for(new i; i <MAX_PLAYERS; i++)
- {
- votou[i] = false;
- }
- } else {
- SendClientMessage(playerid,BRANCO, "Nenhuma votação foi criada!");
- }
- } else {
- SendClientMessage(playerid,BRANCO, "Você não tem permissão para usar este comando!");
- }
- return 1;
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement