Thread: Looping through Ints

Results 1 to 6 of 6
  1. #1 Looping through Ints 
    Learner

    Kaiser Btw's Avatar
    Join Date
    Dec 2010
    Posts
    2,420
    Thanks given
    509
    Thanks received
    445
    Rep Power
    209
    Code:
    			for(int i = 0; i < 24; i++) {
    				if(c.playerXP[i] >= getLevelForXP(10) && c.playerXP[i] <= getLevelForXP(19)) {
    					c.getItems().addItem(20754);
    					return;
    When using this it only checks if the first skill 0 (Attack) is at level 10, what am i doing wrong that makes it stop there and not check all skills?
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Dec 2016
    Posts
    23
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Seems like the command works fine for me.

    Code:
    for(int i = 0; i < 24; i++) {
    				if(c.playerXP[i] >= getLevelForXP(10) && c.playerXP[i] <= getLevelForXP(19)) {
    					c.getItems().addItem(20754);
    					return;
    Reply With Quote  
     

  3. #3  
    Extreme Donator


    Join Date
    Oct 2010
    Posts
    2,853
    Thanks given
    1,213
    Thanks received
    1,622
    Rep Power
    5000
    Not sure if I understand the purpose of the code, but try changing return; to continue;
    return; will break the loop but continue; will "skip" to next one
    Reply With Quote  
     

  4. #4  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    Code:
    if(c.playerXP[i] >= getLevelForXP(10) && c.playerXP[i] <= getLevelForXP(19)) {
    					c.getItems().addItem(20754);
    					return;
    Code:
    if(this is true) { //if this is right
    c.additem;//then do this
    return;//then end loop
    that's what your code is doing. post the whole thing if you'd like some more clarification

    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  
     

  5. #5  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    Because of:
    Code:
    			for(int i = 0; i < 24; i++) {
    				if(c.playerXP[i] >= getLevelForXP(10) && c.playerXP[i] <= getLevelForXP(19)) {
    					c.getItems().addItem(20754);
    					return;


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  6. #6  
    Registered Member
    _Ali's Avatar
    Join Date
    Apr 2014
    Posts
    382
    Thanks given
    67
    Thanks received
    147
    Rep Power
    252
    Quote Originally Posted by KaiserCo View Post
    Code:
    			for(int i = 0; i < 24; i++) {
    				if(c.playerXP[i] >= getLevelForXP(10) && c.playerXP[i] <= getLevelForXP(19)) {
    					c.getItems().addItem(20754);
    					return;
    When using this it only checks if the first skill 0 (Attack) is at level 10, what am i doing wrong that makes it stop there and not check all skills?
    I don't know what you're trying to do and that makes no sense because you're checking players xp in a given skill against the level in that skill? Xp and Level are 2 diff measures.

    You can do either of the following:

    1) You're checking if a players xp in a given skill meets the xp they are supposed to have for levels between 10 to 19.

    Code:
    			for(int i = 0; i < 24; i++) {
    				if(c.playerXP[i] >= getXPForLevel(10) && c.playerXP[i] <= getXPForLevel(19))
    					c.getItems().addItem(20754);
                             }
    2) Here you're checking if a players level in a given skill is between 9 - 20.

    Code:
    			for(int i = 0; i < 24; i++) {
    				if(c.playerLevel[i] > 9 && c.playerLevel[i] < 20)
    					c.getItems().addItem(20754);
                             }
    Go with the one that meets your need.
    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. [PI]Loop through items
    By Valcombird in forum Help
    Replies: 9
    Last Post: 10-08-2012, 11:07 PM
  2. Looping Through Items
    By .Scott in forum Help
    Replies: 13
    Last Post: 08-17-2011, 05:49 PM
  3. Replies: 0
    Last Post: 04-17-2011, 12:15 AM
  4. RuneSource - Looping through players
    By F0rn in forum Help
    Replies: 5
    Last Post: 12-16-2010, 11:04 PM
  5. Looping through lines in text file
    By Ed in forum Application Development
    Replies: 11
    Last Post: 06-10-2010, 12:39 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
  •