[Tutorial] [TUT]Lotto script
#35

not work i don't know why cmds work but no announce ment and lotto winner

pawn Код:
#include <a_samp> //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];

#if defined FILTERSCRIPT

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;
}
forward Draw();
public Draw()
{
    new Lnum = random(100) + 1; //Picks a random number
    new winner = -1; //Winners ID variable
    for(new i; i<MAX_PLAYERS; i++) //checks through all players
    {
        if(!IsPlayerConnected(i)) continue; //Players not connected
        if(GetPVarInt(i, "LottoNumber") == Lnum) winner = i; //If the players number is the winning number
        SetPVarInt(i, "LottoNumber", 0); //Resets the number
    }
    if(winner != -1) //If there was a winner
    {
        new Pname[24];
        GetPlayerName(winner, Pname, 24);
        new str[100];
        SendClientMessageToAll(0x62FF32FF, "****LOTTO INFORMATION****"); //Lotto info
        format(str, sizeof(str), "WE HAVE A WINNER! %s(%d) won $%d!!!!", Pname, winner, Jackpot);
        SendClientMessageToAll(0x62FF32FF, str); //Lotto info
        SendClientMessageToAll(0x62FF32FF, "Make sure you get a ticket for next draw /lotto [1-100]!!"); //Lotto info
        GivePlayerMoney(winner, Jackpot); //Gives the winner the cash
        Jackpot = LOTTO_START; //Resets the jackpot
    }
    if(winner == -1) //No winner
    {
                new str[100];
        SendClientMessageToAll(0x62FF32FF, "****LOTTO INFORMATION****"); //Lotto info
        format(str, sizeof(str), "There was no lotto winner for this draw. The jackpot will go up to $%d!", Jackpot);
        SendClientMessageToAll(0x62FF32FF, str); //Lotto info
        SendClientMessageToAll(0x62FF32FF, "Make sure you get a ticket for next draw /lotto [1-100]!!");
    }
    for(new s; s<100; s++)
    {
        Numbers[s] = 0; //Resets all numbers so they are usable.
    }
    return 1;
}
public OnFilterScriptExit()
{
    return 1;
}

#endif

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;
}
Reply


Messages In This Thread
[TUT]Lotto script - by [HiC]TheKiller - 15.07.2010, 11:35
Re: [TUT]Lotto script - by willsuckformoney - 15.07.2010, 11:37
Re: [TUT]Lotto script - by jamesbond007 - 15.07.2010, 11:58
Re: [TUT]Lotto script - by [HiC]TheKiller - 15.07.2010, 12:00
Re: [TUT]Lotto script - by jamesbond007 - 15.07.2010, 12:02
Re: [TUT]Lotto script - by Aleluja - 15.07.2010, 13:22
Re: [TUT]Lotto script - by ViruZZzZ_ChiLLL - 15.07.2010, 14:07
Re: [TUT]Lotto script - by Kar - 16.07.2010, 02:52
Re: [TUT]Lotto script - by FireCat - 16.07.2010, 10:08
Re: [TUT]Lotto script - by Amit_B - 17.07.2010, 16:02
Re: [TUT]Lotto script - by DiddyBop - 17.07.2010, 16:53
Re: [TUT]Lotto script - by willsuckformoney - 17.07.2010, 21:43
Re: [TUT]Lotto script - by [HiC]TheKiller - 17.07.2010, 23:58
Re: [TUT]Lotto script - by Amit_B - 18.07.2010, 03:47
Re: [TUT]Lotto script - by Kar - 18.07.2010, 05:48
Re: [TUT]Lotto script - by Scenario - 19.07.2010, 08:34
Re: [TUT]Lotto script - by [HiC]TheKiller - 19.07.2010, 08:35
Re: [TUT]Lotto script - by Scenario - 19.07.2010, 08:38
Re: [TUT]Lotto script - by Juve913 - 23.07.2010, 08:54
Re: [TUT]Lotto script - by Armin_Avdic - 23.07.2010, 11:23
Re: [TUT]Lotto script - by Flake. - 23.07.2010, 11:45
Re: [TUT]Lotto script - by DrifteX_ - 23.07.2010, 11:49
Re: [TUT]Lotto script - by Elviss - 23.08.2010, 08:37
Re: [TUT]Lotto script - by Claude - 23.08.2010, 17:53
Re: [TUT]Lotto script - by [HiC]TheKiller - 23.08.2010, 19:39
Re: [TUT]Lotto script - by playbox12 - 24.08.2010, 15:40
Re: [TUT]Lotto script - by Elviss - 28.08.2010, 17:59
Re: [TUT]Lotto script - by [HiC]TheKiller - 28.08.2010, 21:06
Re: [TUT]Lotto script - by Lenny the Cup - 11.10.2010, 23:59
Re: [TUT]Lotto script - by [HiC]TheKiller - 12.10.2010, 03:53
Re: [TUT]Lotto script - by CrunkBankS - 16.03.2011, 16:39
Re: [TUT]Lotto script - by justsomeguy - 16.03.2011, 18:09
Re: [TUT]Lotto script - by alpha500delta - 17.03.2011, 14:21
Re: [TUT]Lotto script - by justsomeguy - 17.03.2011, 20:11
Re: [TUT]Lotto script - by Venice - 06.04.2011, 04:13
Respuesta: [TUT]Lotto script - by Host-samp - 08.04.2011, 15:28
Re: [TUT]Lotto script - by ScriptJorkis - 11.01.2012, 12:06
Re: [TUT]Lotto script - by Min - 11.01.2012, 12:52
AW: [TUT]Lotto script - by Babul - 11.01.2012, 14:41
Re: [TUT]Lotto script - by (ETR)Geto244 - 25.02.2012, 15:10
Re: [TUT]Lotto script - by [Cali]ChrOnic_T - 03.03.2012, 00:45
Re: [TUT]Lotto script - by Ukko - 28.06.2012, 14:34
Re: [TUT]Lotto script - by $$inSane - 29.06.2012, 14:28
Re: [TUT]Lotto script - by Lordzy - 29.06.2012, 14:40
Re: [TUT]Lotto script - by HighPitchedVoice - 29.06.2012, 14:56
Re: [TUT]Lotto script - by Sufrdude099 - 27.10.2012, 16:20
FIXED - by Sufrdude099 - 27.10.2012, 19:04
Re: [TUT]Lotto script - by Dawood - 16.05.2015, 14:09
Re: [TUT]Lotto script - by FernandoLight - 16.05.2015, 16:59
Re: [TUT]Lotto script - by Konverse - 16.05.2015, 17:17
Re: [TUT]Lotto script - by J0sh... - 16.05.2015, 17:19
Re: [TUT]Lotto script - by Dawood - 17.05.2015, 14:16
Re: [TUT]Lotto script - by Dawood - 18.05.2015, 14:02
Re: [TUT]Lotto script - by Luis- - 18.05.2015, 14:19
Re: [TUT]Lotto script - by jamesbond007 - 18.05.2015, 20:48

Forum Jump:


Users browsing this thread: 17 Guest(s)