/buyticket command. - 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: /buyticket command. (
/showthread.php?tid=275776)
/buyticket command. -
iGetty - 11.08.2011
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.
Re: /buyticket command. -
PrawkC - 11.08.2011
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
Re: /buyticket command. -
iGetty - 11.08.2011
Thank you