Thread: Random help

Results 1 to 6 of 6
  1. #1 Random help 
    Typical Swede


    Join Date
    Jul 2008
    Posts
    1,162
    Thanks given
    204
    Thanks received
    154
    Rep Power
    217
    Hello, i need a "code" for random etc. i wanna make the barrows chest give random barrows.

    barrows id's:
    Code:
    4708, 4710, 4712, 4714, 4716, 4718, 4720, 4722, 4724, 4726, 4728, 4730, 4732, 4734, 4736, 4738
    Help is appreciated :]

    'Strange things did happen here no stranger would it be'
    ______________________________________________
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Jan 2008
    Posts
    2,340
    Thanks given
    20
    Thanks received
    575
    Rep Power
    1202
    Code:
    	public static int randomChest[] = {708, 4710, 4712, 4714, 4716, 4718, 4720, 4722, 4724, 4726, 4728, 4730, 4732, 4734, 4736, 4738};
    
    	public static int getRandomChest() {
    		return randomChest[(int)(Math.random()*randomChest.length)];
    	}
    Usage:

    Code:
    Engine.playerItems.addItem(p, getRandomChest(), 1);
    Reply With Quote  
     

  3. #3  
    Hi.

    'Mystic Flow's Avatar
    Join Date
    Nov 2007
    Posts
    7,146
    Thanks given
    256
    Thanks received
    1,252
    Rep Power
    3714
    Quote Originally Posted by Lil_Michael View Post
    Code:
    	public static int randomChest[] = {708, 4710, 4712, 4714, 4716, 4718, 4720, 4722, 4724, 4726, 4728, 4730, 4732, 4734, 4736, 4738};
    
    	public static int getRandomChest() {
    		return randomChest[(int)(Math.random()*randomChest.length)];
    	}
    Usage:

    Code:
    Engine.playerItems.addItem(p, getRandomChest(), 1);
    How bout if we want to add a number of runes to the reward?



    Reply With Quote  
     

  4. #4  
    Registered Member
    AndyJay's Avatar
    Join Date
    Jun 2008
    Posts
    1,285
    Thanks given
    38
    Thanks received
    48
    Rep Power
    84
    Engine.playerItems.addItem(p, getRandomChest(), Misc.random(50));

    Change the (50) to the max amount... It'll randomly choose a number up to 50.
    Reply With Quote  
     

  5. #5  
    Member Random help Market Banned


    Luke132's Avatar
    Join Date
    Dec 2007
    Age
    35
    Posts
    12,574
    Thanks given
    199
    Thanks received
    7,106
    Rep Power
    5000
    Quote Originally Posted by Mystic Flow View Post
    How bout if we want to add a number of runes to the reward?
    Make a new array with the rune id's (int[] runes = {56*** then use

    Code:
    Engine.playerItems.addItem(p, getRandomRunes(), Misc.random(randomAmountHere));
    The random runes method would be the same as the random chest one.

    Attached imageAttached image
    Reply With Quote  
     

  6. #6  
    Hi.

    'Mystic Flow's Avatar
    Join Date
    Nov 2007
    Posts
    7,146
    Thanks given
    256
    Thanks received
    1,252
    Rep Power
    3714
    Quote Originally Posted by Luke132 View Post
    Make a new array with the rune id's (int[] runes = {56*** then use

    Code:
    Engine.playerItems.addItem(p, getRandomRunes(), Misc.random(randomAmountHere));
    The random runes method would be the same as the random chest one.
    Thanks, you people are beast at this lol
    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

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •