Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*----------------------------------------------
- Lotto system with an automated clock by iGetty
- Please keep all credits to me, as it would be
- highly appreciated.
- ----------------------------------------------*/
- /*--- INCLUDES ---*/
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- /*--- DEFINES ---*/
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 25
- /*--- COLOURS ---*/
- #define WHITE 0xFFFFFFF
- /*--- VARIABLES ---*/
- new ClockTimer, Text:Clock, LottoPurchased[MAX_PLAYERS], LottoNumber[MAX_PLAYERS], Hour, Minute, Second;
- /*--- FORWARDS ---*/
- forward ClockUpdate();
- public OnFilterScriptInit()
- {
- Clock = TextDrawCreate(523.000000, 11.000000, "00:00:00");
- TextDrawBackgroundColor(Clock, 255);
- TextDrawFont(Clock, 1);
- TextDrawLetterSize(Clock, 0.500000, 1.000000);
- TextDrawColor(Clock, -1);
- TextDrawSetOutline(Clock, 0);
- TextDrawSetProportional(Clock, 1);
- TextDrawSetShadow(Clock, 1);
- ClockTimer = SetTimer("ClockUpdate", 999, 1);
- Hour = 12;
- Minute = 30;
- Second = 0;
- return 1;
- }
- public OnFilterScriptExit()
- {
- TextDrawHideForAll(Clock);
- TextDrawDestroy(Clock);
- KillTimer(ClockTimer);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- TextDrawShowForPlayer(playerid, Clock);
- LottoPurchased[playerid] = 0;
- LottoNumber[playerid] = -1;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- TextDrawHideForPlayer(playerid, Clock);
- return 1;
- }
- /*--- COMMANDS ---*/
- command(buyticket, playerid, params[])
- {
- if(LottoPurchased[playerid] == 0)
- {
- new lnum, string[128];
- if(sscanf(params, "d", lnum)) return SendClientMessage(playerid, WHITE, "Usage: /buyticket [1 - 99]");
- {
- if(lnum < 100 && lnum > 0)
- {
- format(string, sizeof(string), "[LOTTO NEWS] You have purchased a lottery ticket with the number of %d, for $15.", lnum);
- SendClientMessage(playerid, WHITE, string);
- LottoNumber[playerid] = lnum;
- LottoPurchased[playerid] = 1;
- }
- else return SendClientMessage(playerid, WHITE, "Lottery tickets can only be from 1 to 99.");
- }
- }
- else return SendClientMessage(playerid, WHITE, "You already have a lottery ticket purchased.");
- return 1;
- }
- command(myticket, playerid, params[])
- {
- if(LottoPurchased[playerid] == 1)
- {
- new string[50];
- format(string, sizeof(string), "Your lottery ticket number is - %d.", LottoNumber[playerid]);
- ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "My Lottery Ticket", string, "OK", "");
- }
- else return SendClientMessage(playerid, WHITE, "You haven't purchased a lottery ticket.");
- return 1;
- }
- command(lotteryhelp, playerid, params[])
- {
- SendClientMessage(playerid, WHITE, "Lottery Help.");
- SendClientMessage(playerid, WHITE, "Commands: /myticket /buyticket /lotteryhelp /credits");
- SendClientMessage(playerid, WHITE, "Information: Lotto draws will be held at every XX:00 in game time. To see the time, look at");
- SendClientMessage(playerid, WHITE, "Information: the clock in the top right of the screen, it will constantly update every second and you won't miss anything.");
- return 1;
- }
- command(credits, playerid, params[])
- {
- SendClientMessage(playerid, WHITE, "{FF0000}Credits");
- SendClientMessage(playerid, WHITE, "Creator: {FF0000}iGetty{FFFFFF}.");
- SendClientMessage(playerid, WHITE, "Tester: {FF0000}iGetty{FFFFFF}.");
- SendClientMessage(playerid, WHITE, "Information: Please keep my credits inside this filterscript if you use it, as I created the actual filterscript.");
- return 1;
- }
- /*--- CUSTOM FUNCTIONS ---*/
- public ClockUpdate()
- {
- for(new x = 0; x < MAX_PLAYERS; x++)
- {
- if(!IsPlayerConnected(x))return 1;
- new string[12];
- Second += 1;
- if(Second == 60)
- {
- if(Minute == 59)
- {
- if(LottoPurchased[x] == 1)
- {
- new rand = 1 + random(99), lrand = 1 + random(599);
- if(LottoNumber[x] == rand)
- {
- new lottostr[128];
- format(lottostr, sizeof(lottostr), "[LOTTO NEWS] %s has won the lottery of $%d this time!", pName(x), lrand);
- SendClientMessageToAll(WHITE, lottostr);
- GivePlayerMoney(x, lrand);
- LottoNumber[x] = -1;
- LottoPurchased[x] = 0;
- return 1;
- }
- else
- {
- SendClientMessageToAll(WHITE, "[LOTTO NEWS] Nobody has won the lottery this time. Better luck next time!");
- LottoNumber[x] = -1;
- LottoPurchased[x] = 0;
- }
- }
- if(Hour == 23)
- {
- Hour = 0;
- Minute = 0;
- Second = 0;
- }
- else
- {
- Hour ++;
- Minute = 0;
- Second = 0;
- }
- }
- else
- {
- Minute ++;
- Second = 0;
- }
- }
- format(string,sizeof (string),"%02i:%02i:%02i", Hour, Minute, Second);
- TextDrawSetString(Clock, string);
- SetWorldTime(Hour);
- }
- return 1;
- }
- stock pName(playerid)
- {
- new name[24];
- GetPlayerName(playerid, name, 24);
- return name;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement