Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*==============================================================================
- | |
- | Scratch Card by JIDAVID v1 |
- | http://forum.sa-mp.com/ |
- | |
- ==============================================================================*/
- #include <a_samp>
- #define SLOTS 500 //SLOTS of your server
- #define DIALOG_CARD 7777 //Dialog ID
- new Card[SLOTS];
- new LNumber1[SLOTS];
- new LNumber2[SLOTS];
- new LNumber3[SLOTS];
- new LTimer1[SLOTS];
- new LTimer2[SLOTS];
- new LTimer3[SLOTS];
- new bool:CActive[SLOTS];
- new bool:ActivedCard[SLOTS];
- new bool:Spawned[SLOTS];
- new Text:TextCard0;
- new Text:TextCard1;
- new Text:TextCard2;
- new Text:TextCard3;
- new Text:TextCard4;
- new Text:ScratchArea1[SLOTS];
- new Text:ScratchArea2[SLOTS];
- new Text:ScratchArea3[SLOTS];
- new Text:TextCard5;
- new Text:TextCard6;
- forward ShowNumber2(playerid);
- forward ShowNumber3(playerid);
- forward HideCard(playerid);
- public OnFilterScriptInit()
- {
- TextCard0 = TextDrawCreate(297.000000, 332.000000, "_");
- TextDrawAlignment(TextCard0, 2);
- TextDrawBackgroundColor(TextCard0, -65281);
- TextDrawFont(TextCard0, 1);
- TextDrawLetterSize(TextCard0, 0.500000, 9.799998);
- TextDrawColor(TextCard0, -65281);
- TextDrawSetOutline(TextCard0, 0);
- TextDrawSetProportional(TextCard0, 1);
- TextDrawSetShadow(TextCard0, 1);
- TextDrawUseBox(TextCard0, 1);
- TextDrawBoxColor(TextCard0, -5614081);
- TextDrawTextSize(TextCard0, 0.000000, 150.000000);
- TextCard1 = TextDrawCreate(399.000000, 379.000000, "_");
- TextDrawAlignment(TextCard1, 2);
- TextDrawBackgroundColor(TextCard1, -65281);
- TextDrawFont(TextCard1, 1);
- TextDrawLetterSize(TextCard1, 0.500000, 4.600000);
- TextDrawColor(TextCard1, -65281);
- TextDrawSetOutline(TextCard1, 0);
- TextDrawSetProportional(TextCard1, 1);
- TextDrawSetShadow(TextCard1, 1);
- TextDrawUseBox(TextCard1, 1);
- TextDrawBoxColor(TextCard1, -1061109505);
- TextDrawTextSize(TextCard1, 0.000000, -51.000000);
- TextCard2 = TextDrawCreate(378.000000, 380.000000, "1 = 1 000$ ~n~5 = 5 000$ ~n~10 = 10 000$ ~n~25 = 25 000$ ~n~50 = 50 000$");
- TextDrawBackgroundColor(TextCard2, 255);
- TextDrawFont(TextCard2, 1);
- TextDrawLetterSize(TextCard2, 0.160000, 0.900000);
- TextDrawColor(TextCard2, 16711935);
- TextDrawSetOutline(TextCard2, 1);
- TextDrawSetProportional(TextCard2, 1);
- TextCard3 = TextDrawCreate(399.000000, 362.000000, "Prices");
- TextDrawAlignment(TextCard3, 2);
- TextDrawBackgroundColor(TextCard3, 255);
- TextDrawFont(TextCard3, 0);
- TextDrawLetterSize(TextCard3, 0.500000, 1.400000);
- TextDrawColor(TextCard3, -1);
- TextDrawSetOutline(TextCard3, 1);
- TextDrawSetProportional(TextCard3, 1);
- TextDrawUseBox(TextCard3, 1);
- TextDrawBoxColor(TextCard3, -8388353);
- TextDrawTextSize(TextCard3, 0.000000, -51.000000);
- TextCard4 = TextDrawCreate(252.000000, 334.000000, "Lottery San Andreas");
- TextDrawBackgroundColor(TextCard4, 255);
- TextDrawFont(TextCard4, 0);
- TextDrawLetterSize(TextCard4, 0.390000, 1.100000);
- TextDrawColor(TextCard4, -8388353);
- TextDrawSetOutline(TextCard4, 1);
- TextDrawSetProportional(TextCard4, 1);
- for(new i=0; i<SLOTS; i++)
- {
- ScratchArea1[i] = TextDrawCreate(255.000000, 390.000000, "_");
- TextDrawAlignment(ScratchArea1[i], 2);
- TextDrawBackgroundColor(ScratchArea1[i], 255);
- TextDrawFont(ScratchArea1[i], 1);
- TextDrawLetterSize(ScratchArea1[i], 0.500000, 2.600000);
- TextDrawColor(ScratchArea1[i], -1);
- TextDrawSetOutline(ScratchArea1[i], 1);
- TextDrawSetProportional(ScratchArea1[i], 1);
- TextDrawUseBox(ScratchArea1[i], 1);
- TextDrawBoxColor(ScratchArea1[i], -8388353);
- TextDrawTextSize(ScratchArea1[i], 0.000000, -33.000000);
- TextDrawSetSelectable(ScratchArea1[i], 0);
- }
- for(new i=0; i<SLOTS; i++)
- {
- ScratchArea2[i] = TextDrawCreate(297.000000, 390.000000, "_");
- TextDrawAlignment(ScratchArea2[i], 2);
- TextDrawBackgroundColor(ScratchArea2[i], 255);
- TextDrawFont(ScratchArea2[i], 1);
- TextDrawLetterSize(ScratchArea2[i], 0.500000, 2.600000);
- TextDrawColor(ScratchArea2[i], -1);
- TextDrawSetOutline(ScratchArea2[i], 1);
- TextDrawSetProportional(ScratchArea2[i], 1);
- TextDrawUseBox(ScratchArea2[i], 1);
- TextDrawBoxColor(ScratchArea2[i], -8388353);
- TextDrawTextSize(ScratchArea2[i], 0.000000, -33.000000);
- TextDrawSetSelectable(ScratchArea2[i], 0);
- }
- for(new i=0; i<SLOTS; i++)
- {
- ScratchArea3[i] = TextDrawCreate(340.000000, 390.000000, "_");
- TextDrawAlignment(ScratchArea3[i], 2);
- TextDrawBackgroundColor(ScratchArea3[i], 255);
- TextDrawFont(ScratchArea3[i], 1);
- TextDrawLetterSize(ScratchArea3[i], 0.500000, 2.600000);
- TextDrawColor(ScratchArea3[i], -1);
- TextDrawSetOutline(ScratchArea3[i], 1);
- TextDrawSetProportional(ScratchArea3[i], 1);
- TextDrawUseBox(ScratchArea3[i], 1);
- TextDrawBoxColor(ScratchArea3[i], -8388353);
- TextDrawTextSize(ScratchArea3[i], 0.000000, -33.000000);
- TextDrawSetSelectable(ScratchArea3[i], 0);
- }
- TextCard5 = TextDrawCreate(238.000000, 351.000000, "Click to START. ~n~3 same numbers is win.");
- TextDrawBackgroundColor(TextCard5, 65535);
- TextDrawFont(TextCard5, 1);
- TextDrawLetterSize(TextCard5, 0.220000, 0.899999);
- TextDrawColor(TextCard5, -1);
- TextDrawSetOutline(TextCard5, 1);
- TextDrawSetProportional(TextCard5, 1);
- TextCard6 = TextDrawCreate(297.500000, 373.000000, "START");
- TextDrawAlignment(TextCard6, 2);
- TextDrawBackgroundColor(TextCard6, 0x000000FF);
- TextDrawFont(TextCard6, 1);
- TextDrawLetterSize(TextCard6, 0.330000, 1.000000);
- TextDrawColor(TextCard6, 0xFF0000FF);
- TextDrawSetOutline(TextCard6, 1);
- TextDrawSetProportional(TextCard6, 1);
- TextDrawSetSelectable(TextCard6, 1);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- Card[playerid] = 0;
- LNumber1[playerid] = 0;
- LNumber2[playerid] = 0;
- LNumber3[playerid] = 0;
- CActive[playerid] = false;
- ActivedCard[playerid] = false;
- Spawned[playerid] = false;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- Card[playerid] = 0;
- LNumber1[playerid] = 0;
- LNumber2[playerid] = 0;
- LNumber3[playerid] = 0;
- CActive[playerid] = false;
- ActivedCard[playerid] = false;
- Spawned[playerid] = false;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- Spawned[playerid] = true;
- if(CActive[playerid] == true)
- {
- TextDrawHideForPlayer(playerid, TextCard0);
- TextDrawHideForPlayer(playerid, TextCard1);
- TextDrawHideForPlayer(playerid, TextCard2);
- TextDrawHideForPlayer(playerid, TextCard3);
- TextDrawHideForPlayer(playerid, TextCard4);
- TextDrawHideForPlayer(playerid, TextCard5);
- TextDrawHideForPlayer(playerid, ScratchArea1[playerid]);
- TextDrawHideForPlayer(playerid, ScratchArea2[playerid]);
- TextDrawHideForPlayer(playerid, ScratchArea3[playerid]);
- CActive[playerid] = false;
- }
- CancelSelectTextDraw(playerid);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- Spawned[playerid] = false;
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(strcmp("/scratchcard", cmdtext, true, 12) == 0)
- {
- if(CActive[playerid] == true) return SendClientMessage(playerid, 0xFF0000FF, "[ ! ] {FFFFFF}You can scratching only one card now!");
- if(Card[playerid] < 1) return SendClientMessage(playerid, 0xFF0000FF, "[ ! ] {FFFFFF}You don't have scratch card!");
- if(Spawned[playerid] == false) return SendClientMessage(playerid, 0xFF0000FF, "[ ! ] {FFFFFF}You must be in game!");
- new string[128];
- format(string, sizeof string, "{FFFFFF}Are you sure, you want to scratch your card? \nYou own {FF8000}%d {FFFFFF}scratch cards.", Card[playerid]);
- ShowPlayerDialog(playerid, DIALOG_CARD, DIALOG_STYLE_MSGBOX, "{FF8000}Scratch card by JIDAVID", string, "Scratch", "Cancel");
- return 1;
- }
- if(strcmp("/buycard", cmdtext, true, 8) == 0)
- {
- if(GetPlayerMoney(playerid) < 3000) return SendClientMessage(playerid, 0xFF0000FF, "[ ! ] {FFFFFF}You don't have 3000$ to buy scratch card!");
- GivePlayerMoney(playerid, -3000);
- Card[playerid] ++;
- SendClientMessage(playerid, 0x00FF00FF, "[ ! ] {FFFFFF}You have successfully bought scratch card for 3000$!");
- return 1;
- }
- return 0;
- }
- public OnPlayerClickTextDraw(playerid, Text:clickedid)
- {
- if(clickedid == TextCard6)
- {
- if(ActivedCard[playerid] == true)
- {
- TextDrawSetSelectable(TextCard6, 0);
- TextDrawHideForPlayer(playerid, TextCard6);
- ActivedCard[playerid] = false;
- new RCislo = random(5);
- if(RCislo == 0){ LNumber1[playerid] = 1; }
- else if(RCislo == 1){ LNumber1[playerid] = 5; }
- else if(RCislo == 2){ LNumber1[playerid] = 10; }
- else if(RCislo == 3){ LNumber1[playerid] = 25; }
- else if(RCislo == 4){ LNumber1[playerid] = 50; }
- TextDrawHideForPlayer(playerid, ScratchArea1[playerid]);
- new la[50];
- format(la, sizeof la, "%d", LNumber1[playerid]);
- TextDrawSetString(ScratchArea1[playerid], la);
- TextDrawShowForPlayer(playerid, ScratchArea1[playerid]);
- new Float:X, Float:Y, Float:Z;
- GetPlayerPos(playerid, X, Y, Z);
- PlayerPlaySound(playerid, 1056, X, Y, Z);
- LTimer1[playerid] = SetTimerEx("ShowNumber2", 1000, 0, "i", playerid);
- LTimer2[playerid] = SetTimerEx("ShowNumber3", 2000, 0, "i", playerid);
- LTimer3[playerid] = SetTimerEx("HideCard", 3500, 0, "i", playerid);
- }
- }
- if(_:clickedid == INVALID_TEXT_DRAW)
- {
- if(CActive[playerid] == true)
- {
- KillTimer(LTimer1[playerid]), KillTimer(LTimer2[playerid]), KillTimer(LTimer3[playerid]);
- TextDrawHideForPlayer(playerid, TextCard0);
- TextDrawHideForPlayer(playerid, TextCard1);
- TextDrawHideForPlayer(playerid, TextCard2);
- TextDrawHideForPlayer(playerid, TextCard3);
- TextDrawHideForPlayer(playerid, TextCard4);
- TextDrawHideForPlayer(playerid, TextCard5);
- TextDrawHideForPlayer(playerid, TextCard6);
- TextDrawHideForPlayer(playerid, ScratchArea1[playerid]);
- TextDrawHideForPlayer(playerid, ScratchArea2[playerid]);
- TextDrawHideForPlayer(playerid, ScratchArea3[playerid]);
- CActive[playerid] = false;
- ActivedCard[playerid] = false;
- }
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_CARD)
- {
- if(response == 1)
- {
- Card[playerid] --;
- TextDrawSetString(ScratchArea1[playerid], "_");
- TextDrawSetString(ScratchArea2[playerid], "_");
- TextDrawSetString(ScratchArea3[playerid], "_");
- TextDrawSetSelectable(TextCard6, 1);
- TextDrawShowForPlayer(playerid, TextCard0);
- TextDrawShowForPlayer(playerid, TextCard1);
- TextDrawShowForPlayer(playerid, TextCard2);
- TextDrawShowForPlayer(playerid, TextCard3);
- TextDrawShowForPlayer(playerid, TextCard4);
- TextDrawShowForPlayer(playerid, TextCard5);
- TextDrawShowForPlayer(playerid, TextCard6);
- TextDrawShowForPlayer(playerid, ScratchArea1[playerid]);
- TextDrawShowForPlayer(playerid, ScratchArea2[playerid]);
- TextDrawShowForPlayer(playerid, ScratchArea3[playerid]);
- SelectTextDraw(playerid, 0x00FF00FF);
- CActive[playerid] = true;
- ActivedCard[playerid] = true;
- }
- }
- return 1;
- }
- public HideCard(playerid)
- {
- TextDrawHideForPlayer(playerid, TextCard0);
- TextDrawHideForPlayer(playerid, TextCard1);
- TextDrawHideForPlayer(playerid, TextCard2);
- TextDrawHideForPlayer(playerid, TextCard3);
- TextDrawHideForPlayer(playerid, TextCard4);
- TextDrawHideForPlayer(playerid, TextCard5);
- TextDrawHideForPlayer(playerid, TextCard6);
- TextDrawHideForPlayer(playerid, ScratchArea1[playerid]);
- TextDrawHideForPlayer(playerid, ScratchArea2[playerid]);
- TextDrawHideForPlayer(playerid, ScratchArea3[playerid]);
- CActive[playerid] = false;
- CancelSelectTextDraw(playerid);
- }
- public ShowNumber2(playerid)
- {
- new QRCislo = random(5);
- if(QRCislo == 0){ LNumber2[playerid] = 1; }
- else if(QRCislo == 1){ LNumber2[playerid] = 5; }
- else if(QRCislo == 2){ LNumber2[playerid] = 10; }
- else if(QRCislo == 3){ LNumber2[playerid] = 25; }
- else if(QRCislo == 4){ LNumber2[playerid] = 50; }
- new Float:X, Float:Y, Float:Z;
- GetPlayerPos(playerid, X, Y, Z);
- TextDrawHideForPlayer(playerid, ScratchArea2[playerid]);
- new string[6];
- format(string, sizeof string, "%d", LNumber2[playerid]);
- TextDrawSetString(ScratchArea2[playerid], string);
- TextDrawShowForPlayer(playerid, ScratchArea2[playerid]);
- PlayerPlaySound(playerid, 1056, X, Y, Z);
- }
- public ShowNumber3(playerid)
- {
- new QQRCislo = random(5);
- if(QQRCislo == 0){ LNumber3[playerid] = 1; }
- else if(QQRCislo == 1){ LNumber3[playerid] = 5; }
- else if(QQRCislo == 2){ LNumber3[playerid] = 10; }
- else if(QQRCislo == 3){ LNumber3[playerid] = 25; }
- else if(QQRCislo == 4){ LNumber3[playerid] = 50; }
- TextDrawHideForPlayer(playerid, ScratchArea3[playerid]);
- new string1[6];
- format(string1, sizeof string1, "%d", LNumber3[playerid]);
- TextDrawSetString(ScratchArea3[playerid], string1);
- TextDrawShowForPlayer(playerid, ScratchArea3[playerid]);
- new Float:X, Float:Y, Float:Z;
- GetPlayerPos(playerid, X, Y, Z);
- if(LNumber1[playerid] == LNumber2[playerid] && LNumber2[playerid] == LNumber3[playerid] && LNumber3[playerid] == LNumber1[playerid])
- {
- new x = LNumber1[playerid]*1000;
- new string[30];
- GivePlayerMoney(playerid, x);
- format(string, sizeof string, "You won ~n~~g~~h~%d$ !", x);
- GameTextForPlayer(playerid, string, 4000, 4);
- PlayerPlaySound(playerid, 1057, X, Y, Z);
- }
- else
- {
- PlayerPlaySound(playerid, 1055, X, Y, Z);
- GameTextForPlayer(playerid, "~r~~h~You lose!", 3000, 4);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment