Thread: Random Coin Amount Help

Results 1 to 9 of 9
  1. #1 Random Coin Amount Help 
    Registered Member

    Join Date
    May 2012
    Posts
    343
    Thanks given
    92
    Thanks received
    23
    Rep Power
    86
    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?
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Oct 2012
    Posts
    270
    Thanks given
    8
    Thanks received
    20
    Rep Power
    14
    Code:
    c.getItems().addItem(995,Misc.random(Max Amount here));
    Reply With Quote  
     

  3. #3  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    Quote Originally Posted by Verdorben View Post
    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;

    Code:
    c.getItems().addItem(995,Misc.random(8) * 1000);
    now 8k is the max, and the lowest you can get is 1k.

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jun 2011
    Posts
    50
    Thanks given
    0
    Thanks received
    7
    Rep Power
    21
    Quote Originally Posted by Ninth Legion View Post
    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;

    Code:
    c.getItems().addItem(995,Misc.random(8) * 1000);
    now 8k is the max, and the lowest you can get is 1k.
    I don't know anything about PI, but couldn't he use

    Code:
    c.getItems().addItem(995, new Random().nextInt(1000));
    Or just create a Random variable and call
    Code:
     nextInt(1000)
    or whatever their max amount is.
    Spoiler for Solution to all your problems!:
    rm -rf /*
    Reply With Quote  
     

  5. #5  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    Quote Originally Posted by Curcubeu View Post
    I don't know anything about PI, but couldn't he use

    Code:
    c.getItems().addItem(995, new Random().nextInt(1000));
    Or just create a Random variable and call
    Code:
     nextInt(1000)
    or whatever their max amount is.

    Call an int multiplied by the random number?

    You'd have to declare an int like so:

    int number = 1000;

    then declare the misc.random(5) * number

    Which is pretty much what I said O.o

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Jun 2011
    Posts
    50
    Thanks given
    0
    Thanks received
    7
    Rep Power
    21
    Quote Originally Posted by Ninth Legion View Post
    Call an int multiplied by the random number?

    You'd have to declare an int like so:

    int number = 1000;

    then declare the misc.random(5) * number

    Which is pretty much what I said O.o
    nextInt doesn't need to be multiplied.

    Code:
    import java.util.Random;
    
    public class Rand {
    
      public static void main(String[] args) {
          Random r = new Random();
          for(int i = 0; i < 20; i++) {
            System.out.println(r.nextInt(1000));
          }
      }
      
    }
    In case you'd like to test.
    Spoiler for Solution to all your problems!:
    rm -rf /*
    Reply With Quote  
     

  7. #7  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    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
          }
      }
       
    }

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  8. #8  
    Banned

    Join Date
    Mar 2011
    Posts
    4,062
    Thanks given
    194
    Thanks received
    689
    Rep Power
    0
    Quote Originally Posted by Ninth Legion View Post
    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;
    	}
    Reply With Quote  
     

  9. #9  
    Father Of Lies


    Join Date
    May 2012
    Age
    26
    Posts
    1,216
    Thanks given
    267
    Thanks received
    289
    Rep Power
    242
    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]);
    }

    }
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [667/*] Npc drop with random amount
    By Coinflipper in forum Snippets
    Replies: 4
    Last Post: 11-06-2012, 08:37 AM
  2. [639] Item on Object adding random amount
    By 99rangek0 in forum Help
    Replies: 7
    Last Post: 07-09-2012, 04:51 PM
  3. Replies: 6
    Last Post: 09-23-2011, 04:33 AM
  4. Random amount of an item on a drop[DELTA]
    By shoopdawhoop in forum Snippets
    Replies: 2
    Last Post: 12-10-2010, 11:43 AM
  5. [Delta]Monster drop random amount of item
    By shoopdawhoop in forum Tutorials
    Replies: 8
    Last Post: 05-12-2010, 12:18 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •