SA-MP Forums Archive
Automatic lotto ? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Automatic lotto ? (/showthread.php?tid=276115)



Automatic lotto ? - antsolen - 12.08.2011

How i can make automatic loto in Larp GM , every payday loto starts automaticly ..


Re: Automatic lotto ? - Riddick94 - 12.08.2011

I can't look at your avatar.. it making me fun? or dissociation me?

pawn Код:
#include    "a_samp"
#include    "zcmd"
#include    "sscanf"

#undef  MAX_PLAYERS
#define MAX_PLAYERS     (50)

enum sInfo
{
    sLottoMoney,
    sLottoPrice
};
new ServerInfo[sInfo];

enum pInfo
{
    pLottoNumber
};
new PlayerInfo[MAX_PLAYERS][pInfo];

public OnFilterScriptInit()
{
    ServerInfo[sLottoPrice] = 650; // How much costs lot.
    ServerInfo[sLottoMoney] = 20000; // Money to win for the first time.
    return true;
}

public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][pLottoNumber] = 0;
    return true;
}

CMD:buylotto(playerid, params[])
{
    new number, string[128];
    if(sscanf(params, "d", number))SendClientMessage(playerid, -1, "Type: /lotto [1-46]");
    else if(number < 1 && number > 46)SendClientMessage(playerid, -1, "Bad number.");
    else if(PlayerInfo[playerid][pLottoNumber] > 0)SendClientMessage(playerid, -1, "You already took part in lotto.");
    else
    {
        if(ServerInfo[sLottoPrice] > GetPlayerMoney(playerid))
        {
            format(string, sizeof(string), "Not enough money. Need: %d$", ServerInfo[sLottoPrice]);
            SendClientMessage(playerid, -1, string);
        }

        GivePlayerMoney(playerid, ServerInfo[sLottoPrice]);
        PlayerInfo[playerid][pLottoNumber] = number;
        ServerInfo[sLottoMoney] += ServerInfo[sLottoPrice];


        format(string, sizeof(string), "* You bought a lot. Your number is %d. Lotto starting every Payday.", number);
        SendClientMessage(playerid, -1, string);
    }
    return true;
}

forward LottoSystem();
public LottoSystem()
{
    new
        Number = random(46)+1,
        Number1 = random(46)+1,
        Number2 = random(46)+1,
        Number3 = random(46)+1,
        Winners, string[128];
       
    format(string, sizeof(string), "Lotto: The drawn numbers: %d, %d, %d, %d.", Number, Number1, Number2, Number3);
    SendClientMessageToAll(-1, string);

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pLottoNumber] == Number)Winners++;
        if(Winners > 0)
        {
            format(string, sizeof(string), " Player %s bulls eye! Wins: %d$",PlayerName(i), ServerInfo[sLottoMoney]/Winners);
            if(PlayerInfo[i][pLottoNumber] == Number || PlayerInfo[i][pLottoNumber] == Number1 || PlayerInfo[i][pLottoNumber] == Number2 || PlayerInfo[i][pLottoNumber] == Number3)
            {
                SendClientMessageToAll(-1, string);
                GivePlayerMoney(i, ServerInfo[sLottoMoney]/Winners);
            }
            ServerInfo[sLottoMoney] = 0;
        }

        else if(ServerInfo[sLottoMoney] > 0)
        {
            format(string, sizeof(string), "Nobody came. Pool %d passes to the next draw.", ServerInfo[sLottoMoney]);
            SendClientMessageToAll(-1, string);
        }
       
        PlayerInfo[i][pLottoNumber] = 0;
        format(string, sizeof(string), "Another draw for the next PayDay. Use the command /lotto [1-46] to buy lottery tickets (Cost: %d$)", ServerInfo[sLottoPrice]);
        SendClientMessageToAll(-1, string);
    }
    return true;
}

stock PlayerName(playerid)
{
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    return Name;
}
Put LottoSystem(); in your PayDay public. I made this ^ for you now.


