Originally Posted by
TheChosenOne
Do it like you correctly thought how you should make the array.
Then you got this:
"Mysterybox[(int) (Math.random()*Mysterybox.length)]"
That grabs one of the inner arrays (your new one is a 2D array). For example: {995, 10000000}
Index 0 is the itemId, index 1 is the itemAmount.
So in the end it'll be something like this (do not use Math.random() twice for the same reward!!!):
Code:
int reward = (int) (Math.random()*Mysterybox.length;
int itemId = Mysterybox[reward][0];
int amount = Mysterybox[reward][1];
Hey, thanks for the great help with explaining.
Could you help me a little further idk how to make it like 100%
I have this so far but i keep getting errors
Code:
int reward = (int) (Math.random()*MysteryBox.length);
int itemId = MysteryBox[reward][0];
int amount = MysteryBox[reward][1];
public static int MysteryBox[][] =
{{4151, 1},
{11694, 1},
{4153, 1},
{11696, 9},
{11698, 9},
{11700, 9},
{5699, 3},
{3440, 1}
};
public int randomMysterybox() {
return MysteryBox[(reward)(itemId)(amount) (Math.random()*MysteryBox.length)];
}