Ok, so i made this..
#1

Lottery system..

Well basically, I got problems in these lines:

pawn Код:
LotN = random(ticket1 + random(ticket2));
pawn Код:
if(ticket1 || ticket2 == LotN)
        {
            format(string, sizeof(string), "Congratulations! You have won the lottery of {FFFFFF}$%d.", LotP);
            SendClientMessage(i, -1, string);
            format(string, sizeof(string), "Congratulations to %s! He has won the lottery of $%d!", name, LotP);
            SendClientMessageToAll(-1, string);
            GivePlayerMoney(i, LotP);
        }
The problem with line 1: Well, this system has a /setticket command, wich sets the ticket minimum/maximum ammount, The winning ticket is supposed to be between those two ammounts set on /setticket..

The problem with line 2: I Won the lottery once, BUT, it didn't give me no money. // I think i fixed this.


pawn Код:
new LotN;
new LotP;
new ticket1, ticket2;
new lottopr;
new Lottery[MAX_PLAYERS];


public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}


public OnFilterScriptExit()
{
    return 1;
}

CMD:lotto(playerid, params[])
{
   
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "[{FF0606}ERROR{FFFFFF}]: You have no authorization to use this command.");
    if(sscanf(params, "d", lottopr)) return SendClientMessage(playerid, -1, "{FF9900}/lotto {FFFFFF}<prize>");
    if(lottopr < 10000 || lottopr > 5000000) return SendClientMessage(playerid, -1, "Invalid prize number. Prize must be between $10,000 and $5,000,000.");
    if(LotN != 0) return SendClientMessage(playerid, -1, "There is a lottery already going on.");
    else
    {
        new string[256];
        SendClientMessage(playerid, -1, " "); SendClientMessageToAll(COLOR_ORANGE, "A new lottery has begun use {FFFFFF}/ticket {FF9900}[ number ] to buy a ticket!");
        format(string, sizeof(string), "Ticket numbers: {FFFFFF}[%d - %d]", ticket1, ticket2);
        SendClientMessageToAll(COLOR_ORANGE, string);
        format(string, sizeof(string), "Lottery Prize: $%d", lottopr);
        SendClientMessage(playerid, COLOR_ORANGE, string);
        SendClientMessage(playerid, -1, " ");
        LotN = random(ticket1 + random(ticket2));
        LotP = lottopr;
        SetTimer("Lotteria", 15000, false);
    }
    return 1;
}

CMD:setticket(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "[{FF0606}ERROR{FFFFFF}]: You have no authorization to use this command.");
    new string[256];
    if(sscanf(params, "dd", ticket1, ticket2)) return SendClientMessage(playerid, -1, " {FFFFFF} Usage: {FF9900} /setticket [Minimum - Maximum] ");
    format(string, sizeof(string), "You have set the minimum amount of a ticket {FFFFFF}to: %d {FF9900} and the maximum {FFFFFF}to: %d", ticket1, ticket2);
    SendClientMessage(playerid, COLOR_ORANGE , string);
    SendClientMessage(playerid, -1, "Remember you setted this to start a new lottery, not to just spam commands..");
    return 1;
}

CMD:ticket(playerid, params[])
{
    new string[256], number;
    if(LotN == 0) return SendClientMessage(playerid, -1, "There is no lottery going on.");
   
    if(sscanf(params, "d", number)) return SendClientMessage(playerid, -1, " {FF9900}/ticket {FFFFFF}<number>");
    if(number < ticket1 || number > ticket2)
    {
        format(string, sizeof(string), "Invalid ticket, ticket must be between %d and %d", ticket1, ticket2);
        SendClientMessage(playerid, -1, string);
    }
    else
    {
        format(string, sizeof(string), "You picked number %d for the lottery wich costs $100.", number);
        SendClientMessage(playerid, -1, string);
        Lottery[playerid] = number;
        GivePlayerMoney(playerid, -100);
    }
    return 1;
}

forward Lotteria(playerid);
public Lotteria(playerid)
{
    new name[MAX_PLAYER_NAME], string[256];
    format(string, sizeof(string), "The lottery winning number is %d!",LotN);
    SendClientMessageToAll(COLOR_ORANGE, string);
    foreach(Player, i)
    {
        GetPlayerName(i, name, sizeof(name));
        if(ticket1 || ticket2 == LotN)
        {
            format(string, sizeof(string), "Congratulations! You have won the lottery of {FFFFFF}$%d.", LotP);
            SendClientMessage(i, -1, string);
            format(string, sizeof(string), "Congratulations to %s! He has won the lottery of $%d!", name, LotP);
            SendClientMessageToAll(-1, string);
            GivePlayerMoney(i, LotP);
        }
        else SendClientMessage(i, -1, "You haven't win the lottery! Better luck next time.");
    }
    foreach(Player, i)
    {
        Lottery[i] = 0;
        }
            LotN = 0;
            LotP = 0;
            Lottery[playerid] = 0;
            return 1;
}
Reply


Messages In This Thread
Ok, so i made this.. - by Strier - 18.04.2013, 00:57
Re: Ok, so i made this.. - by Krx17 - 18.04.2013, 01:14
Respuesta: Ok, so i made this.. - by Strier - 18.04.2013, 01:24
Respuesta: Ok, so i made this.. - by Strier - 18.04.2013, 01:38
Re: Respuesta: Ok, so i made this.. - by FalconX - 18.04.2013, 02:06
Re: Respuesta: Ok, so i made this.. - by Krx17 - 18.04.2013, 05:21

Forum Jump:


Users browsing this thread: 1 Guest(s)