SA-MP Forums [Tutorial] [TUT]Lotto script
 New Account Members List Search Today's Posts Mark Forums Read

 15/07/2010, 11:35 AM #1 [HiC]TheKiller High-roller   Join Date: Mar 2008 Location: New Zealand Posts: 3,080 Reputation: 406 [TUT]Lotto script [TUT]Lotto script Alot of people where asking for this and it's pretty basic so here it is . Lets start with the defines (You can change most of them to what suits you) Code: ```#include //You need the a_samp include in almost every script. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 //DCMD #define LOTTO_JACKPOT 10000 //How much it goes up every 30 seconds or whenever someone buys a ticket #define LOTTO_START 200000 //How much the lotto starts off at every draw #define LOTTO_DRAW 10 //How many minutes between each lotto draw #define TICKET_COST 1000 //How much a ticket will cost new Jackpot = LOTTO_START; //Jackpot amount new Numbers[100]; //So 2 people don't get the same #``` Now we are going to add the timers for the lotto timers (Jackpot and Update). Code: ```public OnFilterScriptInit() { SetTimer("UpdateJP", 30000, true); //Updates the jackpot SetTimer("Draw", LOTTO_DRAW*1000*60, true); //Updates the jackpot return 1; } forward UpdateJP(); //Always forward a timer public UpdateJP() { Jackpot = Jackpot + LOTTO_JACKPOT; //Ads to the lotto jackpot return 1; }``` Now that we have that out of the way, we are going to do the command in DCMD Code: ```public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(lotto, 5, cmdtext); return 0; } dcmd_lotto(playerid, params[]) { if(!strlen(params)) //If the player doesn't put a nubmer { SendClientMessage(playerid, 0x62FF32FF, "***Lotto information***"); //Lotto info SendClientMessage(playerid, 0x62FF32FF, "Pick a number between 1 and 100 with /lotto [1-100]"); //Lotto info new str[75]; //Creates the string format(str, sizeof(str), "Current Jackpot is \$%d!!!!", Jackpot); //Formats the jackpot string SendClientMessage(playerid, 0x62FF32FF, str); //Shows the current jackpot } new Num = strval(params); //Makes the param that the player entered into a intiger if(Numbers[Num] == 1) //If the number is used { new str[75]; //Makes a variable format(str, sizeof(str), "Lotto number %d is already taken!", Num); //Formats a str SendClientMessage(playerid, 0xE21F1FFF, str); //Sends the message return 1; } if(GetPVarInt(playerid, "LottoNumber") != 0) return SendClientMessage(playerid, 0xE21F1FFF, "You have already got a lotto number"); SetPVarInt(playerid, "LottoNumber", Num); //Sets the players number Numbers[Num] = 1; //Number is used GivePlayerMoney(playerid, -TICKET_COST); //Takes away the ticket cost. new str[75]; format(str, sizeof(str), " Lotto ticket brought! You now have number %d for the next draw", Num); SendClientMessage(playerid, 0x62FF32FF, str); //Lotto info format(str, sizeof(str), " Draws are held every %d minutes and the winners are announced. Current jackpot is \$%d", LOTTO_DRAW, Jackpot); Jackpot = Jackpot + LOTTO_JACKPOT; //Ads to the lotto jackpot SendClientMessage(playerid, 0x62FF32FF, str); //Lotto info return 1; }``` Now for the actual lotto draw (Picks a random number between 0 and 100, checks against all players numbers and if the player has that number they win). Code: ```forward Draw(); public Draw() { new Lnum = random(100) + 1; //Picks a random number new winner = -1; //Winners ID variable for(new i; i
 15/07/2010, 11:37 AM #2 willsuckformoney High-roller     Join Date: Dec 2009 Posts: 1,516 Reputation: 65 Re: [TUT]Lotto script moO! tanks and FIRST MOOWNED
 15/07/2010, 11:58 AM #3 jamesbond007 Gangsta     Join Date: Oct 2009 Location: Canadia Posts: 821 Reputation: 40 Re: [TUT]Lotto script a simple and stupid mistake will ruin everything Code: `dcmd(lotto, 4, cmdtext);` __________________ Scripting for cash \$\$\$. PM me for info.
15/07/2010, 12:00 PM   #4
[HiC]TheKiller
High-roller

Join Date: Mar 2008
Location: New Zealand
Posts: 3,080
Reputation: 406
Re: [TUT]Lotto script

Quote:
 Originally Posted by jamesbond007 a simple and stupid mistake will ruin everything Code: `dcmd(lotto, 4, cmdtext);`
Yea,h my bad, tired as lol.
__________________

 15/07/2010, 12:02 PM #5 jamesbond007 Gangsta     Join Date: Oct 2009 Location: Canadia Posts: 821 Reputation: 40 Re: [TUT]Lotto script other then that awesome script! good tutorial i will use it sometime soon! __________________ Scripting for cash \$\$\$. PM me for info.
 15/07/2010, 01:22 PM #6 Aleluja Big Clucker   Join Date: Jul 2010 Location: Croatia Posts: 189 Reputation: 0 Re: [TUT]Lotto script nice tutorial TheKiller __________________ Tutorial How TO Make Moving Object
 15/07/2010, 02:07 PM #7 ViruZZzZ_ChiLLL High-roller     Join Date: Aug 2009 Location: I don't know Posts: 1,685 Reputation: 8 Re: [TUT]Lotto script Another awesome and useful tutorial [HiC]TheKiller :P __________________
 16/07/2010, 02:52 AM #8 Kar High-roller     Join Date: May 2010 Location: Black Asylum Posts: 3,238 Reputation: 396 Re: [TUT]Lotto script wow finally this is exactly what i f-***in wanted
 16/07/2010, 10:08 AM #9 FireCat Banned   Join Date: Jul 2010 Posts: 2,438 Reputation: 596 Re: [TUT]Lotto script nice thekiller
 17/07/2010, 04:02 PM #10 Amit_B Gangsta     Join Date: Nov 2007 Location: Israel Posts: 693 Reputation: 61 Re: [TUT]Lotto script Where's the tutorial? You've just posted your own lotto system and teached where to put every code in the script.

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules

All times are GMT. The time now is 04:54 AM.

 -- (EN) English -- (ES) Espaņol -- (RU) Русски Contact Us - SA-MP - Archive - Top