Check random problem
#1

Message is not sent.
Where is the problem?

Код:
new RandomBox1[][] =
{
    "LD_SLOT:r_69",
    "LD_SLOT:r_69",
    "LD_SLOT:r_69",
    "LD_SLOT:r_69",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:bell",
    "LD_SLOT:bell",
    "LD_SLOT:bell",
    "LD_SLOT:bar2_o",
    "LD_SLOT:bar1_o",
    "LD_SLOT:bar1_o"
};

new RandomBox2[][] =
{
    "LD_SLOT:r_69",
    "LD_SLOT:r_69",
    "LD_SLOT:r_69",
    "LD_SLOT:r_69",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:bell",
    "LD_SLOT:bell",
    "LD_SLOT:bell",
    "LD_SLOT:bar2_o",
    "LD_SLOT:bar1_o",
    "LD_SLOT:bar1_o"
};

new RandomBox3[][] =
{
    "LD_SLOT:r_69",
    "LD_SLOT:r_69",
    "LD_SLOT:r_69",
    "LD_SLOT:r_69",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:bell",
    "LD_SLOT:bell",
    "LD_SLOT:bell",
    "LD_SLOT:bar2_o",
    "LD_SLOT:bar1_o",
    "LD_SLOT:bar1_o"
};

//IN COMMAND
		if(rand1 == 0) if(rand1 == 1) if(rand1 == 2) if(rand1 == 3)
		{
 			if(rand2 == 0) if(rand2 == 1) if(rand2 == 2) if(rand2 == 3)
 			{
 			    if(rand3 == 0) if(rand3 == 1) if(rand3 == 2) if(rand3 == 3)
 			    {
 			        SendClientMessage(playerid, -1, "69 69 69");
 			    }
 			}
		}
		
		if(rand1 == 4) if(rand1 == 5) if(rand1 == 6) if(rand1 == 7) if(rand1 == 8)
		{
		    if(rand2 == 4) if(rand2 == 5) if(rand2 == 6) if(rand2 == 7) if(rand2 == 8)
		    {
		        if(rand3 == 4) if(rand3 == 5) if(rand3 == 6) if(rand3 == 7) if(rand3 == 8)
				{
 					SendClientMessage(playerid, -1, "grape grape grape");
				}
			}
		}
		
		if(rand1 == 9) if(rand1 == 10) if(rand1 == 11) if(rand1 == 12) if(rand1 == 13)
		{
		    if(rand2 == 9) if(rand2 == 10) if(rand2 == 11) if(rand2 == 12) if(rand2 == 13)
		    {
		        if(rand3 == 9) if(rand3 == 10) if(rand3 == 11) if(rand3 == 12) if(rand3 == 13)
				{
 					SendClientMessage(playerid, -1, "cherry cherry cherry");
				}
			}
		}
		
		if(rand1 == 14) if(rand1 == 15) if(rand1 == 16)
		{
		    if(rand2 == 14) if(rand2 == 15) if(rand2 == 16)
		    {
		        if(rand3 == 14) if(rand3 == 15) if(rand3 == 16)
				{
 					SendClientMessage(playerid, -1, "bells bells bells");
				}
			}
		}
		
		if(rand1 == 17)
		{
		    if(rand2 == 17)
		    {
		        if(rand3 == 17)
		        {
 					SendClientMessage(playerid, -1, "JACKPOT!");
				}
			}
		}
		
		if(rand1 == 18) if(rand1 == 19)
		{
		    if(rand2 == 18) if(rand2 == 19)
		    {
		        if(rand3 == 18) if(rand3 == 19)
				{
 					SendClientMessage(playerid, -1, "half jackpot .. :/");
				}
			}
		}
Reply
#2

One condition by line.
Use something like: if(rand1 == 0 || rand1 == 1 || rand1 == 2)
etc..
Reply
#3

Quote:
Originally Posted by Chipardeur
Посмотреть сообщение
One condition by line.
Use something like: if(rand1 == 0 || rand1 == 1 || rand1 == 2)
etc..
As Chipardeur said, but I'd go about it another way such as using && with the three choices and random potabilities.
Reply
#4

I made up this little edit of your code:
pawn Код:
new RandomBox[][] =
{
    "LD_SLOT:r_69",
    "LD_SLOT:r_69",
    "LD_SLOT:r_69",
    "LD_SLOT:r_69",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:grapes",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:cherry",
    "LD_SLOT:bell",
    "LD_SLOT:bell",
    "LD_SLOT:bell",
    "LD_SLOT:bar2_o",
    "LD_SLOT:bar1_o",
    "LD_SLOT:bar1_o"
};

//IN COMMAND
    new rand1 = random(sizeof(RandomBox)), rand2 = random(sizeof(RandomBox)), rand3 = random(sizeof(RandomBox));
    switch(rand1)
    {
        case 0 .. 3: if((0 <= rand2 <= 3) && (0 <= rand3 <= 3)) SendClientMessage(playerid, -1, "69 69 69");
        case 4 .. 8: if((4 <= rand2 <= 8) && (4 <= rand3 <= 8)) SendClientMessage(playerid, -1, "Grape Grape Grape");
        case 9 .. 13: if((9 <= rand2 <= 13) && (9 <= rand3 <= 13)) SendClientMessage(playerid, -1, "Cherry Cherry Cherry");
        case 14 .. 16: if((14 <= rand2 <= 16) && (14 <= rand3 <= 16)) SendClientMessage(playerid, -1, "Bells Bells Bells");
        case 17: if(rand2 == 17 && rand3 == 17) SendClientMessage(playerid, -1, "JACKPOT!!!");
        case 18, 19: if((18 <= rand2 <= 19) && (18 <= rand3 <= 19)) SendClientMessage(playerid, -1, "Half Jackpot... :/");
    }
There's no need to create 3 arrays that contain exactly the same information. You can just access from the same array. I'm guessing this is what you're trying to do, based on the code you've provided.
Reply
#5

Great, that's that.
Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)