Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Sistema de Votacao com Salvamento de Enquete e Votos
- #include a_samp
- #include DOF2
- #include zcmd
- #include sscanf2
- #define QuerVotar 1234
- #define Opcao 1243
- new strvote[256];
- new bool:VotacaoIniciada;
- new Sim,Nao,Votou[MAX_PLAYERS];
- new Votacao[128];
- stock GetVotacao() return Votacao;
- forward IniciarVotacao(playerid, pergunta[]);
- forward EncerrarVotacao(playerid, pergunta[]);
- public IniciarVotacao(playerid, pergunta[])
- {
- VotacaoIniciada = true;
- Sim = 0;
- Nao = 0;
- strmid(Votacao,pergunta,0,strlen(pergunta),255);
- format(strvote,sizeof(strvote),"Votacoes/%s.ini",pergunta);
- DOF2_CreateFile(strvote);
- DOF2_SetString(strvote,"Criador",pNome(playerid));
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- format(strvote,sizeof(strvote),"Votacao Iniciada Por %s\nPergunta: %s?",pergunta);
- ShowPlayerDialog(i,QuerVotar,DIALOG_STYLE_MSGBOX,"Votacao",strvote,"VOTAR","NAO VOTAR");
- }
- return 1;
- }
- public EncerrarVotacao(playerid, pergunta[])
- {
- format(strvote,sizeof(strvote),"~r~Votacao Encerrada~r~~n~~b~Pergunta: ~w~%s~n~~g~Sim: ~w~%d~n~~r~Nao: ~w~%d",GetVotacao(),Sim,Nao);
- GameTextForAll(strvote,10000,1);
- VotacaoIniciada = false;
- format(strvote,sizeof(strvote),"Votacoes/%s.ini",GetVotacao());
- DOF2_SetInt(strvote,"Sim",Sim);
- DOF2_SetInt(strvote,"Nao",Nao);
- DOF2_SetString(strvote,"Encerrada_Por",pNome(playerid));
- DOF2_SaveFile();
- return 1;
- }
- CMD:votacao(playerid, params[])
- {
- if(VotacaoIniciada == false)
- {
- new pergunta[96];
- if(sscanf(params,"s[96]",pergunta))
- return SendClientMessage(playerid,-1,"Use /Votacao [Pergunta]");
- IniciarVotacao(playerid, pergunta);
- }
- else return SendClientMessage(playerid,-1,"Ja Esta Havendo uma Votacao");
- return 1;
- }
- CMD:encerrar(playerid, params[])
- {
- if(VotacaoIniciada == true)
- {
- #pragma unused params
- EncerrarVotacao(playerid, GetVotacao());
- }
- else return SendClientMessage(playerid,-1,"Nenhuma Votacao em Andamento!");
- return 1;
- }
- public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
- {
- if(dialogid == QuerVotar)
- {
- if(response)
- {
- format(strvote,sizeof(strvote),"Pergunta: %s",GetVotacao());
- ShowPlayerDialog(playerid,Opcao,DIALOG_STYLE_MSGBOX,"Votacao",strvote,"SIM","NAO");
- return 1;
- }
- }
- if(dialogid == Opcao)
- {
- if(!response)
- {
- if(VotacaoIniciada == true)
- {
- if(Votou[playerid] == 1)
- return SendClientMessage(playerid,-1,"Voce Ja Votou!");
- Nao ++;
- Votou[playerid] = 1;
- SendClientMessage(playerid,0xE31919,"Voto Computado Com Sucesso!");
- }
- else return SendClientMessage(playerid,-1,"Nenhuma Votacao Esta Ocorrendo.");
- return 1;
- }
- if(response)
- {
- if(VotacaoIniciada == true)
- {
- if(Votou[playerid] == 1)
- return SendClientMessage(playerid,-1,"Voce Ja Votou!");
- Sim ++;
- Votou[playerid] = 1;
- SendClientMessage(playerid,0x007700,"Voto Computado Com Sucesso!");
- }
- else return SendClientMessage(playerid,-1,"Nenhuma Votacao Esta Ocorrendo.");
- return 1;
- }
- }
- return 1;
- }
- public OnFilterScriptInit()
- {
- print(" ");
- print("==> Sistema de Votacao com Salvamento by Pedro Miranda Iniciado <==");
- print(" ");
- Sim = 0;
- Nao = 0;
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("Sistema de Votacao com Salvamento by Pedro Miranda Finalizado");
- DOF2_Exit();
- return 1;
- }
- stock pNome(playerid)
- {
- new name[24];
- GetPlayerName(playerid, name, 24);
- return name;
- }
- //Qualquer BUG Reporte em MP
Advertisement
Add Comment
Please, Sign In to add comment