pawn Код:
/*
FULLY spaces Theft Credit or
Publication of this filterscript without my permission.
EASY FILTERSCRIPT --> Easy Lottery System BASE
CREDITOS: OTACON ;)
*/
// ========== [ -|- FUNCTION -|- ] ==========
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#define ID_LOTERIA (1) //The id of the menu of the lottery.
#define VALOR_TICKET (500) //The value of the ticket.
#define TIEMPO_LOTERIA (30) //cada 30 Minutos sorteara.
#define PREMIO_INICIAL (100) //initial well lottery is multiplied according to the number of ticket's sold.
#define POZO_LIMITE (200) //the limit for the initial well will return.
new NumeroLoteria[MAX_PLAYERS];
new PozoLoteria=PREMIO_INICIAL;
new bool:TicketLoteria[MAX_PLAYERS]=false;
new MatarLoteria;
new PozoLoteriaLimite=0;
public OnFilterScriptInit() {
MatarLoteria=SetTimer("Lottery", TIEMPO_LOTERIA*60000, true);
return true;
}
public OnFilterScriptExit() {
KillTimer(MatarLoteria);
return true;
}
COMMAND:ticket(playerid, params[]) {
ShowPlayerDialog(playerid,ID_LOTERIA+0, DIALOG_STYLE_INPUT, "Easy Lottery System BASE", "Enter a number between 0 and 100:", "Buy "," Exit ");
return true;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
new str[128];
switch(dialogid) {
case ID_LOTERIA+0: {
if(response) {
if(sscanf(inputtext, "d", inputtext[0])) return ShowPlayerDialog(playerid,ID_LOTERIA+0, DIALOG_STYLE_INPUT, "Easy Lottery System BASE", "Enter a number between 0 and 100: \nNumeric value is permitted", "Buy "," Exit ");
if(inputtext[0]<0 || inputtext[0]>100) return ShowPlayerDialog(playerid,ID_LOTERIA+0, DIALOG_STYLE_INPUT, "Easy Lottery System BASE", "Enter a number between 0 and 100: \nnot go below 0 or above 100", "Buy "," Exit ");
if(TicketLoteria[playerid]==true) return ShowPlayerDialog(playerid,ID_LOTERIA+0, DIALOG_STYLE_INPUT, "Easy Lottery System BASE", "Enter a number between 0 and 100: \nalready bought a ticket", "Buy "," Exit ");
if(GetPlayerMoney(playerid)<VALOR_TICKET) return ShowPlayerDialog(playerid,ID_LOTERIA+0, DIALOG_STYLE_INPUT, "Easy Lottery System BASE", "Enter a number between 0 and 100: \nnot have enough money to buy a ticket", "Buy "," Exit ");
NumeroLoteria[playerid]=inputtext[0];
TicketLoteria[playerid]=true;
GivePlayerMoney(playerid,(0-VALOR_TICKET));
PozoLoteriaLimite++;
format(str, sizeof(str), "You have bought a lottery ticket with the number %d, to a value of %d dollars.", NumeroLoteria[playerid], VALOR_TICKET);
SendClientMessage(playerid, -1, str);
new count=0;
for(new i=0; i<GetMaxPlayers(); i++) {
if(!IsPlayerConnected(i)) continue;
if(IsPlayerConnected(i) && TicketLoteria[i]==true) { count++; break; }
}
if(count==POZO_LIMITE) PozoLoteriaLimite=0;
}
}
}
return false;
}
forward Lottery();
public Lottery() {
new str[200];
for(new player=0; player<GetMaxPlayers(); player++) {
if(!IsPlayerConnected(player) || TicketLoteria[player]!=true) continue;
if(IsPlayerConnected(player) && TicketLoteria[player]!=false) {
new numero=random(100);
if(NumeroLoteria[player]==numero) {
format(str, sizeof(str), "~y~lottery raffled~n~~w~Number drawn was the ~g~%d~w~~n~with a prize of ~g~$%d~w~ dollars.~n~~g~Make won the lottery, Congratulations!.", numero, PozoLoteria*PozoLoteriaLimite);
GameTextForPlayer(player, str, 15*1000, 3);
GivePlayerMoney(player,(0+PozoLoteria*PozoLoteriaLimite));
NumeroLoteria[player]=0;
TicketLoteria[player]=false;
} else {
format(str, sizeof(str), "~y~lottery raffled~n~~w~Number drawn was the ~g~%d~w~~n~with a prize of ~g~$%d~w~ dollars.~n~~r~You have lost the lottery, Luck!.", numero, PozoLoteria*PozoLoteriaLimite);
GameTextForPlayer(player, str, 15*1000, 3);
NumeroLoteria[player]=0;
TicketLoteria[player]=false;
}
}
}
}
// ========== [ -|- FUNCTION -|- ] ==========