16.04.2014, 04:17
Lottery Scratchers
By Aerotactics
By Aerotactics
Have you ever gone into a convenience store and seen the rolls of tickets that you can scratch off for a chance at cash? Well I bring you the filterscript equivalent. This filterscript includes 3 scratchers. Each cost $5:
-Lucky 3: scratch all 3, and if they all say WINNER, you win $500 instantly!
-50/50: scratch one or the other, if it's a winner, you win $10!
-Equals Seven: there are 6 numbers. You scratch any 3, and if they equal 7, you win $77!
Commands
There's only 1 command and it is in this format:
/scratcher [cardtype (1-3)]
Includes
This FS requires 2 well-known includes:
-zcmd
-sscanf2
Script
Here's the full script:
pawn Код:
/////////////////////////////////////////////////////
// Lottery Scratchers by Aerotactics
/////////////////////////////////////////////////////
// Add this credit to any script you merge this with,
// even if you don't plan on releasing your script!
//
#define FILTERSCRIPT
#define DIALOG_SCRATCHER1 755
#define DIALOG_SCRATCHER2 756
#define DIALOG_SCRATCHER3 757
#define COLOR_GREEN 0x009900FF
new GLOBAL_MSGS = 1; //Change to 0 for "false"; does not apply to "50/50" scratchers.
#include <a_samp>
#include <zcmd>
#include <sscanf2>
// Lucky 3
new winner[MAX_PLAYERS];
new scratched_slot1[MAX_PLAYERS];
new scratched_slot2[MAX_PLAYERS];
new scratched_slot3[MAX_PLAYERS];
new slot1[20];
new slot2[20];
new slot3[20];
// 50/50
new spot1[12];
new spot2[12];
new scratched_spot[MAX_PLAYERS];
// Equals Seven
new num1[3];
new num2[3];
new num3[3];
new num4[3];
new num5[3];
new num6[3];
new scratched_num1[MAX_PLAYERS];
new scratched_num2[MAX_PLAYERS];
new scratched_num3[MAX_PLAYERS];
new scratched_num4[MAX_PLAYERS];
new scratched_num5[MAX_PLAYERS];
new scratched_num6[MAX_PLAYERS];
new scratchcount[MAX_PLAYERS];
new total1[MAX_PLAYERS];
new total2[MAX_PLAYERS];
new total3[MAX_PLAYERS];
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Lotto Scratchers by Aero Loaded!");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
CMD:scratcher(playerid, params[])
{
new scratch_num;
if (sscanf(params, "i", scratch_num)) return SendClientMessage(playerid, COLOR_GREEN, "Use: /scratcher [cardtype (1-3)]");
if (scratch_num > 3 || scratch_num < 1) return SendClientMessage(playerid, COLOR_GREEN, "Error: cardtype is 1-3.");
if (scratch_num == 1) // Lucky 3
{
GivePlayerMoney(playerid, -5);
slot1 = "{================}";
slot2 = "{================}";
slot3 = "{================}";
winner[playerid] = 0;
scratched_slot1[playerid] = 0;
scratched_slot2[playerid] = 0;
scratched_slot3[playerid] = 0;
UpdateScratcher1(playerid);
SendClientMessage(playerid, COLOR_GREEN, "{DCB700}====================================================");
SendClientMessage(playerid, COLOR_GREEN, "{DCB700}Lucky 3! Simply get 3 {FFFFFF}WINNER{DCB700}'s, and instantly win $500!");
SendClientMessage(playerid, COLOR_GREEN, "{DCB700}====================================================");
return 1;
}
if (scratch_num == 2) // 50/50
{
GivePlayerMoney(playerid, -5);
spot1 = "Scratch me!";
spot2 = "Scratch me!";
scratched_spot[playerid] = 0;
UpdateScratcher2(playerid);
SendClientMessage(playerid, COLOR_GREEN, "{DCB700}====================================================");
SendClientMessage(playerid, COLOR_GREEN, "{DCB700}50/50! Choose a spot, if you win you'll get $10!");
SendClientMessage(playerid, COLOR_GREEN, "{DCB700}====================================================");
return 1;
}
if (scratch_num == 3) // Equals Seven
{
GivePlayerMoney(playerid, -5);
num1 = "#";
num2 = "#";
num3 = "#";
num4 = "#";
num5 = "#";
num6 = "#";
scratchcount[playerid] = 0;
scratched_num1[playerid] = 0;
scratched_num2[playerid] = 0;
scratched_num3[playerid] = 0;
scratched_num4[playerid] = 0;
scratched_num5[playerid] = 0;
scratched_num6[playerid] = 0;
total1[playerid] = 0;
total2[playerid] = 0;
total3[playerid] = 0;
SendClientMessage(playerid, COLOR_GREEN, "{DCB700}====================================================");
SendClientMessage(playerid, COLOR_GREEN, "{DCB700}Equals Seven! If they equal '7' you win $77!");
SendClientMessage(playerid, COLOR_GREEN, "{DCB700}====================================================");
UpdateScratcher3(playerid);
return 1;
}
return 1;
}
stock UpdateScratcher1(playerid)
{
new dialog[64];
format(dialog,sizeof(dialog), "%s\n%s\n%s",slot1,slot2,slot3);
ShowPlayerDialog(playerid, DIALOG_SCRATCHER1, DIALOG_STYLE_LIST, "{DCB700}Lucky 3!", dialog, "Scratch", "Dispose");
return 1;
}
stock UpdateScratcher2(playerid)
{
ShowPlayerDialog(playerid, DIALOG_SCRATCHER2, DIALOG_STYLE_MSGBOX, "{DCB700}50/50!", "Choose a spot, if you win you'll get $10!", spot1, spot2);
return 1;
}
stock UpdateScratcher3(playerid)
{
new dialog[32];
format(dialog,sizeof(dialog), "%s\n%s\n%s\n%s\n%s\n%s",num1,num2,num3,num4,num5,num6);
ShowPlayerDialog(playerid, DIALOG_SCRATCHER3, DIALOG_STYLE_LIST, "{DCB700}Equals Seven!", dialog, "Scratch", "Dispose");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == DIALOG_SCRATCHER1)
{
if(response)
{
switch(listitem)
{
case 0:
{
if(scratched_slot1[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You already scratched this spot.");
UpdateScratcher1(playerid);
return 1;
}
new rand=random(3);
if(rand == 0)
{
slot1 = "{=====WINNER=====}";
winner[playerid]++;
}
else
{
slot1 = "{====TRYAGAIN====}";
}
scratched_slot1[playerid] = 1;
UpdateScratcher1(playerid);
if (winner[playerid] == 3)
{
if(GLOBAL_MSGS == 1)
{
new name[48];
new msg[128];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg), "%s just won $500 in the 'Lucky 3' scratchers!",name);
SendClientMessageToAll(COLOR_GREEN, msg);
}
SendClientMessage(playerid, COLOR_GREEN, "YOU'RE A WINNER!");
GivePlayerMoney(playerid, 500);
}
}
case 1:
{
if(scratched_slot2[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You already scratched this spot.");
UpdateScratcher1(playerid);
return 1;
}
new rand=random(3);
if(rand == 0)
{
slot2 = "{=====WINNER=====}";
winner[playerid]++;
}
else
{
slot2 = "{====TRYAGAIN====}";
}
scratched_slot2[playerid] = 1;
UpdateScratcher1(playerid);
if (winner[playerid] == 3)
{
if(GLOBAL_MSGS == 1)
{
new name[48];
new msg[128];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg), "%s just won $500 in the 'Lucky 3' scratchers!",name);
SendClientMessageToAll(COLOR_GREEN, msg);
}
SendClientMessage(playerid, COLOR_GREEN, "YOU'RE A WINNER!");
GivePlayerMoney(playerid, 500);
}
}
case 2:
{
if(scratched_slot3[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You already scratched this spot.");
UpdateScratcher1(playerid);
return 1;
}
new rand=random(3);
if(rand == 0)
{
slot3 = "{=====WINNER=====}";
winner[playerid]++;
}
else
{
slot3 = "{====TRYAGAIN====}";
}
scratched_slot3[playerid] = 1;
UpdateScratcher1(playerid);
if (winner[playerid] == 3)
{
if(GLOBAL_MSGS == 1)
{
new name[48];
new msg[128];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg), "%s just won $500 in the 'Lucky 3' scratchers!",name);
SendClientMessageToAll(COLOR_GREEN, msg);
}
SendClientMessage(playerid, COLOR_GREEN, "YOU'RE A WINNER!");
GivePlayerMoney(playerid, 500);
}
}
}
}
return 1;
}
if (dialogid == DIALOG_SCRATCHER2)
{
if(response)
{
if (scratched_spot[playerid] == 1) return 1;
new rand=random(2);
if (rand == 0)
{
spot1 = "Winner!";
spot2 = "Try Again";
SendClientMessage(playerid, COLOR_GREEN, "YOU'RE A WINNER!");
GivePlayerMoney(playerid, 10);
}
else
{
spot2 = "Winner!";
spot1 = "Try Again";
}
scratched_spot[playerid] = 1;
UpdateScratcher2(playerid);
}
if (!response)
{
if (scratched_spot[playerid] == 1) return 1;
new rand=random(2);
if (rand == 0)
{
spot2 = "Winner!";
spot1 = "Try Again";
SendClientMessage(playerid, COLOR_GREEN, "YOU'RE A WINNER!");
GivePlayerMoney(playerid, 10);
}
else
{
spot1 = "Winner!";
spot2 = "Try Again";
}
scratched_spot[playerid] = 1;
UpdateScratcher2(playerid);
}
return 1;
}
if (dialogid == DIALOG_SCRATCHER3)
{
if(response)
{
switch(listitem)
{
case 0:
{
if(scratched_num1[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You already scratched this spot.");
UpdateScratcher3(playerid);
return 1;
}
else
{
new rand=random(3);
new addtotal = rand+1;
if(total1[playerid] == 0){total1[playerid] = addtotal;}
else if(total2[playerid] == 0){total2[playerid] = addtotal;}
else if(total3[playerid] == 0){total3[playerid] = addtotal;}
valstr(num1,addtotal);
scratched_num1[playerid] = 1;
UpdateScratcher3(playerid);
scratchcount[playerid]++;
}
if (scratchcount[playerid] == 3)
{
if (total1[playerid] + total2[playerid] + total3[playerid] == 7)
{
if(GLOBAL_MSGS == 1)
{
new name[48];
new msg[128];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg), "%s just won $77 in the 'Equals Seven' scratchers!",name);
SendClientMessageToAll(COLOR_GREEN, msg);
}
SendClientMessage(playerid, COLOR_GREEN, "YOU'RE A WINNER!");
GivePlayerMoney(playerid, 77);
}
else
{
SendClientMessage(playerid, COLOR_GREEN, "Your numbers were not equal to seven. Please try again.");
}
}
}
case 1:
{
if(scratched_num2[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You already scratched this spot.");
UpdateScratcher3(playerid);
return 1;
}
else
{
new rand=random(3);
new addtotal = rand+1;
if(total1[playerid] == 0){total1[playerid] = addtotal;}
else if(total2[playerid] == 0){total2[playerid] = addtotal;}
else if(total3[playerid] == 0){total3[playerid] = addtotal;}
valstr(num2,addtotal);
scratched_num2[playerid] = 1;
UpdateScratcher3(playerid);
scratchcount[playerid]++;
}
if (scratchcount[playerid] == 3)
{
if (total1[playerid] + total2[playerid] + total3[playerid] == 7)
{
if(GLOBAL_MSGS == 1)
{
new name[48];
new msg[128];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg), "%s just won $77 in the 'Equals Seven' scratchers!",name);
SendClientMessageToAll(COLOR_GREEN, msg);
}
SendClientMessage(playerid, COLOR_GREEN, "YOU'RE A WINNER!");
GivePlayerMoney(playerid, 77);
}
else
{
SendClientMessage(playerid, COLOR_GREEN, "Your numbers were not equal to seven. Please try again.");
}
}
}
case 2:
{
if(scratched_num3[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You already scratched this spot.");
UpdateScratcher3(playerid);
return 1;
}
else
{
new rand=random(3);
new addtotal = rand+1;
if(total1[playerid] == 0){total1[playerid] = addtotal;}
else if(total2[playerid] == 0){total2[playerid] = addtotal;}
else if(total3[playerid] == 0){total3[playerid] = addtotal;}
valstr(num3,addtotal);
scratched_num3[playerid] = 1;
UpdateScratcher3(playerid);
scratchcount[playerid]++;
}
if (scratchcount[playerid] == 3)
{
if (total1[playerid] + total2[playerid] + total3[playerid] == 7)
{
if(GLOBAL_MSGS == 1)
{
new name[48];
new msg[128];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg), "%s just won $77 in the 'Equals Seven' scratchers!",name);
SendClientMessageToAll(COLOR_GREEN, msg);
}
SendClientMessage(playerid, COLOR_GREEN, "YOU'RE A WINNER!");
GivePlayerMoney(playerid, 77);
}
else
{
SendClientMessage(playerid, COLOR_GREEN, "Your numbers were not equal to seven. Please try again.");
}
}
}
case 3:
{
if(scratched_num4[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You already scratched this spot.");
UpdateScratcher3(playerid);
return 1;
}
else
{
new rand=random(3);
new addtotal = rand+1;
if(total1[playerid] == 0){total1[playerid] = addtotal;}
else if(total2[playerid] == 0){total2[playerid] = addtotal;}
else if(total3[playerid] == 0){total3[playerid] = addtotal;}
valstr(num4,addtotal);
scratched_num4[playerid] = 1;
UpdateScratcher3(playerid);
scratchcount[playerid]++;
}
if (scratchcount[playerid] == 3)
{
if (total1[playerid] + total2[playerid] + total3[playerid] == 7)
{
if(GLOBAL_MSGS == 1)
{
new name[48];
new msg[128];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg), "%s just won $77 in the 'Equals Seven' scratchers!",name);
SendClientMessageToAll(COLOR_GREEN, msg);
}
SendClientMessage(playerid, COLOR_GREEN, "YOU'RE A WINNER!");
GivePlayerMoney(playerid, 77);
}
else
{
SendClientMessage(playerid, COLOR_GREEN, "Your numbers were not equal to seven. Please try again.");
}
}
return 1;
}
case 4:
{
if(scratched_num5[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You already scratched this spot.");
UpdateScratcher3(playerid);
return 1;
}
else
{
new rand=random(3);
new addtotal = rand+1;
if(total1[playerid] == 0){total1[playerid] = addtotal;}
else if(total2[playerid] == 0){total2[playerid] = addtotal;}
else if(total3[playerid] == 0){total3[playerid] = addtotal;}
valstr(num5,addtotal);
scratched_num5[playerid] = 1;
UpdateScratcher3(playerid);
scratchcount[playerid]++;
}
if (scratchcount[playerid] == 3)
{
if (total1[playerid] + total2[playerid] + total3[playerid] == 7)
{
if(GLOBAL_MSGS == 1)
{
new name[48];
new msg[128];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg), "%s just won $77 in the 'Equals Seven' scratchers!",name);
SendClientMessageToAll(COLOR_GREEN, msg);
}
SendClientMessage(playerid, COLOR_GREEN, "YOU'RE A WINNER!");
GivePlayerMoney(playerid, 77);
}
else
{
SendClientMessage(playerid, COLOR_GREEN, "Your numbers were not equal to seven. Please try again.");
}
}
return 1;
}
case 5:
{
if(scratched_num6[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You already scratched this spot.");
UpdateScratcher3(playerid);
return 1;
}
else
{
new rand=random(3);
new addtotal = rand+1;
if(total1[playerid] == 0){total1[playerid] = addtotal;}
else if(total2[playerid] == 0){total2[playerid] = addtotal;}
else if(total3[playerid] == 0){total3[playerid] = addtotal;}
valstr(num6,addtotal);
scratched_num6[playerid] = 1;
UpdateScratcher3(playerid);
scratchcount[playerid]++;
}
if (scratchcount[playerid] == 3)
{
if (total1[playerid] + total2[playerid] + total3[playerid] == 7)
{
if(GLOBAL_MSGS == 1)
{
new name[48];
new msg[128];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg), "%s just won $77 in the 'Equals Seven' scratchers!",name);
SendClientMessageToAll(COLOR_GREEN, msg);
}
SendClientMessage(playerid, COLOR_GREEN, "YOU'RE A WINNER!");
GivePlayerMoney(playerid, 77);
}
else
{
SendClientMessage(playerid, COLOR_GREEN, "Your numbers were not equal to seven. Please try again.");
}
}
}
}
}
return 1;
}
return 0;
}
I've never seen this before in SAMP, and I'm a guy who likes to be original. Looking forward to adding onto this FS if you have ideas for improvement. This FS is meant to be added to your gamemode script to be able to purchase the tickets from a store or something similar. Thanks for downloading and I look forward to your compliments!
Images
![](http://s25.postimg.org/6dfaua81r/gta_sa_2014_04_15_21_16_21_91.png)
![](http://s25.postimg.org/tt1tddh6n/gta_sa_2014_04_15_21_16_54_39.png)
Download
Mediafire