Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //_______________________________________INCLUDES_________________________________________//
- #include <a_samp>
- #include <zcmd>
- #include <sscanf>
- #include <DOF2>
- #include <streamer>
- //_______________________________________DEFINES_______________________________________//
- //_________ARQUIVOS______//
- #define PASTA_USUARIOS "Contas/%s.ini"
- #define ConfigEleicao "Info Eleicao/Eleicao.ini"
- #define CANDIDATOS_ELEICAO "Info Eleicao/Candidatos.ini"
- #define VOTOS_CANDIDATOS "Info Eleicao/Votos.ini"
- #define PARTIDOS_CANDIDATOS "Info Eleicao/Partidos.ini"
- #define ID_CANDIDATO "Info Eleicao/ID.ini"
- #define URNAS "Info Eleicao/Urna %d.ini"
- #define ID_URNA "Info Eleicao/IDUrnas.ini"
- //__________LIMITES_________//
- #define MAX_CANDIDATOS 31
- #define MAX_URNAS 11
- //__________DIALOGS_________//
- #define DIALOG_VOTAR 40
- #define DIALOG_RESULTADO_VOTACAO 41
- //___________CORES__________//
- #define COR_VERDE 0xADFF2FFF
- #define COR_AZUL 0x00BFFFFF
- enum iUrna
- {
- Float:PosX,
- Float:PosY,
- Float:PosZ,
- Obj,
- Text3D:TextUrna
- };
- new InfoUrnas[MAX_URNAS][iUrna];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" By Aninhaah - ");
- print("--------------------------------------\n");
- CarregarUrnas();
- return 1;
- }
- public OnFilterScriptExit()
- {
- DOF2_Exit();
- return 1;
- }
- CMD:mecandidatar(playerid, params[])
- {
- new file[56];
- format(file, sizeof(file),PASTA_USUARIOS, Nome(playerid));
- if(!DOF2_FileExists(ConfigEleicao) || DOF2_GetBool(ConfigEleicao,"VotacaoIniciada") == true || DOF2_GetBool(ConfigEleicao,"EleicaoAberta") == false) return SendClientMessage(playerid, COR_VERDE, "Não está na época de eleição ou a votação já foi iniciada.");
- if(DOF2_FileExists(file))
- {
- if(DOF2_GetBool(file,"Candidato") == true) return SendClientMessage(playerid, COR_VERDE, "Você já é candidato.");
- if(isnull(params) || strval(params)) return SendClientMessage(playerid, COR_VERDE, "Use: /MeCandidatar [Nome Partido (sem números)]");
- DOF2_SetBool(file,"Candidato", true);
- DOF2_SetString(file, "Partido", params);
- DOF2_SaveFile();
- if(!DOF2_FileExists(CANDIDATOS_ELEICAO)) { DOF2_CreateFile(CANDIDATOS_ELEICAO); }
- if(!DOF2_FileExists(ID_CANDIDATO))
- {
- DOF2_CreateFile(ID_CANDIDATO);
- DOF2_SetInt(ID_CANDIDATO,"ID", 1);
- DOF2_SaveFile();
- }
- new tag[28];
- format(tag, sizeof(tag),"Candidato %d", DOF2_GetInt(ID_CANDIDATO,"ID"));
- DOF2_SetString(CANDIDATOS_ELEICAO, tag, Nome(playerid));
- DOF2_SaveFile();
- if(!DOF2_FileExists(VOTOS_CANDIDATOS)) { DOF2_CreateFile(VOTOS_CANDIDATOS); }
- DOF2_SetInt(VOTOS_CANDIDATOS,tag,0);
- DOF2_SaveFile();
- if(!DOF2_FileExists(PARTIDOS_CANDIDATOS)) { DOF2_CreateFile(PARTIDOS_CANDIDATOS); }
- DOF2_SetString(PARTIDOS_CANDIDATOS, tag, params);
- DOF2_SaveFile();
- DOF2_SetInt(ID_CANDIDATO,"ID", DOF2_GetInt(ID_CANDIDATO,"ID") +1);
- DOF2_SaveFile();
- new string[110];
- format(string, sizeof(string),"%s é o mais novo candidato! Partido: %s", Nome(playerid), params);
- SendClientMessageToAll(COR_AZUL, string);
- }
- else return SendClientMessage(playerid, COR_VERDE, "Sua conta não está registrada.");
- return 1;
- }
- CMD:votar(playerid)
- {
- if(!DOF2_FileExists(ConfigEleicao) || DOF2_GetBool(ConfigEleicao,"EleicaoAberta") == false) return SendClientMessage(playerid, COR_VERDE, "Não está na época de votação!");
- if(DOF2_GetBool(ConfigEleicao, "VotacaoIniciada") == false) return SendClientMessage(playerid, COR_VERDE, "Ainda não começou a votação!");
- new file[56];
- format(file, sizeof(file),PASTA_USUARIOS, Nome(playerid));
- if(DOF2_FileExists(file))
- {
- for(new u = 0; u < MAX_URNAS; u++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 2.0, InfoUrnas[u][PosX], InfoUrnas[u][PosY], InfoUrnas[u][PosZ]))
- {
- if(DOF2_GetBool(file,"JaVotou") == true) return SendClientMessage(playerid, COR_VERDE, "Você já votou.");
- new str[70],string[500];
- for(new c = 0; c < MAX_CANDIDATOS; c++)
- {
- new tag[25];
- format(tag, sizeof(tag),"Candidato %d", c);
- if(!DOF2_FileExists(CANDIDATOS_ELEICAO) || !DOF2_FileExists(PARTIDOS_CANDIDATOS)) return SendClientMessage(playerid, COR_VERDE, "Ainda não tem nenhum candidato!");
- if(DOF2_IsSet(CANDIDATOS_ELEICAO, tag))
- {
- format(str, sizeof(str),"%s (Partido: %s)\n", DOF2_GetString(CANDIDATOS_ELEICAO, tag), DOF2_GetString(PARTIDOS_CANDIDATOS, tag));
- strcat(string, str);
- }
- }
- ShowPlayerDialog(playerid, DIALOG_VOTAR, DIALOG_STYLE_LIST,"Escolha alguém para votar", string, "Votar","Cancelar");
- }
- }
- }
- return 1;
- }
- CMD:iniciareleicao(playerid)
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COR_VERDE, "Sem permissão!");
- if(!DOF2_FileExists(ConfigEleicao))
- {
- DOF2_CreateFile(ConfigEleicao);
- DOF2_SetBool(ConfigEleicao,"EleicaoAberta", true);
- DOF2_SetBool(ConfigEleicao,"VotacaoIniciada", false);
- DOF2_SaveFile();
- DOF2_CreateFile(CANDIDATOS_ELEICAO);
- DOF2_SetString(CANDIDATOS_ELEICAO,"Candidato 0", "Voto Branco");
- DOF2_SaveFile();
- DOF2_CreateFile(VOTOS_CANDIDATOS);
- DOF2_SetInt(VOTOS_CANDIDATOS,"Candidato 0", 0);
- DOF2_SaveFile();
- DOF2_CreateFile(PARTIDOS_CANDIDATOS);
- DOF2_SetString(PARTIDOS_CANDIDATOS,"Candidato 0", "Nenhum");
- DOF2_SaveFile();
- SendClientMessageToAll(COR_AZUL, "Foi iniciada a nova eleição! Se candidate (/mecandidatar)");
- }
- else
- {
- if(DOF2_GetBool(ConfigEleicao,"EleicaoAberta") == true) return SendClientMessage(playerid, COR_VERDE, "A eleição já começou, termine essa eleição! (/terminareleicao)");
- DOF2_SetBool(ConfigEleicao,"EleicaoAberta", true);
- DOF2_SetBool(ConfigEleicao,"VotacaoIniciada", false);
- DOF2_SaveFile();
- DOF2_CreateFile(CANDIDATOS_ELEICAO);
- DOF2_SetString(CANDIDATOS_ELEICAO,"Candidato 0", "Voto Branco");
- DOF2_SaveFile();
- DOF2_CreateFile(VOTOS_CANDIDATOS);
- DOF2_SetInt(VOTOS_CANDIDATOS,"Candidato 0", 0);
- DOF2_SaveFile();
- SendClientMessageToAll(COR_AZUL, "Foi iniciada a nova eleição! Se candidate (/mecandidatar)");
- }
- return 1;
- }
- CMD:terminareleicao(playerid)
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COR_VERDE, "Sem permissão!");
- if(!DOF2_FileExists(ConfigEleicao)) return SendClientMessage(playerid, COR_VERDE, "Não foi iniciada nenhuma eleição!");
- if(DOF2_GetBool(ConfigEleicao,"EleicaoAberta") == false) return SendClientMessage(playerid, COR_VERDE, "Não está tendo eleição, comece uma eleição! (/iniciareleicao)");
- if(DOF2_GetBool(ConfigEleicao,"VotacaoIniciada") == true) return SendClientMessage(playerid,COR_VERDE,"A votação já foi iniciada.");
- DOF2_SetBool(ConfigEleicao,"EleicaoAberta", true);
- DOF2_SetBool(ConfigEleicao,"VotacaoIniciada", true);
- DOF2_SaveFile();
- SendClientMessageToAll(COR_AZUL, "O prazo para se candidatar acabou. As votações já começaram!");
- SendClientMessage(playerid,COR_AZUL,"Use: /terminarvotacao para terminar.");
- return 1;
- }
- CMD:terminarvotacao(playerid)
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COR_VERDE, "Sem permissão!");
- if(!DOF2_FileExists(ConfigEleicao)) return SendClientMessage(playerid, COR_VERDE, "Não foi iniciada nenhuma eleição!");
- if(DOF2_GetBool(ConfigEleicao,"VotacaoIniciada") == false) return SendClientMessage(playerid, COR_VERDE, "Não está tendo votação, comece uma eleição! (/iniciareleicao)");
- DOF2_SetBool(ConfigEleicao,"EleicaoAberta", false);
- DOF2_SetBool(ConfigEleicao,"VotacaoIniciada", false);
- DOF2_SaveFile();
- new string[500], str[70];
- for(new c = 0; c < MAX_CANDIDATOS; c++)
- {
- new tag[25];
- format(tag, sizeof(tag),"Candidato %d", c);
- if(DOF2_IsSet(CANDIDATOS_ELEICAO, tag) && DOF2_IsSet(VOTOS_CANDIDATOS, tag))
- {
- format(str, sizeof(str),"Candidato %s: %d votos\n", DOF2_GetString(CANDIDATOS_ELEICAO, tag), DOF2_GetInt(VOTOS_CANDIDATOS, tag));
- strcat(string, str);
- }
- }
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- ShowPlayerDialog(i, DIALOG_RESULTADO_VOTACAO, DIALOG_STYLE_MSGBOX,"RESULTADO DAS ELEIÇÕES!", string, "Fechar","");
- }
- DOF2_RemoveFile(ConfigEleicao);
- DOF2_RemoveFile(ID_CANDIDATO);
- DOF2_RemoveFile(VOTOS_CANDIDATOS);
- DOF2_RemoveFile(CANDIDATOS_ELEICAO);
- DOF2_RemoveFile(PARTIDOS_CANDIDATOS);
- for(new u = 0; u < MAX_URNAS; u++)
- {
- DestroyDynamicObject(InfoUrnas[u][Obj]);
- Delete3DTextLabel(InfoUrnas[u][TextUrna]);
- }
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- new file[56];
- format(file, sizeof(file),PASTA_USUARIOS, Nome(i));
- if(DOF2_FileExists(file))
- {
- DOF2_Unset(file,"JaVotou");
- DOF2_Unset(file,"Candidato");
- DOF2_Unset(file,"Partido");
- DOF2_SaveFile();
- }
- }
- return 1;
- }
- CMD:criarurna(playerid)
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COR_VERDE, "Sem permissao!");
- if(!DOF2_FileExists(ConfigEleicao) || DOF2_GetBool(ConfigEleicao,"EleicaoAberta") == false) return SendClientMessage(playerid, COR_VERDE, "As eleições não começaram!");
- new Float:Pos[3];
- GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
- if(!DOF2_FileExists(ID_URNA))
- {
- DOF2_CreateFile(ID_URNA);
- DOF2_SetInt(ID_URNA,"ID", 0);
- DOF2_SaveFile();
- }
- new arq[25], IDU = DOF2_GetInt(ID_URNA,"ID");
- format(arq, sizeof(arq),URNAS, IDU);
- if(!DOF2_FileExists(arq))
- {
- DOF2_CreateFile(arq);
- DOF2_SetFloat(arq, "PosX", Pos[0]);
- DOF2_SetFloat(arq, "PosY", Pos[1]);
- DOF2_SetFloat(arq, "PosZ", Pos[2]);
- DOF2_SaveFile();
- new string[100];
- format(string, sizeof(string),"Urna %d criada com sucesso!", IDU);
- SendClientMessage(playerid, COR_AZUL, string);
- InfoUrnas[IDU][Obj] = CreateDynamicObject(3013, Pos[0], Pos[1], Pos[2], 0,0,0);
- InfoUrnas[IDU][TextUrna] = Create3DTextLabel("Urna de eleição!\nUse: /votar", -1, Pos[0], Pos[1], Pos[2], 14.0,0,0);
- InfoUrnas[IDU][PosX] = Pos[0];
- InfoUrnas[IDU][PosY] = Pos[1];
- InfoUrnas[IDU][PosZ] = Pos[2];
- }
- DOF2_SetInt(ID_URNA,"ID", DOF2_GetInt(ID_URNA,"ID") +1);
- DOF2_SaveFile();
- return 1;
- }
- CMD:editarpartido(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COR_VERDE,"Sem permissão!");
- new nome[MAX_PLAYER_NAME], partido[30];
- if(sscanf(params,"ss", nome, partido)) return SendClientMessage(playerid, COR_VERDE,"Use: /EditarPartido [Nick completo] [Nome do novo partido]");
- new file[56];
- format(file, sizeof(file),PASTA_USUARIOS, nome);
- if(!DOF2_FileExists(file)) return SendClientMessage(playerid, COR_VERDE,"Essa conta não existe.");
- if(!DOF2_IsSet(file,"Candidato") || DOF2_GetBool(file,"Candidato") == false) return SendClientMessage(playerid, COR_VERDE,"Esse jogador não é um candidato.");
- DOF2_SetString(file,"Partido", partido);
- DOF2_SaveFile();
- new string[110];
- format(string, sizeof(string),"Partido de %s mudado para %s.", nome, partido);
- SendClientMessage(playerid, COR_AZUL, string);
- printf("%s mudou o nome do partido de %s para %s.", Nome(playerid), nome, partido);
- return 1;
- }
- CMD:pp(playerid, params[])
- {
- new file[56];
- format(file, sizeof(file),PASTA_USUARIOS, Nome(playerid));
- if(!DOF2_FileExists(file) || !DOF2_IsSet(file,"Candidato") || !DOF2_IsSet(file,"Partido") || DOF2_GetBool(file,"Candidato") == false) return SendClientMessage(playerid, COR_VERDE, "Você não é um candidato.");
- if(isnull(params)) return SendClientMessage(playerid, COR_VERDE,"Use: /PP [Texto]");
- new string[128];
- format(string, sizeof(string),"[%s] %s: %s", DOF2_GetString(file,"Partido"), Nome(playerid), params);
- SendClientMessageToAll(COR_AZUL, "|__________________________Propaganda Política__________________________|");
- SendClientMessageToAll(-1, string);
- SendClientMessageToAll(COR_AZUL,"|______________________________________________________________________|");
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_VOTAR)
- {
- if(!response) return SendClientMessage(playerid, COR_VERDE, "Você cancelou a votação!");
- new cand = listitem;
- new tag[25];
- format(tag, sizeof(tag),"Candidato %d", cand);
- if(DOF2_IsSet(VOTOS_CANDIDATOS,tag))
- {
- DOF2_SetInt(VOTOS_CANDIDATOS, tag, DOF2_GetInt(VOTOS_CANDIDATOS,tag)+1);
- DOF2_SaveFile();
- }
- new string[90];
- format(string, sizeof(string),"Você votou em %s!", DOF2_GetString(CANDIDATOS_ELEICAO,tag));
- SendClientMessage(playerid, COR_AZUL, string);
- new file[56];
- format(file, sizeof(file),PASTA_USUARIOS, Nome(playerid));
- if(!DOF2_FileExists(file)) return 1;
- DOF2_SetBool(file,"JaVotou", true);
- DOF2_SaveFile();
- return 1;
- }
- return 1;
- }
- Nome(playerid)
- {
- new nome[MAX_PLAYER_NAME];
- GetPlayerName(playerid, nome, sizeof(nome));
- return nome;
- }
- stock CarregarUrnas()
- {
- new count;
- for(new u = 0; u < MAX_URNAS; u++)
- {
- new file[56];
- format(file, sizeof(file), URNAS, u);
- if(DOF2_FileExists(file) && DOF2_FileExists(ConfigEleicao) && DOF2_GetBool(ConfigEleicao,"EleicaoAberta") == true)
- {
- InfoUrnas[u][PosX] = DOF2_GetFloat(file,"PosX");
- InfoUrnas[u][PosY] = DOF2_GetFloat(file,"PosY");
- InfoUrnas[u][PosZ] = DOF2_GetFloat(file,"PosZ");
- InfoUrnas[u][Obj] = CreateDynamicObject(3013, InfoUrnas[u][PosX], InfoUrnas[u][PosY], InfoUrnas[u][PosZ], 0,0,0);
- InfoUrnas[u][TextUrna] = Create3DTextLabel("Urna de eleição!\nUse: /votar", -1, InfoUrnas[u][PosX], InfoUrnas[u][PosY], InfoUrnas[u][PosZ], 14.0,0);
- count++;
- }
- }
- printf("%d urnas carregadas!", count);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement