Thread: enum help ples

Results 1 to 4 of 4
  1. #1 enum help ples 
    Server developer


    Join Date
    Jul 2010
    Posts
    881
    Thanks given
    265
    Thanks received
    55
    Rep Power
    94
    Okay, let me explain what I am trying to do.

    I created an enum, but I want to loop the string 'name' for instance.

    Code:
    COOKING(0, 29287, "Achievement Name 1", "Cook 50 fish"),
    COOKING_2(1, 29288, "Achievment Name 2", "Cook 150 fish");
    I tried to use a (array)list or this (below), but didn't really work out..

    Code:
                     /**
    		 * Gets all the names
    		 * @return
    		 */
    		public static String getAllNames() {
    			for (AchievData data : AchievData.values()) {
    				return data.getName();
    			}
    			return "";
    		}
    So how can I make the ouput say;

    Code:
    Achievement Name 1
    Achievement Name 2
    and not just:
    Code:
    Achievement Name 1
    Thanks
    Reply With Quote  
     

  2. #2  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    28
    Posts
    4,421
    Thanks given
    891
    Thanks received
    1,527
    Rep Power
    3285
    Well remember you need to have 2 different line ids set otherwise the second one would just override the first one.

    Edit wait I see your issue now lmao.

    Code:
                     /**
    		 * Gets all the names
    		 * @return
    		 */
    		public static String getAllNames() {
    			for (AchievData data : AchievData.values()) {
    				return data.getName();
    			}
    			return "";
    		}
    Your returning the first name that it comes across. Basically returning the loop right after the first one.

    Something like this would work better;

    Code:
                     /**
    		 * Gets all the names
    		 * @return
    		 */
    		public static void getAllNames() {
    			for (AchievData data : AchievData.values()) {
    				sendString(data.getName(), lineId);
    			}
    		}
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Server developer


    Join Date
    Jul 2010
    Posts
    881
    Thanks given
    265
    Thanks received
    55
    Rep Power
    94
    Quote Originally Posted by Zivik View Post
    Well remember you need to have 2 different line ids set otherwise the second one would just override the first one.

    Edit wait I see your issue now lmao.

    Code:
                     /**
    		 * Gets all the names
    		 * @return
    		 */
    		public static String getAllNames() {
    			for (AchievData data : AchievData.values()) {
    				return data.getName();
    			}
    			return "";
    		}
    Your returning the first name that it comes across. Basically returning the loop right after the first one.

    Something like this would work better;

    Code:
                     /**
    		 * Gets all the names
    		 * @return
    		 */
    		public static void getAllNames() {
    			for (AchievData data : AchievData.values()) {
    				sendString(data.getName(), lineId);
    			}
    		}
    Yeah that's what I also thought, but didn't know how to solve it, thanks! How will the sendString(String a, int b) method look like?
    Reply With Quote  
     

  5. #4  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    Quote Originally Posted by klaasvaakjes View Post
    Yeah that's what I also thought, but didn't know how to solve it, thanks! How will the sendString(String a, int b) method look like?
    Hes probably referring to packet 126 server > client which is also known as sendFrame126 in PI.
    Reply With Quote  
     

  6. Thankful user:



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. [718] Editing Items HELP PLES
    By brykez in forum Help
    Replies: 2
    Last Post: 07-22-2014, 08:48 PM
  2. Trivia bot. enum help
    By ohokay in forum Help
    Replies: 12
    Last Post: 09-29-2013, 12:00 AM
  3. Enum help.
    By Zach55200 in forum Help
    Replies: 5
    Last Post: 10-04-2012, 04:03 PM
  4. Enum help
    By The Watcher in forum Help
    Replies: 1
    Last Post: 09-26-2012, 07:29 AM
  5. Replies: 6
    Last Post: 02-04-2009, 02:01 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •