Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Sistema de votação - TextDraw e dialog
- Autor: Hardware - Bryan.
- Qualquer um poderá usar esse sistema, desde que use os créditos.
- */
- #include <a_samp>
- #define Votacao 20
- new
- bool:ECriada,
- sim,
- nao,
- nick[MAX_PLAYER_NAME],
- bool:jvotou,
- adminmsg[128]
- ;
- new
- Text:R,
- Text:S,
- Text:N,
- Text:T,
- Text:RF
- ;
- forward VSair(playerid);
- public OnGameModeInit()
- {
- R = TextDrawCreate(2.000000, 155.000000, "- Numero de votos:");
- TextDrawBackgroundColor(R, 255);
- TextDrawFont(R, 1);
- TextDrawLetterSize(R, 0.500000, 1.000000);
- TextDrawColor(R, 9127423);
- TextDrawSetOutline(R, 0);
- TextDrawSetProportional(R, 1);
- TextDrawSetShadow(R, 1);
- S = TextDrawCreate(2.000000, 183.000000, "Sim:");
- TextDrawBackgroundColor(S, 255);
- TextDrawFont(S, 1);
- TextDrawLetterSize(S, 0.500000, 1.000000);
- TextDrawColor(S, -2686721);
- TextDrawSetOutline(S, 0);
- TextDrawSetProportional(S, 1);
- TextDrawSetShadow(S, 1);
- N = TextDrawCreate(52.000000, 182.000000, "Nao:");
- TextDrawBackgroundColor(N, 255);
- TextDrawFont(N, 1);
- TextDrawLetterSize(N, 0.500000, 1.000000);
- TextDrawColor(N, -2686721);
- TextDrawSetOutline(N, 0);
- TextDrawSetProportional(N, 1);
- TextDrawSetShadow(N, 1);
- T = TextDrawCreate(106.000000, 183.000000, "Total:");
- TextDrawBackgroundColor(T, 255);
- TextDrawFont(T, 1);
- TextDrawLetterSize(T, 0.500000, 1.000000);
- TextDrawColor(T, -2686721);
- TextDrawSetOutline(T, 0);
- TextDrawSetProportional(T, 1);
- TextDrawSetShadow(T, 1);
- RF = TextDrawCreate(1.000000, 211.000000, "Resultado Final:");
- TextDrawBackgroundColor(RF, 255);
- TextDrawFont(RF, 1);
- TextDrawLetterSize(RF, 0.500000, 1.000000);
- TextDrawColor(RF, 1618709503);
- TextDrawSetOutline(RF, 0);
- TextDrawSetProportional(RF, 1);
- TextDrawSetShadow(RF, 1);
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new texto[128];
- if(!strcmp(cmdtext,"/votacao",true))
- {
- if(!IsPlayerAdmin(playerid))
- return SendClientMessage(playerid, -1, "Você não é administrador!");
- if(ECriada == true)
- return SendClientMessage(playerid, -1,"Já existe uma votação iniciada!");
- ShowPlayerDialog(playerid,Votacao,DIALOG_STYLE_INPUT,"Iniciando a votação","Digite a pergunta para iniciar a votação:","Ok","Cancelar");
- return 1;
- }
- if(!strcmp(cmdtext,"/votar",true))
- {
- if(ECriada == false)
- return SendClientMessage(playerid, -1,"Não existe nenhuma votação feita!");
- if(jvotou == true)
- return SendClientMessage(playerid, -1,"Desculpe, mas você já votou e não poderá votar novamente!");
- format(texto,sizeof texto,"%s",adminmsg);
- ShowPlayerDialog(playerid,Votacao+1,DIALOG_STYLE_MSGBOX,"Escolha a sua resposta para a pergunta.",texto,"Sim","Não");
- return 1;
- }
- if(!strcmp(cmdtext,"/fecharv",true))
- {
- new msgvotos[128],msg2[128],msg3[128];
- if(!IsPlayerAdmin(playerid))
- return SendClientMessage(playerid, -1, "Você não é administrador!");
- if(ECriada == false)
- return SendClientMessage(playerid, -1,"Não existe nenhuma votação feita!");
- new totalvotos = (sim + nao);
- format(msgvotos,sizeof msgvotos,"Sim:%d",sim);
- format(msg2,sizeof msgvotos,"Nao:%d",nao);
- format(msg3,sizeof msgvotos,"Total:%d",totalvotos);
- for(new i; i<MAX_PLAYERS; i++)
- {
- TextDrawShowForPlayer(i,R);
- TextDrawShowForPlayer(i,S);
- TextDrawShowForPlayer(i,N);
- TextDrawShowForPlayer(i,T);
- TextDrawShowForPlayer(i,RF);
- TextDrawSetString(S,msgvotos);
- TextDrawSetString(N,msg2);
- TextDrawSetString(T,msg3);
- SetTimerEx("VSair",5000,false,"i",i);
- if(jvotou == true)
- {
- jvotou = false;
- }
- }
- if(sim == nao) return TextDrawSetString(RF,"A votacao empatou!");
- if(sim > nao)
- {
- TextDrawSetString(RF,"A maioria votou em 'Sim'.");
- }
- else
- {
- TextDrawSetString(RF,"A maioria votou em 'Nao'");
- }
- sim = 0;
- nao = 0;
- ECriada = false;
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == Votacao)
- {
- if(!response)
- return SendClientMessage(playerid, -1, "Você cancelou a criação da votação.");
- GetPlayerName(playerid, nick,MAX_PLAYER_NAME);
- SendClientMessageToAll(-1,"• ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ •");
- format(adminmsg,sizeof adminmsg,"» O administrador %s, criou uma enquete.",nick);
- SendClientMessageToAll(-1,adminmsg);
- format(adminmsg,sizeof adminmsg,"» Pergunta: %s",inputtext);
- SendClientMessageToAll(-1,adminmsg);
- SendClientMessageToAll(-1,"• ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ •");
- ECriada = true;
- return 1;
- }
- if(dialogid == Votacao+1)
- {
- if(response)
- {
- sim++;
- jvotou = true;
- SendClientMessage(playerid,-1,"Você votou na opção 'Sim'");
- }
- else
- {
- nao++;
- jvotou = true;
- SendClientMessage(playerid, -1, "Você votou na opção 'Não'");
- }
- }
- return 1;
- }
- public VSair(playerid)
- {
- for(new i; i<MAX_PLAYERS; i++)
- {
- TextDrawHideForPlayer(i,R);
- TextDrawHideForPlayer(i,S);
- TextDrawHideForPlayer(i,N);
- TextDrawHideForPlayer(i,T);
- TextDrawHideForPlayer(i,RF);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement