Thread: [PI] Mystery Box - common, uncommon and rare prizes

Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1 [PI] Mystery Box - common, uncommon and rare prizes 
    Banned
    Join Date
    Dec 2012
    Posts
    175
    Thanks given
    35
    Thanks received
    51
    Rep Power
    0
    Hey guys,
    It been a while since iv'e contributed towards anything, so i decided to do this simple snippet. I know this is easy to do and has been done before all i'm doing is making a better one, so please try not to flame.


    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
     * From Rune-server
     */
    
    public class MysteryBox {
    
    	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 OpenMysteryBox(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.");
    			}
    		}
    	}
    	
    }

    Enjoy.
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Donator
    Tanker's Avatar
    Join Date
    Mar 2008
    Posts
    177
    Thanks given
    26
    Thanks received
    7
    Rep Power
    40
    Easy but effective
    Reply With Quote  
     

  4. #3  
    RageXile Owner ;)
    Aim High's Avatar
    Join Date
    Feb 2012
    Posts
    366
    Thanks given
    162
    Thanks received
    28
    Rep Power
    28
    Thanks for this. Good job
    Reply With Quote  
     

  5. #4  
    Banned
    Join Date
    Dec 2012
    Posts
    175
    Thanks given
    35
    Thanks received
    51
    Rep Power
    0
    thanks guys
    Reply With Quote  
     

  6. #5  
    Banned
    Join Date
    Mar 2013
    Posts
    23
    Thanks given
    6
    Thanks received
    0
    Rep Power
    0
    Wewt
    Reply With Quote  
     

  7. #6  
    Community Veteran

    George's Avatar
    Join Date
    Mar 2009
    Posts
    7,059
    Thanks given
    2,100
    Thanks received
    2,939
    Rep Power
    5000
    That has nothing to do with common, uncommon or rare, it just generate a random number and if the number is > or < a certain number you receive the specific amount of coins. Also the event is completely useless.


    Reply With Quote  
     

  8. Thankful users:


  9. #7  
    Contaminated

    Radiated's Avatar
    Join Date
    Mar 2011
    Age
    24
    Posts
    929
    Thanks given
    255
    Thanks received
    163
    Rep Power
    240
    Or you can simply make dis in the clickitem.java

    No need for a whole class for a simple thing..

    Code:
    	if(itemId == 6199) {
    		int Common [] = 
    			{1323, 1313, 1315, 1321, 1109,181,3026,3022,3021,4153,1261,1079,1093,1113,1127,1147,1156,1173,1117,39,589,552,3011617,526,113,6199,1779,1712,1231,6729,3125,8844,8845,1442,1289,1303,555,554,556,560,1023,4317,491,561,54,542440,1623,52,892,373,371,1277,2309,2311,149,157,163,167,3016,5608,2138,2144,5609,5607,}; // Add more item Id's
    
    		int Uncommon [] = 
    			{10828, 4587, 4586, 9185}; // Add more item Id's
    	
    		int Rare [] = 
    			{4151, 6585, 4718, 4720, 4722, 4723}; // Add more item Id's
    
    		int Coins = 50000 + Misc.random(75000); //Change the 75000 to any amount you want (MONEY)
    
    		c.getItems().addItem(995, Coins);			
    		c.getItems().deleteItem(6199, 1);
    
    		int Random = Misc.random(100);
    		if (Random <= 764) {
    			c.getItems().addItem(Common[(int) (Math.random() * Common.length)], 1);
    			c.sendMessage("[<col=990000>*</col>] You have recieved a <col=2784FF>common</col> item and <col=990000>"+ Coins +"</col> coins.");
    			c.sendMessage("[<col=990000>*</col>] Good luck next time!");
    		} else if (Random >= 77 && Random <= 96) {
    			c.getItems().addItem(Uncommon[(int) (Math.random() * Uncommon.length)], 1);
    			c.sendMessage("[<col=990000>*</col>] You have recieved an <col=2784FF>uncommon</col> item and <col=990000>"+ Coins +"</col> coins.");
    		} else if (Random >= 97 && Random <= 100) {
    			c.getItems().addItem(Rare[(int) (Math.random() * Rare.length)], 1);
    			c.sendMessage("[<col=990000>*</col>] You have recieved a <col=990000>rare</col> item and <col=990000>"+ Coins +"</col> coins.");
    			c.sendMessage("[<col=990000>*</col>] Congratulations!");
    		}
    	}
    fuckoff
    Reply With Quote  
     

  10. #8  
    Community Veteran

    George's Avatar
    Join Date
    Mar 2009
    Posts
    7,059
    Thanks given
    2,100
    Thanks received
    2,939
    Rep Power
    5000
    Quote Originally Posted by A7mad View Post
    Or you can simply make dis in the clickitem.java

    No need for a whole class for a simple thing..

    Code:
    	if(itemId == 6199) {
    		int Common [] = 
    			{1323, 1313, 1315, 1321, 1109,181,3026,3022,3021,4153,1261,1079,1093,1113,1127,1147,1156,1173,1117,39,589,552,3011617,526,113,6199,1779,1712,1231,6729,3125,8844,8845,1442,1289,1303,555,554,556,560,1023,4317,491,561,54,542440,1623,52,892,373,371,1277,2309,2311,149,157,163,167,3016,5608,2138,2144,5609,5607,}; // Add more item Id's
    
    		int Uncommon [] = 
    			{10828, 4587, 4586, 9185}; // Add more item Id's
    	
    		int Rare [] = 
    			{4151, 6585, 4718, 4720, 4722, 4723}; // Add more item Id's
    
    		int Coins = 50000 + Misc.random(75000); //Change the 75000 to any amount you want (MONEY)
    
    		c.getItems().addItem(995, Coins);			
    		c.getItems().deleteItem(6199, 1);
    
    		int Random = Misc.random(100);
    		if (Random <= 764) {
    			c.getItems().addItem(Common[(int) (Math.random() * Common.length)], 1);
    			c.sendMessage("[<col=990000>*</col>] You have recieved a <col=2784FF>common</col> item and <col=990000>"+ Coins +"</col> coins.");
    			c.sendMessage("[<col=990000>*</col>] Good luck next time!");
    		} else if (Random >= 77 && Random <= 96) {
    			c.getItems().addItem(Uncommon[(int) (Math.random() * Uncommon.length)], 1);
    			c.sendMessage("[<col=990000>*</col>] You have recieved an <col=2784FF>uncommon</col> item and <col=990000>"+ Coins +"</col> coins.");
    		} else if (Random >= 97 && Random <= 100) {
    			c.getItems().addItem(Rare[(int) (Math.random() * Rare.length)], 1);
    			c.sendMessage("[<col=990000>*</col>] You have recieved a <col=990000>rare</col> item and <col=990000>"+ Coins +"</col> coins.");
    			c.sendMessage("[<col=990000>*</col>] Congratulations!");
    		}
    	}
    Can I fucking hit you?


    Reply With Quote  
     

  11. Thankful user:


  12. #9  
    Contaminated

    Radiated's Avatar
    Join Date
    Mar 2011
    Age
    24
    Posts
    929
    Thanks given
    255
    Thanks received
    163
    Rep Power
    240
    Quote Originally Posted by spongebob View Post
    Can I fucking hit you?
    fuckoff
    Reply With Quote  
     

  13. #10  
    PokeFrontier Java Developer

    Pokemon's Avatar
    Join Date
    May 2011
    Posts
    2,733
    Thanks given
    494
    Thanks received
    801
    Discord
    View profile
    Rep Power
    1242
    Quote Originally Posted by spongebob View Post
    Can I fucking hit you?
    I second that

    [Only registered and activated users can see links. ]



    Pokemon loves his
    Reply With Quote  
     

Page 1 of 2 12 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. [PI] Mystery Boxes
    By Matt0wn3r in forum Snippets
    Replies: 14
    Last Post: 06-15-2014, 10:20 PM
  2. [PI] Mystery boxes WITH TUT
    By Shaloxis in forum Tutorials
    Replies: 26
    Last Post: 05-19-2013, 03:25 PM
  3. PI Mystery boxes (Help please)
    By NoChildSupport in forum Help
    Replies: 20
    Last Post: 08-16-2012, 05:04 PM
  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
Tags for this Thread

View Tag Cloud

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •