/buyticket command.
#1

How could I make a /buyticket command for the lottery?, and then when it is lotto time (I already have it set), how could I make it so that the person who did "/buyticket [NUMBER]" that if their number matches the one on the server, they win a prize?, also, how do I make it so it sends a random number? Like "the number for the lotto today is %d" then what?,

if it could be, please could the person/people helping maybe help it to be ZCMD?

Thanks in advance.
Reply
#2

pawn Code:
//Vars
new Ticket[MAX_PLAYERS];

CMD:buyticket(playerid, params[])
{
    new number;
    if(Ticket[playerid] != 0) return SendClientMessage(playerid, -1, "You already have a lotto ticket!");
    if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid, -1, "You can't afford the lotto ticket!");
    if(sscanf(params, "i", number) return SendClientMessage(playerid, -1, "Syntax: /buyticket <number>");
    if(number > 100 || number < 1) return SendClientMessage(playerid, -1, "Lotto number must be between 1-100!");
    //The rest happens if all above checks out
    Ticket[playerid] = number;
    SendClientMessage(playerid, -1. "Ticket bought!");
    GivePlayerMoney(playerid, -1000);
    return 1;
}

stock CheckTickets()
{
    new rand = rand2(1,100);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(rand == Ticket[i])
        {
            SendClientMessage(i, -1, "You've won the lotto!");
            GivePlayerMoney(i, 5000);
            return 1;
        }
    }
    return 1;
}

stock rand2(min, max)
{    
    new rand = random(max-min)+min;    
    return rand;
}
untested, wrote it up in notepad quickly.. you'd have to use checktickets with a timer or what not
Reply
#3

Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)