Thread: 317 PI Mystery Box (ADVANCED)

Page 1 of 4 123 ... LastLast
Results 1 to 10 of 37
  1. #1 317 PI Mystery Box (ADVANCED) 
    Banned
    Join Date
    Nov 2013
    Age
    25
    Posts
    433
    Thanks given
    465
    Thanks received
    69
    Rep Power
    0
    Hello, just wanted to repost this with more in detail.
    If you're going to b*tch and have unnecessary comments then don't comment.

    'THANK' the thread though!

    -------------------------------------------------
    Purpose: Adding Mystery Box
    Difficulty: 1/10
    Assumed Knowledge: Ability to read and know how to copy + paste.
    Server Base: PI
    Classes Modified: ClickItem.java
    -------------------------------------------------

    R-S Admin Response  Mystery Box
    Make a new method called AdvancedMysteryBox.java
    Code:
    package server.model.players;
    
    import server.model.players.Client;
    import server.event.EventManager;
    import server.event.Event;
    import server.event.EventContainer;
    import server.util.Misc;
    
    /*
     * Author - Ferocious & Mod Loc ([email protected])
     * http://www.rune-server.ee/members/ags 
     * http://www.rune-server.ee/members/Ferocious
     */
    
    public class AdvancedMysteryBox {
    
    	public static boolean Canusebox = true;
    	
    	public static int Common [] = 
    	{1323, 1313, 1315, 1321, 1109}; // Add more item Id's
    	
    	public static int Uncommon [] = 
    	{10828, 4587, 4586, 9185}; // Add more item Id's
    	
    	public static int Rare [] = 
    	{4151, 14484, 11700, 11694, 11696, 11698}; // Add more item Id's
    
    	public static int GenerateMyrsteryPrize(final Client c) {
    		 EventManager.getSingleton().addEvent(new Event() {
    			int BoxTimer = 2;
    			int Coins = 50000 + Misc.random(25000);
    			public void execute(EventContainer Box) {
    				Canusebox = false;
    				if (BoxTimer == 2) {
    					c.sendMessage("Calculating prize...");
    				}
    				if (BoxTimer == 0) {
    					c.getItems().addItem(995, Coins);
    					int Random = Misc.random(100);
    					if (Random <= 64) {
    						c.getItems().addItem(Common[(int) (Math.random() * Common.length)], 1);
    						c.sendMessage("You have recieved a @[email protected] @[email protected] and @[email protected]"+ Coins +" @[email protected]");
    					} else if (Random >= 65 && Random <= 89) {
    						c.getItems().addItem(Uncommon[(int) (Math.random() * Uncommon.length)], 1);
    						c.sendMessage("You have recieved an @[email protected] @[email protected] and @[email protected]"+ Coins +" @[email protected]");
    					} else if (Random >= 90 && Random <= 100) {
    						c.getItems().addItem(Rare[(int) (Math.random() * Rare.length)], 1);
    						c.sendMessage("You have recieved a @[email protected] @[email protected] and @[email protected]"+ Coins +" @[email protected]");
    					}
    				}
    				if (c == null || BoxTimer <= 0) {
    				   	Box.stop();
    					Canusebox = true;
                        return; 
    				}
    				if (BoxTimer >= 0) {
    					BoxTimer--;
    				}
    			}
    		}, 1000);
    		return Common[(int) (Math.random() * Common.length)];
    	}
    	
    	public static void Open(int itemID, Client c) {
    		if (itemID == 6199) {
    			if (c.getItems().freeSlots() > 1) {
    				if (Canusebox == true) {
    					c.getItems().deleteItem(6199, 1);
    					GenerateMyrsteryPrize(c);
    				} else {
    					c.sendMessage("Please wait while your current process is finished.");
    				}
    			} else {
    				c.sendMessage("You need atleast 2 slots to open the Mystery box.");
    			}
    		}
    	}
    	
    }
    ^ Place that code in src/server/model/players.

    Then in ClickItem.java look for:
    Code:
    if (itemId != c.playerItems[itemSlot] - 1) {
    			return;
    		}
    Then below that paste this code:
    Code:
    if (itemId == 6199)
                    	if (c.getItems().playerHasItem(6199)) {
                    	AdvancedMysteryBox.Open(itemId, c);
                    	return;
    }
    Then lastly, post this import at the top of ClickItem.java
    Code:
    import server.model.players.AdvancedMysteryBox;
    Compile & Run!


    If you get any errors during this progress (doubt it) then just PM me via rune-server.
    Enjoy!

    Credits:
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  2. Thankful users:


  3. #2  
    Registered Member
    Join Date
    Nov 2013
    Posts
    6
    Thanks given
    0
    Thanks received
    3
    Rep Power
    0
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  4. Thankful users:


  5. #3  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    25
    Posts
    4,432
    Thanks given
    892
    Thanks received
    1,525
    Rep Power
    3228
    Thanks for the contribution. Might use it for something.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  6. Thankful user:


  7. #4  
    Banned
    Join Date
    Nov 2013
    Age
    25
    Posts
    433
    Thanks given
    465
    Thanks received
    69
    Rep Power
    0
    Quote Originally Posted by Lazy View Post
    [Only registered and activated users can see links. ]
    Quote Originally Posted by Ags View Post
    If you're going to b*tch and have unnecessary comments then don't comment.
    ^ ^ ^ ^
    Reply With Quote  
     

  8. #5  
    Banned

    Join Date
    Nov 2010
    Age
    11
    Posts
    2,645
    Thanks given
    158
    Thanks received
    280
    Rep Power
    0
    been released numerous times.
    Reply With Quote  
     

  9. Thankful user:


  10. #6  
    Registered Member
    Join Date
    Nov 2013
    Posts
    6
    Thanks given
    0
    Thanks received
    3
    Rep Power
    0
    Quote Originally Posted by Ags View Post
    ^ ^ ^ ^
    I wasn't griping about anything? I simply posted that so you can work on your conventions as they are disgusting. Meant no harm from it.
    Reply With Quote  
     

  11. #7  
    Super Donator

    Batukka's Avatar
    Join Date
    Oct 2011
    Posts
    2,437
    Thanks given
    86
    Thanks received
    342
    Rep Power
    496
    You should put another event inside of event, instead of doing timering...

    as example for my teleporting:

    Code:
    public void requestTeleport(final int x,final int y){
    		if(player.isDead || player.isTeleporting)
    			return;
    		player.isTeleporting = true;
                    //teleporting gfx..
    		CycleEventHandler.getSingleton().addEvent(3, player, new CycleEvent(){
    			@Override
    			public void execute() {
    				movePlayerTo(x,y);
    				CycleEventHandler.getSingleton().addEvent(2, player, new CycleEvent(){
    					@Override
    					public void execute() {
    						player.isTeleporting = false;
                                                    //end teleport gfx..
    						this.stop();
    					}
    				});
    				this.stop();
    			}
    		});
    }
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  12. Thankful user:


  13. #8  
    Owner of Zanarite
    Ep1k's Avatar
    Join Date
    May 2012
    Posts
    419
    Thanks given
    107
    Thanks received
    62
    Rep Power
    12
    if (itemId == 6199)
    if (c.getItems().playerHasItem(6199)) {
    AdvancedMysteryBox.Open(itemId, c);
    return;
    you need to have a } under return mate. But thanks, some might use.
    EDIT: had to test this and it nulls the server.
    Reply With Quote  
     

  14. #9  
    Banned

    Join Date
    Dec 2011
    Posts
    967
    Thanks given
    234
    Thanks received
    208
    Rep Power
    0
    Why would you make a public class for a mystery box >.>

    Anyways, the conventions seem off b/c of rune-server's text wrapping (shouldn't use [admin][/admin])

    Good job, it's been released numerous times & can be improve. Thanks for contributing ^.^
    Reply With Quote  
     

  15. #10  
    Registered Member Sirius_'s Avatar
    Join Date
    Nov 2013
    Age
    23
    Posts
    271
    Thanks given
    77
    Thanks received
    53
    Rep Power
    11
    Thanks for the contribution however I disagree that it requires a whole class by itself.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

Page 1 of 4 123 ... LastLast

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. 317 pi barrows box set
    By pkingbandit in forum Tutorials
    Replies: 4
    Last Post: 01-14-2015, 11:12 PM
  2. [PI] Mystery Boxes
    By Matt0wn3r in forum Snippets
    Replies: 14
    Last Post: 06-15-2014, 10:20 PM
  3. Replies: 18
    Last Post: 08-17-2013, 01:18 AM
  4. PI mystery boxes
    By NoChildSupport in forum Help
    Replies: 4
    Last Post: 08-12-2012, 05:47 PM
  5. [PI] - Mystery Box: Giving random rewards
    By Sonic chao in forum Snippets
    Replies: 23
    Last Post: 05-23-2012, 01:27 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
  •