|
|
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
-------------------------------------------------
Mystery Box
Make a new method called AdvancedMysteryBox.java
^ Place that code in src/server/model/players.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."); } } } }
Then in ClickItem.java look for:
Then below that paste this code:Code:if (itemId != c.playerItems[itemSlot] - 1) { return; }
Then lastly, post this import at the top of ClickItem.javaCode:if (itemId == 6199) if (c.getItems().playerHasItem(6199)) { AdvancedMysteryBox.Open(itemId, c); return; }
Compile & Run!Code:import server.model.players.AdvancedMysteryBox;
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. ]

been released numerous times.
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(); } }); }
you need to have a } under return mate. But thanks, some might use.if (itemId == 6199)
if (c.getItems().playerHasItem(6199)) {
AdvancedMysteryBox.Open(itemId, c);
return;
EDIT: had to test this and it nulls the server.

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 ^.^
| « 317 Auto CacheDownloader | how to added a autocache downloader to your server. » |
| Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |