LOTTERY HELP
#1

What for do i need help:
- If i write /lotto it automaticly picks the number 0, but it shouldn't! It should say to pick one between 1 and 100!

Here the command

pawn Код:
CMD:lotto(playerid, params[])
{
    if(!strlen(params))
    {
        SCM(playerid, COLOR_GREEN, "Lotterie:");
        SCM(playerid, COLOR_WHITE, "Wдhle eine Nummer zwischen 1 und 100 aus.");
        new str[75];
        format(str, sizeof(str), "Derzeitiger Jackpot: $%d", Jackpot);
        SCM(playerid, COLOR_GREEN, str);
    }
    new Num = strval(params);
    if(Numbers[Num] == 1)
    {
        new str[75];
        format(str, sizeof(str), "Diese Nummer ist bereits vergeben!", Num);
        SCM(playerid, COLOR_RED, str);
        return 1;
    }
    if(GetPVarInt(playerid, "LottoNumber") != 0) return SCM(playerid, COLOR_GREY, "Du hast bereits einen Ticket!");
    SetPVarInt(playerid, "LottoNumber", Num);
    Numbers[Num] = 1;
    GeldGeben(playerid, -TICKET_COST);
    new str[75];
    format(str, sizeof(str), "Ticket gekauft! Du hast die Nummer: %d.", Num);
    SCM(playerid, COLOR_GOLD, str);
    format(str, sizeof(str), "Eine Ziehung findet jede %d Minuten statt und die Gewinner werden angekьndigt. Derzeitiger Jackpot ist: $%d", LOTTO_DRAW, Jackpot);
    Jackpot = Jackpot + LOTTO_JACKPOT;
    SCM(playerid, COLOR_LIGHTGREEN, str);
    return 1;
}
Reply
#2

You should use "random" function.
Reply
#3

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
You should use "random" function.
I already use

pawn Код:
public LottoZiehung()
{
    new Lnum = random(100) + 1;
    new winner = -1;
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(GetPVarInt(i, "LottoNumber") == Lnum) winner = i;
        SetPVarInt(i, "LottoNumber", 0);
    }
    if(winner != -1)
    {
        new Pname[24];
        GetPlayerName(winner, Pname, 24);
        new str[100];
        SCMToAll(COLOR_LIGHTGREEN, "Lotterie:");
        format(str, sizeof(str), "Wir haben einen Gewinner! %s(%d) hat %d$ gewonnen!", Pname, winner, Jackpot);
        SCMToAll(COLOR_GREEN, str);
        SCMToAll(COLOR_WHITE, "Du kannst dir ein neues Ticket mit '/lotto' kaufen.");
        GeldGeben(winner, Jackpot);
        Jackpot = LOTTO_START;
    }
    if(winner == -1)
    {
        new str[100];
        SCMToAll(COLOR_LIGHTRED, "Lotterie:");
        format(str, sizeof(str), "Diesmal hat keiner gewonnen! Der neue Jackpot ist: $%d.", Jackpot);
        SCMToAll(COLOR_WHITE, str);
        SCMToAll(COLOR_WHITE, "Du kannst dir ein neues Ticket mit '/lotto' kaufen.");
    }
    for(new s; s<100; s++)
    {
        Numbers[s] = 0;
    }
    return 1;
}
Reply
#4

Edit: Nvm.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)