Lottery
#1

I would like a lottery filterscript that allow them to play a number from 1 to 100 to a user who writes / ticket, you can play the number only once per hour and the fare will be 75, the draw will be random jackpot from $ 10,000 to $ 70,000.
Now I use this, but i want how to this on


Код:
#include <a_samp>
//===================================DEFINE
#define DIALOGLOTTERIA 10004
#define COMANDOBIGLIETTO "/biglietto"
#define VINCITABASE 1000
#define VINCITAEXTRA 100
#define MINUTIESTRAZIONE 5
#define COSTOBIGLIETTO 75
//==================================VERIABILI
new Biglietto[MAX_PLAYERS]=0;
new stringa[256];
new nome[20];
new numerofortunato;
new vincita;
//============================================================ONFILTERSCRIPTINIT
//===============================================================ONPLAYERCONNECT
public OnPlayerConnect(playerid)
{
	format(stringa,sizeof(stringa),"LOTTERIA: {FFFFFF}Se vuoi comprare un biglietto digita {C14124}%s{FFFFFF}.",COMANDOBIGLIETTO);
	SendClientMessage(playerid,0x338CD9FF,stringa);
	return 1;
}
//============================================================ONPLAYERDISCONNECT
public OnPlayerDisconnect(playerid, reason)
{
	Biglietto[playerid]=0;
	return 1;
}
//===========================================================ONPLAYERCOMMANDTEXT
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp(COMANDOBIGLIETTO, cmdtext, true, 10) == 0)
	{
		ShowPlayerDialog(playerid,DIALOGLOTTERIA,DIALOG_STYLE_INPUT,"Acquista biglietto","{FFFFFF}Inserisci il {C14124}numero{FFFFFF} del biglietto che vuoi acquistare.\nInserisci un numero nell'intervallo {C14124}1-90{FFFFFF}.","Compra","Esci");
		return 1;
	}
	return 0;
}
//==============================================================ONDIALOGRESPONSE
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == DIALOGLOTTERIA)
	{
	if(Biglietto[playerid]!=0) return SendClientMessage(playerid,0xF5432EFF,"ERRORE: {FFFFFF}Possiedi giа un biglietto. Attendi la prossima estrazione.");
	if(!isNumeric(inputtext)) return ShowPlayerDialog(playerid,DIALOGLOTTERIA,DIALOG_STYLE_INPUT,"Acquista biglietto","{C14124}ERRORE: Inserire caratteri numerici.\n{FFFFFF}Inserisci il {C14124}numero{FFFFFF} del biglietto che vuoi acquistare.\nInserisci un numero nell'intervallo {C14124}1-90{FFFFFF}.","Compra","Esci");
	if(strval(inputtext)<1 || strval(inputtext)>90) return ShowPlayerDialog(playerid,DIALOGLOTTERIA,DIALOG_STYLE_INPUT,"Acquista biglietto","{C14124}ERRORE: Inserire il numero del biglietto nell'intervallo 1-90.\n{FFFFFF}Inserisci il {C14124}numero{FFFFFF} del biglietto che vuoi acquistare.\nInserisci un numero nell'intervallo {C14124}1-90{FFFFFF}.","Compra","Esci");
	for(new i=0;i<MAX_PLAYERS;i++)
	if(strval(inputtext)==Biglietto[i]) return ShowPlayerDialog(i,DIALOGLOTTERIA,DIALOG_STYLE_INPUT,"Acquista biglietto","{C14124}ERRORE: Questo biglietto и giа stato acquistato.\n{FFFFFF}Inserisci il {C14124}numero{FFFFFF} del biglietto che vuoi acquistare.\nInserisci un numero nell'intervallo {C14124}1-90{FFFFFF}.","Compra","Esci");
	format(stringa,sizeof(stringa),"LOTTERIA: {FFFFFF}Hai acquistato il {8CE46C}%d{FFFFFF}. Buona fortuna per l'estrazione.",strval(inputtext));
	SendClientMessage(playerid,0x338CD9FF,stringa);
	Biglietto[playerid]=strval(inputtext);
	GivePlayerMoney(playerid,-COSTOBIGLIETTO);
	}
	return 1;
}
//====================================================================ESTRAZIONE
forward Estrazione();
public Estrazione()
{
 numerofortunato=random(90);
 new a=0;
 for(new i=0;i<MAX_PLAYERS;i++)
 {
  if(Biglietto[i]==numerofortunato)
  {
  GetPlayerName(i,nome,sizeof(nome));
  vincita=VINCITABASE+random(VINCITAEXTRA);
  GivePlayerMoney(i,vincita);
  a=1;
  }
  Biglietto[i]=0;
 }
 if(a==1)
 {
 format(stringa,sizeof(stringa),"LOTTERIA: {8CE46C}%s{FFFFFF} vince {C14124}%d{FFFFFF}$ con l'estrazione del numero {C14124}%d{FFFFFF}.",nome,vincita,numerofortunato);
 SendClientMessageToAll(0x338CD9FF,stringa);
 return 1;
 }
 else
 {
 format(stringa,sizeof(stringa),"LOTTERIA: il numero estratto и {C14124}%d{FFFFFF}, ma nessuno ha vinto.",numerofortunato);
 SendClientMessageToAll(0x338CD9FF,stringa);
 }
 return 1;
}
//=====================================================================ISNUMERIC
stock isNumeric(const string[])
{
	new length=strlen(string);
	if (length==0) return false;
	for (new i = 0; i < length; i++)
	{
	if
	((string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') || (string[i]=='-' && i!=0)|| (string[i]=='+' && i!=0))
    return false;
	}
	if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
	return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)