16.11.2013, 02:36
#include <a_samp>
#include <dini>
#include <JunkBuster>
//--------|| Here you can easy change this ||--------//
#define LottoTime 1 //(number of minutes)
#define LottoPrice 500
#define MAX_NUMBERS 200
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_ERROR 0x9ACD32AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_DBLUE 0x375FFFFF
#define COLOR_YELLOW 0xFFFF00AA
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
forward Lotto(number);
forward LoadJackpot();
forward SaveJackpot();
new Jackpot;
new Timer;
new pLottoNumber[MAX_PLAYERS];
new PVar[playerid][money];
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Lottery System V 1.0 By Zero_Cool ");
print("--------------------------------------\n");
Timer = SetTimer("LottoShow", 1000*(LottoTime*60), 1);
if(!fexist("Jackpot.ini"))
{
dini_Create("Jackpot.ini");
dini_IntSet("Jackpot.ini","Jackpot",10000);
return 1;
}
else
{
LoadJackpot();
}
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
pLottoNumber[playerid] = 0;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
pLottoNumber[playerid] = 0;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(lotto,5,cmdtext);
dcmd(darjackpot,10,cmdtext);
return 0;
}
dcmd_darjackpot(playerid,params[])
{
if(IsPlayerAdmin(playerid))
{
new tmp[256], idx;
tmp = strtok(params, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE,"USA: /darjackpot [premio]");
return 1;
}
new amount = strval(tmp);
Jackpot = amount;
SaveJackpot();
return 1;
}
return 1;
}
dcmd_lotto(playerid,params[])
{
new tmp[256], idx;
new string[256];
tmp = strtok(params, idx);
if(IsPlayerConnected(playerid))
{
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE,"USA: /lotto [numero]");
return 1;
}
if(pLottoNumber[playerid] > 0)
{
SendClientMessage(playerid,COLOR_WHITE,"Ya Tienes un Boleto de Loteria");
return 1;
}
if(PVar[playerid][money] < LottoPrice)
{
format(string,sizeof(string),"Necesitas $%d para comprar Un Boleto de Loteria !",LottoPrice);
SendClientMessage(playerid,-1, "Necesitas {FF0000}$500{FFFFFF} Para Comprar Un Boleto !");
return 1;
}
new lottonr = strval(tmp);
for(new i;i<MAX_PLAYERS;i++)
{
if(pLottoNumber[playerid] == lottonr) return SendClientMessage(playerid, COLOR_ERROR,"Ese Numero Ya Esta Registrado!");
}
if(lottonr < 1 || lottonr > MAX_NUMBERS) {format(string, sizeof(string), "El Numero Debe de ser Mayor A 1 Y Menor que %d !",MAX_NUMBERS); SendClientMessage(playerid, COLOR_GREY,string); return 1; }
format(string, sizeof(string), "Has Comprado un Boleto de loteria con el numero:{FF0000} %d{FFFFFF},Premio Acumulado:{FF0000} %d", lottonr,Jackpot);
SendClientMessage(playerid, COLOR_WHITE, string);
GivePlayerMoney(playerid, - LottoPrice);
pLottoNumber[playerid] = lottonr;
}
return 1;
}
public Lotto(number)
{
new string[256];
new winner[MAX_PLAYER_NAME];
format(string, sizeof(string), "{FF0000}Info Loteria:{FFFFFF} Hoy El Numero Del Boleto Ganador es: %d.", number);
SendClientMessageToAll(COLOR_WHITE, string);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(pLottoNumber[i] > 0)
{
if(pLottoNumber[i] == number)
{
GetPlayerName(i, winner, sizeof(winner));
GivePlayerMoney(i, Jackpot);
format(string, sizeof(string), "{FF0000}Loteria{FFFFFF} Info: %s ha ganado el premio mayor de $%d Con Su Boleto De Loteria.", winner, Jackpot);
SendClientMessageToAll(COLOR_DBLUE, string);
format(string, sizeof(string), "*Has Ganado $%d Con Tu Boleto De Loteria.", Jackpot);
SendClientMessage(i, COLOR_YELLOW, string);
format(string,256,"~w~Has Ganado ~g~$%d",Jackpot);
GameTextForPlayer(i,string,10000,4);
}
else
{
SendClientMessage(i, COLOR_WHITE, "* No Has Ganado La Loteria En Esta Ocasion Sigue Participando.");
}
}
pLottoNumber[i] = 0;
}
}
new rand = randomEx(1000,200000);
Jackpot += rand;
SaveJackpot();
format(string, sizeof(string), "{FF0000}Loteria Info:{FFFFFF} El premio mayor Incremento A $%d.", Jackpot);
SendClientMessageToAll(COLOR_DBLUE, string);
return 1;
}
new time;
forward LottoShow();
public LottoShow()
{
new str[256];
format(str,256,"~g~/Loteria (1 - %d)~n~~g~Premio Mayor %d",MAX_NUMBERS,Jackpot);
GameTextForAll(str,10000,3);
KillTimer(Timer);
time = SetTimer("LottoWiner",15000,1);
return 1;
}
forward LottoWiner();
public LottoWiner()
{
new string[256];
KillTimer(time);
format(string, sizeof(string),"{FF0000}Loteria Info:{FFFFFF} Loteria Iniciada.");
SendClientMessageToAll(COLOR_DBLUE, string);
new rand = randomEx(1,MAX_NUMBERS);
if(rand < MAX_NUMBERS - 3) { rand += 3; }
Timer = SetTimer("LottoShow", 1000*(LottoTime*60), 1);
Lotto(rand);
}
public LoadJackpot()
{
new file[128];
format(file,sizeof(file),"Jackpot.ini");
Jackpot = dini_Int(file,"Jackpot");
return 1;
}
public SaveJackpot()
{
new file[128];
format(file,sizeof(file),"Jackpot.ini");
dini_IntSet(file,"Jackpot",Jackpot);
return 1;
}
//-----------|| By ****** ||---------------||
stock randomEx(minnum = cellmin, maxnum = cellmax) return random(maxnum - minnum + 1) + minnum;
#include <dini>
#include <JunkBuster>
//--------|| Here you can easy change this ||--------//
#define LottoTime 1 //(number of minutes)
#define LottoPrice 500
#define MAX_NUMBERS 200
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_ERROR 0x9ACD32AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_DBLUE 0x375FFFFF
#define COLOR_YELLOW 0xFFFF00AA
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
forward Lotto(number);
forward LoadJackpot();
forward SaveJackpot();
new Jackpot;
new Timer;
new pLottoNumber[MAX_PLAYERS];
new PVar[playerid][money];
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Lottery System V 1.0 By Zero_Cool ");
print("--------------------------------------\n");
Timer = SetTimer("LottoShow", 1000*(LottoTime*60), 1);
if(!fexist("Jackpot.ini"))
{
dini_Create("Jackpot.ini");
dini_IntSet("Jackpot.ini","Jackpot",10000);
return 1;
}
else
{
LoadJackpot();
}
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
pLottoNumber[playerid] = 0;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
pLottoNumber[playerid] = 0;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(lotto,5,cmdtext);
dcmd(darjackpot,10,cmdtext);
return 0;
}
dcmd_darjackpot(playerid,params[])
{
if(IsPlayerAdmin(playerid))
{
new tmp[256], idx;
tmp = strtok(params, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE,"USA: /darjackpot [premio]");
return 1;
}
new amount = strval(tmp);
Jackpot = amount;
SaveJackpot();
return 1;
}
return 1;
}
dcmd_lotto(playerid,params[])
{
new tmp[256], idx;
new string[256];
tmp = strtok(params, idx);
if(IsPlayerConnected(playerid))
{
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE,"USA: /lotto [numero]");
return 1;
}
if(pLottoNumber[playerid] > 0)
{
SendClientMessage(playerid,COLOR_WHITE,"Ya Tienes un Boleto de Loteria");
return 1;
}
if(PVar[playerid][money] < LottoPrice)
{
format(string,sizeof(string),"Necesitas $%d para comprar Un Boleto de Loteria !",LottoPrice);
SendClientMessage(playerid,-1, "Necesitas {FF0000}$500{FFFFFF} Para Comprar Un Boleto !");
return 1;
}
new lottonr = strval(tmp);
for(new i;i<MAX_PLAYERS;i++)
{
if(pLottoNumber[playerid] == lottonr) return SendClientMessage(playerid, COLOR_ERROR,"Ese Numero Ya Esta Registrado!");
}
if(lottonr < 1 || lottonr > MAX_NUMBERS) {format(string, sizeof(string), "El Numero Debe de ser Mayor A 1 Y Menor que %d !",MAX_NUMBERS); SendClientMessage(playerid, COLOR_GREY,string); return 1; }
format(string, sizeof(string), "Has Comprado un Boleto de loteria con el numero:{FF0000} %d{FFFFFF},Premio Acumulado:{FF0000} %d", lottonr,Jackpot);
SendClientMessage(playerid, COLOR_WHITE, string);
GivePlayerMoney(playerid, - LottoPrice);
pLottoNumber[playerid] = lottonr;
}
return 1;
}
public Lotto(number)
{
new string[256];
new winner[MAX_PLAYER_NAME];
format(string, sizeof(string), "{FF0000}Info Loteria:{FFFFFF} Hoy El Numero Del Boleto Ganador es: %d.", number);
SendClientMessageToAll(COLOR_WHITE, string);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(pLottoNumber[i] > 0)
{
if(pLottoNumber[i] == number)
{
GetPlayerName(i, winner, sizeof(winner));
GivePlayerMoney(i, Jackpot);
format(string, sizeof(string), "{FF0000}Loteria{FFFFFF} Info: %s ha ganado el premio mayor de $%d Con Su Boleto De Loteria.", winner, Jackpot);
SendClientMessageToAll(COLOR_DBLUE, string);
format(string, sizeof(string), "*Has Ganado $%d Con Tu Boleto De Loteria.", Jackpot);
SendClientMessage(i, COLOR_YELLOW, string);
format(string,256,"~w~Has Ganado ~g~$%d",Jackpot);
GameTextForPlayer(i,string,10000,4);
}
else
{
SendClientMessage(i, COLOR_WHITE, "* No Has Ganado La Loteria En Esta Ocasion Sigue Participando.");
}
}
pLottoNumber[i] = 0;
}
}
new rand = randomEx(1000,200000);
Jackpot += rand;
SaveJackpot();
format(string, sizeof(string), "{FF0000}Loteria Info:{FFFFFF} El premio mayor Incremento A $%d.", Jackpot);
SendClientMessageToAll(COLOR_DBLUE, string);
return 1;
}
new time;
forward LottoShow();
public LottoShow()
{
new str[256];
format(str,256,"~g~/Loteria (1 - %d)~n~~g~Premio Mayor %d",MAX_NUMBERS,Jackpot);
GameTextForAll(str,10000,3);
KillTimer(Timer);
time = SetTimer("LottoWiner",15000,1);
return 1;
}
forward LottoWiner();
public LottoWiner()
{
new string[256];
KillTimer(time);
format(string, sizeof(string),"{FF0000}Loteria Info:{FFFFFF} Loteria Iniciada.");
SendClientMessageToAll(COLOR_DBLUE, string);
new rand = randomEx(1,MAX_NUMBERS);
if(rand < MAX_NUMBERS - 3) { rand += 3; }
Timer = SetTimer("LottoShow", 1000*(LottoTime*60), 1);
Lotto(rand);
}
public LoadJackpot()
{
new file[128];
format(file,sizeof(file),"Jackpot.ini");
Jackpot = dini_Int(file,"Jackpot");
return 1;
}
public SaveJackpot()
{
new file[128];
format(file,sizeof(file),"Jackpot.ini");
dini_IntSet(file,"Jackpot",Jackpot);
return 1;
}
//-----------|| By ****** ||---------------||
stock randomEx(minnum = cellmin, maxnum = cellmax) return random(maxnum - minnum + 1) + minnum;