Code:c.getItems().addItem(995,Misc.random(Max Amount here));
|
I wanna add to where you get a random amount of coins for opening a casket
what would I put in my static int for the casket?
Code:c.getItems().addItem(995,Misc.random(Max Amount here));
This, but that will give anwhere between 1 and whatever you put, put something like :
Code:c.getItems().addItem(995,Misc.random(1) * 1000);
Then just put the 1 to however much thousand you want it to be, like 1k is the max now;
now 8k is the max, and the lowest you can get is 1k.Code:c.getItems().addItem(995,Misc.random(8) * 1000);
Code:import java.util.Random; public class Rand { public static void main(String[] args) { Random r = new Random(); // why not just use the misc.random itself? for(int i = 0; i < 20; i++) { // not used System.out.println(r.nextInt(1000)); // nextInt not defined } } }
1. Doesn't matter...
2. Yes, it is....
3. Again, yes, it is....
ot: This is what I used when I want to fetch a random number between 2 numbers:
Code:public static int random(int startingRange, int endRange) { int random = (int) (Math.random() * (endRange + 1)); while (random < startingRange) random = (int) (Math.random() * (endRange + 1)); return random; }
Or if you want to have a random amount, depending on the list:
import java.util.Random;
public class Random {
private final int[] coinAmount {NUMBER1, NUMBER2, NUMBER3};
public static void main(String[] args) {
Random r = new Random();
int amount = r.nextInt(coinAmount.length)
addItem(995, coinAmount[amount]);
}
}
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |