Making a command throw random numbers - 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)
+--- Thread: Making a command throw random numbers (
/showthread.php?tid=562758)
Making a command throw random numbers -
kevin1990 - 11.02.2015
So, I was wondering
How would I go about making a lottery system that lets the users actually pick there numbers
then when it draws every hour.
it displays those numbers which will be 10 random numbers
and players get money based on how many numbers they picked correct.
Example.
Lotto Winning Numbers are: 7, 25, 13, 11, 67, 33, 56, 23, 17, 05
If player a for instance only got 2 numbers.
He might get 20 bucks
Whereas if Player B got all 10 numbers correct.
He has just one the jackpot of 1000
Re: Making a command throw random numbers -
JhnzRep - 11.02.2015
pawn Код:
new Playernumber[MAX_PLAYERS][10];
new LotteryNumber[10];
new Correctnumbers[MAX_PLAYERS];
forward OnLottery();
public OnLottery()
{
for(new i = 0; i < 10; i++)
{
LotteryNumber[i] = random(100);
}
return 1;
}
forward LotteryCheck();
public LotteryCheck()
{ for(new i = 0; i < MAX_PLAYERS; i++)
{
for(new a = 0; a < MAX_PLAYERS; a++)
if(Playernumber[i][a] == LotteryNumber[1])
{
Correctnumbers[i]++;
}
switch(Correctnumbers[i])
{
case 1:
{
GivePlayerMoney(i, 20)
}
case 2:
{
GivePlayerMoney(i, 50)
}
case 3:
{
GivePlayerMoney(i, 100)
}
case 4:
{
GivePlayerMoney(i, 200)
}
case 5:
{
GivePlayerMoney(i, 300)
}
case 6:
{
GivePlayerMoney(i, 400)
}
case 7:
{
GivePlayerMoney(i, 500)
}
case 8:
{
GivePlayerMoney(i, 600)
}
case 9:
{
GivePlayerMoney(i, 700)
}
case 10:
{
GivePlayerMoney(i, 1000)
}
}
}
return 1;
}
Try something like this.
Re: Making a command throw random numbers -
kevin1990 - 11.02.2015
Awesome, I'll try it out when I get home. Thanks bud!