Originally Posted by
dutchgala
Hello, I want to make it so when you type a command you teleport to a random location between x coords 3000 and 3251 and I've tried it like this just for test:
int testX = (int )(Math.random() * 3251 + 3000);
int testY = (int )(Math.random() * 50 + 1);
if(playerCommand.startsWith("teletest")) {
c.sendMessage("Coords: " + TestX);
c.sendMessage("Coords: " + TestY);
}
And TestY works fine, that gives me numbers between 1 and 50 but with TestX it gives me random numbers always above 3251 and I have no clue why that wont work or does it only work with number up to 50? Any help would be appreciated.
Sorry for my english.
(I posted the same topic in rs2 client help and I saw after that it was the wrong section, can a mod please delete that topic for me?)
Try this?
Code:
int TestX = Utils.random (3000, 3251);
int TestY = Utils.random (1, 50);
If rs2 don't have utils.random already use this
Code:
public static final int getRandom(int maxValue) {
return (int) (Math.random() * (maxValue + 1));
}