Lottery problem
#3

Try to use it:

pawn Код:
CMD:setlotto(playerid, params[])
{
    new string[256], lottonum;
    if(!IsPlayerLoggedIn(playerid)) return SCM(playerid, COLOR_GREY, "You must be logged in to use commands.");
    if(PlayerInfo[playerid][pAdmin] < 5) return SCM(playerid, COLOR_WHITE, "[{FF0606}ERROR{FFFFFF}]: You have no authorization to use this command.");
    if(sscanf(params, "d", lottonum)) return SCM(playerid, COLOR_GREY, "USAGE: /setlotto [prize]");
    if(lottonum < 10000 || lottonum > 1500000) return SCM(playerid, COLOR_GREY, "Invalid prize number. Prize must be between $10,000 and $1,500,000.");
    if(LottoNum != 0) return SCM(playerid, COLOR_GREY, "There is a lottery already going on.");
    else
    {
        SCMTA(COLOR_ORANGE, "A lottery has started and will end in 30 seconds! Type /lotto to pick your number.");
        format(string, sizeof(string), "Prize: $%d", lottonum);
        SCMTA(COLOR_ORANGE, string);
        LottoNum = random(99)+1;
        LottoPrize = lottonum;
        SetTimer("Lottery", 30000, false);
        format(string, sizeof(string), "[OwnerMsg]: The number for lotto is %d.", LottoNum);
        SendAdminMessage(COLOR_LIGHTRED, 7, string);
    }
    return 1;
}

forward Lottery(playerid);
public Lottery(playerid)
{
    new name[MAX_PLAYER_NAME], string[256];
    format(string, sizeof(string), "The lottery winning number is %d!",LottoNum);
    SCMTA(COLOR_ORANGE, string);
    foreach(Player, i)
    {
        //add authorization checks!
        if(PlayerInfo[i][pLottoNum] == LottoNum)
        {
            GetPlayerName(i, name, sizeof(name));
            LottoNum = -1;
            format(string, sizeof(string), "Congratulations! You have won the lottery of {FFFFFF}$%d.", LottoPrize);
            SCM(i, COLOR_GREY, string);
            format(string, sizeof(string), "Congratulations to %s! He has won the lottery of $%d!", RPN(i), LottoPrize);
            SCMTA(COLOR_ORANGE, string);
            GiveZaiatMoney(i, LottoPrize);
            LottoPrize = 0;
        }
        else SCM(i, COLOR_GREY, "You haven't won the lottery! Better luck next time."), PlayerInfo[i][pLottoNum] = 0;
        PlayerInfo[i][pLottoNum] = 0;
    }
    return 1;
}
Reply


Messages In This Thread
Lottery problem - by L.Hudson - 17.03.2013, 19:24
Re: Lottery problem - by mastermax7777 - 17.03.2013, 19:59
Re: Lottery problem - by stabker - 17.03.2013, 20:12
Re: Lottery problem - by Konstantinos - 17.03.2013, 20:18
Re: Lottery problem - by L.Hudson - 17.03.2013, 20:44

Forum Jump:


Users browsing this thread: 2 Guest(s)