Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #pragma tabsize 0
- #if defined FILTERSCRIPT
- //=====================DEFINE
- #define DIALOGLOTTERIA 10004
- #define COMANDOBIGLIETTO "/biglietto"
- #define VINCITABASE 1000
- #define VINCITAEXTRA 100
- #define MINUTIESTRAZIONE 5
- #define COSTOBIGLIETTO 10
- //=====================VARIABILI
- new Biglietto[MAX_PLAYERS]=0
- new stringa[256]
- new nome[20]
- new numerofortunato
- new vincita
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Sistema Lotteria");
- print("--------------------------------------\n");
- SetTimer("Estrazione",60000*MINUTIESTRAZIONE,true);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- #define ROSSO 0xAA3333AA
- main()
- {
- print("\n----------------------------------");
- print(" Sistema Lotteria Terminato");
- print("----------------------------------\n");
- }
- #endif
- public OnPlayerConnect(playerid)
- {
- new stringa[128];
- new COMANDOBIGLIETTO;
- format(stringa,sizeof(stringa),"LOTTERIA: {FFFFFF}Se vuoi comprare un biglietto digita {C14124}%s{FFFFFF}.",COMANDOBIGLIETTO);
- SendClientMessage(playerid,0x338CD9FF,stringa);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new Biglietto[MAX_PLAYERS];
- Biglietto[playerid]=0;
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new COMANDOBIGLIETTO[MAX_PLAYERS];
- new DIALOGLOTTERIA;
- 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;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new DIALOGLOTTERIA;
- new Biglietto[MAX_PLAYERS];
- new stringa[128];
- if(dialogid == DIALOGLOTTERIA)
- {
- if(GetPlayerMoney(playerid) < 10) return SendClientMessage(playerid, ROSSO, "Non hai abbastanza soldi per comprare il biglietto");
- 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 compreso tra {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 compreso tra 1-90.\n{FFFFFF}Inserisci il {C14124}numero{FFFFFF} del biglietto che vuoi acquistare.\nInserisci un numero comprso tra {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 il biglietto","{C14124}ERRORE: Questo biglietto è già stato acquistato.\n{FFFFFF}Inserisci il {C14124}numero{FFFFFF} del biglietto che vuoi acquistare.\nInserisci un numero compreso tra {C14124}1-90{FFFFFF}.","Compra","Esci");
- format(stringa,sizeof(stringa),"LOTTERIA: {FFFFFF}Hai acquistato il {8CE46C}%d{FFFFFF}. Buona fortuna.",strval(inputtext));
- SendClientMessage(playerid,0x338CD9FF,stringa);
- Biglietto[playerid]=strval(inputtext);
- }
- return 1;
- }
- forward Estrazione();
- public Estrazione()
- {
- new numerofortunato;
- numerofortunato=random(90);
- new a=0;
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- new Biglietto[MAX_PLAYERS];
- if(Biglietto[i]==numerofortunato)
- {
- new nome[20];
- new vincita;
- new VINCITABASE;
- new VINCITAEXTRA;
- GetPlayerName(i,nome,sizeof(nome));
- vincita=VINCITABASE+random(VINCITAEXTRA);
- GivePlayerMoney(i,vincita);
- a=1;
- }
- Biglietto[i]=0;
- }
- if(a==1)
- {
- new stringa[128];
- new nome[20];
- new vincita;
- 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
- {
- new stringa[128];
- format(stringa,sizeof(stringa),"LOTTERIA: il numero estratto è {C14124}%d{FFFFFF}, ma nessuno ha vinto.",numerofortunato);
- SendClientMessageToAll(0x338CD9FF,stringa);
- }
- return 1;
- }
- 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;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement