Thread: Question about array

Results 1 to 3 of 3
  1. #1 Question about array 
    Registered Member
    Join Date
    Jul 2017
    Posts
    11
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    Int [][] {11694,1},{11695,2},{11694,3},{11695,4}

    I just made this randomly to help describe what i mean,


    let's say first number is a item, and the second number is a level or what so ever,

    How would i make it only randomoys up to "lvl" 3 ie, and dont roll the last one

    and no cheap fix, such as if j[0] > "lvl" j[0] - 1
    Reply With Quote  
     

  2. #2  
    Respected Member


    Join Date
    Jan 2009
    Posts
    5,743
    Thanks given
    1,162
    Thanks received
    3,603
    Rep Power
    5000
    Code:
            Integer[][] arr = {{11694, 1}, {11695, 2}};
    
            List<Integer[]> availableItems = Arrays.stream(arr).filter(x -> requirement >= x[1]).collect(Collectors.toList());
            if(availableItems.isEmpty()) {
                // oh shit none meet the level requirement do something here
                return;
            }
    
            int item = availableItems.get(new Random().nextInt(availableItems.size()))[0];
    hope that helps
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jul 2017
    Posts
    11
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    Quote Originally Posted by Stuart View Post
    Code:
            Integer[][] arr = {{11694, 1}, {11695, 2}};
    
            List<Integer[]> availableItems = Arrays.stream(arr).filter(x -> requirement >= x[1]).collect(Collectors.toList());
            if(availableItems.isEmpty()) {
                // oh shit none meet the level requirement do something here
                return;
            }
    
            int item = availableItems.get(new Random().nextInt(availableItems.size()))[0];
    hope that helps

    Sorry about the slow response, Been busy lately, i will spend some time and check up on it, thanks a lot! so far
    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. Question about array's
    By Sir Tom in forum Help
    Replies: 10
    Last Post: 05-07-2010, 02:09 AM
  2. Question about custom sprites
    By Mikey` in forum RS2 Client
    Replies: 1
    Last Post: 04-10-2008, 01:16 AM
  3. Private Servers, Question about legality.
    By alongu in forum RS2 Server
    Replies: 10
    Last Post: 01-12-2008, 09:44 AM
  4. Lol noob question about renamed clients
    By newservermaker in forum RS2 Client
    Replies: 4
    Last Post: 01-05-2008, 11:42 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
  •