[Ajuda] DOF2.
#1

Код:
#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;
}
Alguem pode tirar o salvamento de DOF2 e colocar para dini?
agradeзo desde ja.
Reply


Messages In This Thread
DOF2. - by netogba - 17.10.2012, 21:46
Re: DOF2. - by mau.tito - 17.10.2012, 21:55
Re: DOF2. - by netogba - 17.10.2012, 22:44
Re: DOF2. - by @Riichard - 17.10.2012, 22:47
Re: DOF2. - by jQuery - 17.10.2012, 22:53
Re: DOF2. - by @Riichard - 17.10.2012, 22:55
Re: DOF2. - by Abravanel - 17.10.2012, 23:11
Re: DOF2. - by URSS_Morelli - 18.10.2012, 02:11
Re: DOF2. - by Lord_Style - 18.10.2012, 02:13

Forum Jump:


Users browsing this thread: 1 Guest(s)