Re: Automatic lotto ? - antsolen - 13.08.2011

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
I can't look at your avatar.. it making me fun? or dissociation me?

pawn Код:
#include    "a_samp"
#include    "zcmd"
#include    "sscanf"

#undef  MAX_PLAYERS
#define MAX_PLAYERS     (50)

enum sInfo
{
    sLottoMoney,
    sLottoPrice
};
new ServerInfo[sInfo];

enum pInfo
{
    pLottoNumber
};
new PlayerInfo[MAX_PLAYERS][pInfo];

public OnFilterScriptInit()
{
    ServerInfo[sLottoPrice] = 650; // How much costs lot.
    ServerInfo[sLottoMoney] = 20000; // Money to win for the first time.
    return true;
}

public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][pLottoNumber] = 0;
    return true;
}

CMD:buylotto(playerid, params[])
{
    new number, string[128];
    if(sscanf(params, "d", number))SendClientMessage(playerid, -1, "Type: /lotto [1-46]");
    else if(number < 1 && number > 46)SendClientMessage(playerid, -1, "Bad number.");
    else if(PlayerInfo[playerid][pLottoNumber] > 0)SendClientMessage(playerid, -1, "You already took part in lotto.");
    else
    {
        if(ServerInfo[sLottoPrice] > GetPlayerMoney(playerid))
        {
            format(string, sizeof(string), "Not enough money. Need: %d$", ServerInfo[sLottoPrice]);
            SendClientMessage(playerid, -1, string);
        }

        GivePlayerMoney(playerid, ServerInfo[sLottoPrice]);
        PlayerInfo[playerid][pLottoNumber] = number;
        ServerInfo[sLottoMoney] += ServerInfo[sLottoPrice];


        format(string, sizeof(string), "* You bought a lot. Your number is %d. Lotto starting every Payday.", number);
        SendClientMessage(playerid, -1, string);
    }
    return true;
}

forward LottoSystem();
public LottoSystem()
{
    new
        Number = random(46)+1,
        Number1 = random(46)+1,
        Number2 = random(46)+1,
        Number3 = random(46)+1,
        Winners, string[128];
       
    format(string, sizeof(string), "Lotto: The drawn numbers: %d, %d, %d, %d.", Number, Number1, Number2, Number3);
    SendClientMessageToAll(-1, string);

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pLottoNumber] == Number)Winners++;
        if(Winners > 0)
        {
            format(string, sizeof(string), " Player %s bulls eye! Wins: %d$",PlayerName(i), ServerInfo[sLottoMoney]/Winners);
            if(PlayerInfo[i][pLottoNumber] == Number || PlayerInfo[i][pLottoNumber] == Number1 || PlayerInfo[i][pLottoNumber] == Number2 || PlayerInfo[i][pLottoNumber] == Number3)
            {
                SendClientMessageToAll(-1, string);
                GivePlayerMoney(i, ServerInfo[sLottoMoney]/Winners);
            }
            ServerInfo[sLottoMoney] = 0;
        }

        else if(ServerInfo[sLottoMoney] > 0)
        {
            format(string, sizeof(string), "Nobody came. Pool %d passes to the next draw.", ServerInfo[sLottoMoney]);
            SendClientMessageToAll(-1, string);
        }
       
        PlayerInfo[i][pLottoNumber] = 0;
        format(string, sizeof(string), "Another draw for the next PayDay. Use the command /lotto [1-46] to buy lottery tickets (Cost: %d$)", ServerInfo[sLottoPrice]);
        SendClientMessageToAll(-1, string);
    }
    return true;
}

stock PlayerName(playerid)
{
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    return Name;
}
Put LottoSystem(); in your PayDay public. I made this ^ for you now.
Its nice , but dont need new system , Im using gta rp gamemode , and admin have to write /startlotto to start lotto buy i want it comes automaticly on every payday