Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- enum e_votacao
- {
- bool:iniciada,
- sim,
- nao,
- bool:votou[MAX_PLAYERS]
- }
- new votacao[e_votacao];
- public OnFilterScriptInit()
- {
- print("==>> Filter Script de Votacao! <<==");
- print("==>> Criado por [CCV]saalada[] <<==");
- print("==>> Ajuda de Flavio Toribio <<==");
- print("==>> Versao 0.1 BETA <<==");
- print("==>> www.ccvteam.com/forum <<==");
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new string[256];
- if(!strcmp(cmdtext, "/votacao", true, 8))
- {
- if(IsPlayerAdmin(playerid))
- {
- if(!votacao[iniciada])
- {
- if(!cmdtext[9])
- {
- SendClientMessage(playerid, 0xFFFFFFAA, "Use: /votacao [pergunta]");
- return 1;
- }
- format(string, sizeof string, "==> Votaco iniciada: %s ?", cmdtext[10]);
- SendClientMessageToAll(0xFFFFFFAA, string);
- SendClientMessageToAll(0xFFF000AA, "> Se voc concorda digite: /sim");
- SendClientMessageToAll(0xFFF000AA, "> Se voc discorda digite: /nao");
- votacao[iniciada] = true;
- votacao[sim] = 0;
- votacao[nao] = 0;
- for(new i; i < MAX_PLAYERS; i++)
- votacao[votou[i]] = false;
- } else {
- SendClientMessage(playerid, 0xFFFFFFAA,"Ja existe uma votacao em andamento!");
- }
- } else {
- SendClientMessage(playerid, 0xFFFFFFAA,"Voc no tem permisso para usar este comando!");
- }
- return 1;
- }
- if(!strcmp(cmdtext, "/sim", true))
- {
- if(votacao[iniciada] && !votacao[votou[playerid]])
- {
- SendClientMessage(playerid, 0xFFFFFFAA, "Seu voto foi computado com sucesso!");
- votacao[sim]++;
- votacao[votou[playerid]] = true;
- return 1;
- }
- return 0;
- }
- if(!strcmp(cmdtext, "/nao", true))
- {
- if(votacao[iniciada] && !votacao[votou[playerid]])
- {
- SendClientMessage(playerid, 0xFFFFFFAA, "Seu voto foi computado com sucesso!");
- votacao[nao]++;
- votacao[votou[playerid]] = true;
- return 1;
- }
- return 0;
- }
- if(!strcmp(cmdtext, "/encerrar", true))
- {
- if(IsPlayerAdmin(playerid))
- {
- if(votacao[iniciada])
- {
- SendClientMessageToAll(0xFFFFFFAA, "==> Votaco encerrada!");
- format(string, sizeof string, "> %d pessoas concordaram com a pergunta;", votacao[sim]);
- SendClientMessageToAll(0xFFF000AA,string);
- format(string, sizeof string, "> %d pessoas discordaram com a pergunta;", votacao[nao]);
- SendClientMessageToAll(0xFFF000AA, string);
- if(votacao[sim] == votacao[nao])
- {
- SendClientMessageToAll(0xFF0000AA, "==> Houve um empate!");
- } else if(votacao[sim] > votacao[nao])
- {
- SendClientMessageToAll(0xFF0000AA, "==> A maioria CONCORDA com a pergunta.");
- } else if(votacao[sim] < votacao[nao])
- {
- SendClientMessageToAll(0xFF0000AA, "==> A maioria DISCORDA com a pergunta.");
- }
- votacao[iniciada] = false;
- votacao[sim] = 0;
- votacao[nao] = 0;
- for(new i; i < MAX_PLAYERS; i++)
- votacao[votou[i]] = false;
- } else {
- SendClientMessage(playerid, 0xFFFFFFAA, "Nenhuma votacao criada!");
- }
- } else {
- SendClientMessage(playerid, 0xFFFFFFAA, "Voc no tem permisso para usar este comando!");
- }
- return 1;
- }
- return 0;
- }
- public OnPlayerConnect(playerid)
- {
- votacao[votou[playerid]] = false;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement