Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <dof2>
- #define MAX_BILHETES 4//Máximo de bilhetes permitido por player, aqui vai dar 3 bilhetes (tem que ser o máximo +1)
- #define TEMPO_SORTEIO 60//Coloca o tempo em minutos
- #define MAIOR_NUMERO 100 //Maior numero que vai poder ser sorteado
- #define PRECO_BILHETE 2 //Preço do bilhete
- #define ARQUIVO_JOGADOR "Contas/%s.ini" // Pasta onde fica salvo os jogadores
- #define ArqPremio "LoteriaPremio.ini" // Onde vai ficar o arquivo com o premio, aqui tá na pasta scriptfiles, mas pode ser mudada a pasta
- #define COR_VERDE 0x7CFC00FF
- #define COR_AMARELO 0xFFFF00FF
- new Bilhetes[MAX_PLAYERS][MAX_BILHETES];
- new Premio;
- forward Sorteio();
- randomminimo(min, max)
- {
- return random(max-min) +min;
- }
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("aLoteric v1.0 by Aninhaah/HumildadeForever");
- print("--------------------------------------\n");
- CarregarPremio();
- SetTimer("Sorteio", TEMPO_SORTEIO*60000, true);
- return 1;
- }
- public OnFilterScriptExit()
- {
- DOF2_Exit();
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- CarregarBilhetes(playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- SalvarBilhetes(playerid);
- return 1;
- }
- CMD:bilhete(playerid, params[])
- {
- new bool:contar = false;
- for(new b = 1; b < MAX_BILHETES; b++)
- {
- if(Bilhetes[playerid][b] == strval(params)) return SendClientMessage(playerid, COR_AMARELO, "Você já tem um bilhete com esse número.");
- if(Bilhetes[playerid][b] < 1)
- {
- if(isnull(params) || !strval(params)) return SendClientMessage(playerid, COR_AMARELO, "Use: /Bilhete [Numero (Não vale o 0)]");
- if(GetPlayerMoney(playerid) < PRECO_BILHETE) return SendClientMessage(playerid, COR_AMARELO, "Você não tem dinheiro suficiente.");
- if(strval(params) > MAIOR_NUMERO) return SendClientMessage(playerid, COR_AMARELO, "Bilhete invalido, escolha um numero menor.");
- Bilhetes[playerid][b] = strval(params);
- new string[90];
- format(string, sizeof(string),"Você comprou o bilhete número %d por R$%d.", strval(params), PRECO_BILHETE);
- SendClientMessage(playerid, COR_VERDE, string);
- GivePlayerMoney(playerid, -PRECO_BILHETE);
- Premio += PRECO_BILHETE;
- SalvarPremio();
- SalvarBilhetes(playerid);
- contar = true;
- break;
- }
- }
- if(contar == false) return SendClientMessage(playerid, COR_AMARELO, "Você já comprou o máximo de bilhetes.");
- return 1;
- }
- CMD:meusbilhetes(playerid)
- {
- new bool:contar = false;
- for(new b = 1; b < MAX_BILHETES; b++)
- {
- if(Bilhetes[playerid][b] >= 1)
- {
- new string[120];
- format(string,sizeof(string),"Bilhete %d. Número: %d\n", b, Bilhetes[playerid][b]);
- SendClientMessage(playerid, COR_VERDE, string);
- contar = true;
- }
- }
- if(contar == false) return SendClientMessage(playerid, COR_AMARELO, "Você não tem nenhum bilhete.");
- return 1;
- }
- public Sorteio()
- {
- new bilhete = randomminimo(1, MAIOR_NUMERO);
- new string[100], string2[90], bool: contar = false;
- format(string2, sizeof(string2),"O próximo sorteio será daqui %d minutos!", TEMPO_SORTEIO);
- for(new p = 0; p < MAX_PLAYERS; p++)
- {
- for(new b = 1; b < MAX_BILHETES; b++)
- {
- if(Bilhetes[p][b] == bilhete)
- {
- format(string, sizeof(string),"%s ganhou na loteria R$ %d.", Nome(p), Premio);
- GivePlayerMoney(p, Premio);
- Premio = 0;
- SalvarPremio();
- contar = true;
- }
- if(contar == false)
- {
- format(string, sizeof(string),"Ninguém ganhou na loteria! Premio acumulado para R$ %d", Premio);
- }
- Bilhetes[p][b] = 0;
- }
- }
- SendClientMessageToAll(COR_VERDE, string);
- SendClientMessageToAll(COR_VERDE, string2);
- print(string);
- print(string2);
- return 1;
- }
- Nome(playerid)
- {
- new nome[MAX_PLAYER_NAME];
- GetPlayerName(playerid, nome, sizeof(nome));
- return nome;
- }
- SalvarBilhetes(playerid)
- {
- new file[56];
- format(file, sizeof(file), ARQUIVO_JOGADOR, Nome(playerid));
- if(DOF2_FileExists(file))
- {
- for(new b = 1; b < MAX_BILHETES; b++)
- {
- new tag[25];
- format(tag, sizeof(tag),"Bilhete %d", b);
- DOF2_SetInt(file,tag, Bilhetes[playerid][b]);
- DOF2_SaveFile();
- }
- }
- return 1;
- }
- CarregarBilhetes(playerid)
- {
- new file[56];
- format(file, sizeof(file), ARQUIVO_JOGADOR, Nome(playerid));
- if(DOF2_FileExists(file))
- {
- for(new b = 1; b < MAX_BILHETES; b++)
- {
- new tag[25];
- format(tag, sizeof(tag),"Bilhete %d", b);
- if(DOF2_IsSet(file, tag))
- {
- Bilhetes[playerid][b] = DOF2_GetInt(file, tag);
- SendClientMessage(playerid, COR_VERDE, "Seus bilhetes foram carregados! Use: /MeusBilhetes.");
- }
- }
- }
- return 1;
- }
- CarregarPremio()
- {
- if(DOF2_FileExists(ArqPremio))
- {
- Premio = DOF2_GetInt(ArqPremio,"Premio");
- print("Premio da loteria carregado com sucesso!");
- }
- else if(!DOF2_FileExists(ArqPremio))
- {
- DOF2_CreateFile(ArqPremio);
- DOF2_SetInt(ArqPremio,"Premio", 0);
- DOF2_SaveFile();
- Premio = 0;
- }
- return 1;
- }
- SalvarPremio()
- {
- if(DOF2_FileExists(ArqPremio))
- {
- DOF2_SetInt(ArqPremio,"Premio", Premio);
- DOF2_SaveFile();
- print("Premio da loteria salvo com sucesso!");
- }
- else if(!DOF2_FileExists(ArqPremio))
- {
- DOF2_CreateFile(ArqPremio);
- DOF2_SetInt(ArqPremio,"Premio", 0);
- DOF2_SaveFile();
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement