Thread: Crystal Key Chest

Results 1 to 5 of 5
  1. #1 Crystal Key Chest 
    ☕ABERRANT☕

    Join Date
    Oct 2015
    Posts
    98
    Thanks given
    101
    Thanks received
    17
    Rep Power
    67
    Hello, I need some help. I've been writing a Crystal Key chest system from scratch and ran into an issue. I can't seem to figure out how to randomize the 2 int array, and return the 2 ints in the array as useable. Currently, any attempts to code a work around generally results in the erorr "Can't convert int to int[]". Any help would be greatly appreciated.

    p.s I haven't added the add item code. That's where I get the error. I also haven't changed the item amounts from 1 yet. Some will be 5+ in quantity.

    Code:
    package ardi.content;
    
    import ardi.util.Misc;
    import ardi.model.players.Client;
    
    
    public class Crystalkey {
    	Client c;
    	public static int commonReward[][] = {{10404, 1},{10406, 1},{10408, 1},{10410, 1},{10412, 1},{10414,1},{10416, 1},{10418, 1},
    			{10420, 1},{10422, 1},{10424, 1},{10426, 1},{10428, 1},{10430, 1},{10432, 1},{10434, 1},{10436, 1},{10438, 1},{10394, 1},
    			{626, 1},{628, 1},{630, 1},{632, 1},{634, 1},{2894, 1},{2902, 1},{2904, 1},{2912, 1},{2914, 1},{2922, 1},{2924, 1},{2932, 1},{2942, 1},
    			{7534, 1},{ 6858, 1},{6859, 1},{7053, 1},{10836, 1},{10837, 1},{10838, 1},{10839, 1},{10840, 1},{6654, 1},{6655, 1},{6656, 1}};
    	
    	public static int commonLoot() {
    		return commonReward[(int) (Math.random() * commonReward.length)][(int) (commonReward.length)];
    	}
    	
    	public static int uncommonReward[][] = {{10400, 1},{10402, 1},{2362, 1},{537, 1},{452, 1},{1618, 1},{1632, 1},{5304, 1},{1734, 1},
    			{1733, 1},{384, 1},{7937, 1}};
    	
    	public static int uncommonLoot() {
    		return uncommonReward[(int) (Math.random() * uncommonReward.length)][(int) (uncommonReward.length)];
    	}
    	
    	public static int rareReward[][] = {{4087, 1},{11732, 1},{1187, 1},{6571, 1},{6920, 1},{555, 1},{562, 1},{560, 1},{565, 1},{3145, 1},
    			{392, 1},{3025, 1},{6686, 1},{11230, 1},{2453, 1}};
    	
    	public static int rareLoot() {
    		return rareReward[(int) (Math.random() * rareReward.length)][(int) (rareReward.length)];
    	}
    	
    	public static int superRareReward[][] = {{19412, 1},{19413, 1},{19414, 1},{19420, 1},{19404, 1},{299, 1},{989, 1},{6199, 1},
    			{2707, 1}};
    	
    	public static int superRareLoot() {
    		return superRareReward[(int) (Math.random() * superRareReward.length)][(int) (superRareReward.length)];
    	}
    
    	public static int legendaryReward[][] = {{19415, 1},{19416, 1},{19417, 1},{19409, 1},{19408, 1},{19410, 1},{12756, 1},
    			{6199, 1},{2707, 1}};
    	
    	public static int legendaryLoot() {
    		return legendaryReward[(int) (Math.random() * legendaryReward.length)][(int) (legendaryReward.length)];
    	}
    	
    
    	public static void searchChest(Client c) {
    		if (c.getItems().playerHasItem(989)) {
    			c.getItems().deleteItem(989, 1);
    			c.sendMessage("You open the chest");
    			int pool = Misc.random(180);
    			int superRarePointReward = Misc.random(superRareReward.length);
    			int legendaryPointReward = Misc.random(legendaryReward.length);
    				if (pool == 10 || pool == 20 || pool == 30 || pool == 40 || pool == 50 || pool == 60 || pool == 70 || pool == 80 || pool == 90 || pool == 100) {
    
    				} else if (pool == 25 || pool == 51 || pool == 75 || pool == 101 || pool == 125) {
    
    				} else if (pool == 45 || pool == 91 || pool == 145) {
    					if (superRarePointReward != 1) {
    
    					} else {
    						int superRarePoint = Misc.random(1);
    							if (superRarePoint == 0) {
    								c.bossPoints += 500;
    								c.sendMessage("You have recieved 500x boss points.");
    							} else {
    								c.votePoints += 5;
    								c.sendMessage("You have recieved 5x vote points.");
    							}
    					}
    				} else if (pool == 5) {
    					if (legendaryPointReward != 1) {
    
    					} else {
    						int legendaryPoint = Misc.random(1);
    							if (legendaryPoint == 0) {
    								c.bossPoints += 1000;
    								c.globalMessage("[@red@Crystal Key@bla@] @blu@" + c.playerName + "@bla@ has just recieved @red@1000@bla@ Boss Points." );
    							} else {
    								c.votePoints += 10;
    								c.globalMessage("[@red@Crystal Key@bla@] @blu@" + c.playerName + "@bla@ has just recieved @red@10@bla@ vote points." );
    							}
    					}
    				} else {
    					
    				}
    			} else {
    				c.sendMessage("You need a Crystal key to open the chest.");
    			}
    		}
    }
    Reply With Quote  
     

  2. #2  
    ☕ABERRANT☕

    Join Date
    Oct 2015
    Posts
    98
    Thanks given
    101
    Thanks received
    17
    Rep Power
    67
    I still can't seem to figure this out. Can somebody please help. Bump.
    Reply With Quote  
     

  3. #3  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    Code:
    	public static int commonLoot() {
    		return commonReward[(int) (Math.random() * commonReward.length)][0];
    	}
    Reply With Quote  
     

  4. #4  
    ☕ABERRANT☕

    Join Date
    Oct 2015
    Posts
    98
    Thanks given
    101
    Thanks received
    17
    Rep Power
    67
    Quote Originally Posted by Eldritch View Post
    Code:
    	public static int commonLoot() {
    		return commonReward[(int) (Math.random() * commonReward.length)][0];
    	}
    Still getting the same issue as before. I must be trying to add items in a wrong manor.

    Code:
    					commonLoot();
    					c.getItems().addItem(commonReward[0], commonReward[1]);
    My error is that I can't add items with an int[] type. I must be doing something seriously wrong. My code above is the code I'm trying to use to input the data necessary for adding items.
    Reply With Quote  
     

  5. #5  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    Quote Originally Posted by Tainted View Post
    Still getting the same issue as before. I must be trying to add items in a wrong manor.

    Code:
    					commonLoot();
    					c.getItems().addItem(commonReward[0], commonReward[1]);
    My error is that I can't add items with an int[] type. I must be doing something seriously wrong. My code above is the code I'm trying to use to input the data necessary for adding items.
    That is because the code I gave you returns in AN integer, not in a 2d integer.. You use it as
    c.getItems().addItem(commonLoot(), 1);
    If you want it to return the id as well as the amount in the container, you'll need to write it as
    Code:
    	public static int[] commonLoot() {
    		int chosenOne = (int) (Math.random() * commonReward.length;
    		return new int[commonReward[chosenOne][0], commonReward[chosenOne][1]];
    	}
    Only then will you be able to use your code in the post directly above this one.
    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. crystal key chest code?
    By imurdernubs in forum Help
    Replies: 10
    Last Post: 12-18-2013, 09:35 AM
  2. [PI] Donor Crystal Key Chest 317 [PI]
    By acriley3 in forum Tutorials
    Replies: 5
    Last Post: 07-03-2013, 06:50 PM
  3. 637/639 Crystal Key Chest
    By `Eco in forum Snippets
    Replies: 5
    Last Post: 08-11-2012, 10:04 PM
  4. crystal key chest dementhium
    By GomuGomuFruit in forum Help
    Replies: 10
    Last Post: 04-24-2012, 09:44 PM
  5. crystal key chest system for dementhium 639
    By Zᴀᴄʜ in forum Help
    Replies: 2
    Last Post: 01-24-2012, 01:18 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
  •