Thread: [ELVARG] - Standard Pet Mystery Boxes

Results 1 to 4 of 4
  1. #1 [ELVARG] - Standard Pet Mystery Boxes 
    Registered Member

    Join Date
    Aug 2011
    Posts
    766
    Thanks given
    105
    Thanks received
    59
    Rep Power
    114
    I know its not much, but its nice to give back to the community, and there isn't really much released on elvarg for new coders so thought I'd release.




    Firstly go to your client and find

    Code:
    Itemdefinition.java
    Search for

    Code:
     switch (itemId) {
    Add this under.

    Code:
    case 6829:
    			itemDef.name = "Pet Mystery Box";
    			itemDef.stackable = false;
    			itemDef.actions = new String[5];
    			itemDef.actions[0] ="Open";
    			break;
    Then go back to your server files and make a new package called content.

    Code:
    com.elvarg.game.content
    In this package create

    Code:
    PetMbox.java
    Paste this to PetMbox.java

    Code:
    package com.elvarg.game.content;
    
    import java.util.Random;
    import com.elvarg.world.entity.impl.player.Player;
    
    /**
     * 
     * @author Insidia X aka DR AHK
     * Discord: Diddy Ranqe#4105
     *
     */
    public class PetMbox {
    
    /**
     * The item id of the PetMbox is below.
     */
    	public static final int PET_MYSTERY_BOX = 6829;
    	
    /**
     * If the roll is between 0 and 250 it pays out these items. {} - FILL THE BLANKS BELOW
     */
    	
    	public static int[] WORST_PET_PRIZE = new int[] { 272 };
    /**
     * If the roll is between 251 and 399 it pays out these items. {} - FILL THE BLANKS BELOW
     */	
    	
    	public static int [] MED_PET_PRIZE = new int[] { 7582, 7583, 1561, 11995 };
    	
    /**
     *  If the roll is between 401, and 487 it pays out these items. {} - FILL THE BLANKS BELOW
     */
    	
    	public static int [] RARE_PET_PRIZE = new int[] { 13177, 13178 };
    	
    /**
     *  Generates the roll the pay out the prize.
     */
    	public static int generateRandomNumber() {
    			return new Random().nextInt(611 - 0) + 0;
    	}
    	
    /**
     * Gets the random item from the item arrays at the top.
     */
    	
    	public static int getRandomItem(int[] array) {
    		return array[new Random().nextInt(array.length)];
    	}
    /**
     * Opens the box and gives the player a random pet or fish food.
     */
    		public static void openPetMbox(Player player) {
    			int randomNumber = generateRandomNumber();
    			int randomItem = 0;
    
    			player.getInventory().delete(PET_MYSTERY_BOX, 1);
    			player.getPacketSender().sendMessage("You open the box, thank you for donating. Good luck!");
    			if (randomNumber > 0 && randomNumber < 250) {
    				// Select low quality item to give player
    				randomItem = getRandomItem(WORST_PET_PRIZE);
    				player.getPacketSender().sendMessage("@red@You got fish food, unlucky.");
    			}
    			if (randomNumber > 251 && randomNumber < 399) {
    				// Select med quality item to give player
    				randomItem = getRandomItem(MED_PET_PRIZE);
    				player.getPacketSender().sendMessage("@gre@You just got a PET!!!!!");
    			}
    			if (randomNumber > 401 && randomNumber < 487) {
    				// Select high quality item to give player
    				randomItem = getRandomItem(RARE_PET_PRIZE);
    				player.getPacketSender().sendMessage("@blu@You just got a RARE PET!!!!!");
    			}
    
    			player.getInventory().add(randomItem, 1);
    		}
    	}

    Then go into
    Code:
    ItemPacketListener.java
    Add this import in.
    Code:
    import com.elvarg.game.content.PetMbox;
    Search for
    Code:
    public void handleOption(Player player, int option)
    And under
    Code:
    break;
    Add

    Code:
    case PetMbox.PET_MYSTERY_BOX:
    			PetMbox.openPetMbox(player);
    			break;
    Spoiler for vouches:

    Quote Originally Posted by TheMrClassic View Post
    Vouch for Insidia X. Fast and friendly.
    Quote Originally Posted by Vernorexia View Post
    Vouch for insidia x added clipped following and a timer on my gates. I paid first was fast work. I highly recommend using him!
    Quote Originally Posted by Matts B ring View Post
    Bought 5b ikov, vouch
    Quote Originally Posted by InsinuateRS View Post
    Vouch for me lad, bought 3b

    Reply With Quote  
     

  2. #2  
    Member [ELVARG] - Standard Pet Mystery Boxes Market Banned

    NeilG's Avatar
    Join Date
    Jul 2013
    Posts
    413
    Thanks given
    95
    Thanks received
    618
    Rep Power
    1975
    Quote Originally Posted by Insidia X View Post
    Code:
    Itemdefination.java
    Oh dear
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Aug 2011
    Posts
    766
    Thanks given
    105
    Thanks received
    59
    Rep Power
    114
    Quote Originally Posted by NeilG View Post
    Oh dear
    Oops spelt definition wrong
    Spoiler for vouches:

    Quote Originally Posted by TheMrClassic View Post
    Vouch for Insidia X. Fast and friendly.
    Quote Originally Posted by Vernorexia View Post
    Vouch for insidia x added clipped following and a timer on my gates. I paid first was fast work. I highly recommend using him!
    Quote Originally Posted by Matts B ring View Post
    Bought 5b ikov, vouch
    Quote Originally Posted by InsinuateRS View Post
    Vouch for me lad, bought 3b

    Reply With Quote  
     

  4. #4  
    Software Developer

    Tyrant's Avatar
    Join Date
    Jul 2013
    Age
    24
    Posts
    1,562
    Thanks given
    678
    Thanks received
    423
    Rep Power
    1060
    Insidia X is clearly still living in the past.
    Reply With Quote  
     

  5. Thankful users:



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. [Elvarg] Simple Mystery Box
    By Mr Bill in forum Snippets
    Replies: 4
    Last Post: 08-01-2019, 06:12 PM
  2. Replies: 1
    Last Post: 07-17-2019, 09:44 PM
  3. Replies: 0
    Last Post: 10-14-2018, 11:20 PM
  4. Donation Box (Mystery Box)
    By Project in forum Tutorials
    Replies: 24
    Last Post: 04-24-2014, 03:54 AM
  5. [317] Mystery Box [317]
    By pyrotic in forum Tutorials
    Replies: 25
    Last Post: 08-18-2011, 12:24 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
  •