Daniel0576 12 Posted September 19, 2016 Report Share Posted September 19, 2016 I was wanting to make a new mysterybox system because the one i have is old dated if you have any good ones please share them thanks. Link to comment Share on other sites More sharing options...
Mathy 344 Posted September 19, 2016 Report Share Posted September 19, 2016 (edited) Make a new java file named MysteryBox.java and add all this in it: And put that file in server>Model>Players>Content package server.model.players.Content; import server.model.players.Client; import server.util.Misc; import server.model.players.PlayerHandler; import server.Server; /* Author : Mathy */ public class MysteryBox { public static int mysteryBoxID = 6199;//Just incase I want a different box id. public static boolean deleteBox = true;//Use this for reward testing. //Using arrays for item, and amount. private static int[][] commonRewards = { {4067, 1},// {990, 10},// {1053, 1},// {1055, 1},// {1057, 1},// }; private static int[][] uncommonRewards = { {4067, 1},// {16425, 1},// {14484, 1},// {12236, 1},// {12233, 1},// {12237, 1},// {12235, 1},// {12234, 1},// {12238, 1},// {12239, 1},// {11638, 1},// }; private static int[][] rareRewards = { {20089, 1},// {12230, 1},// {12231, 1},// {12225, 1},// {12227, 1},// {12229, 1},// {12232, 1},// {12228, 1},// {20088, 1},// {20093, 1},// {6199, 1},// }; private static int[][] veryRareRewards = { {990, 10},// {15017, 1},// }; private static int[][] UltraRareRewards = { {962, 1},// }; public static void openBox(Client c){ ///This part was just guesstimated, seeing as common would be used more, it has the highest chance of showing. int randomReward = Misc.random(100);//Picking the random number int itemToGive = 0, amountToGive = 0, rewardRoll; if(randomReward >= 0 && randomReward <= 60){//For all common items.. rewardRoll = Misc.random(commonRewards.length-1); itemToGive = commonRewards[rewardRoll][0]; amountToGive = commonRewards[rewardRoll][1]; }else if(randomReward >= 61 && randomReward <= 80){//Uncommon items. rewardRoll = Misc.random(uncommonRewards.length-1); itemToGive = uncommonRewards[rewardRoll][0]; amountToGive = uncommonRewards[rewardRoll][1]; }else if(randomReward >= 81 && randomReward <= 95){//Rare items rewardRoll = Misc.random(rareRewards.length-1); itemToGive = rareRewards[rewardRoll][0]; amountToGive = rareRewards[rewardRoll][1]; }else if(randomReward >= 96 && randomReward <= 99){//Very Rare items rewardRoll = Misc.random(veryRareRewards.length-1); itemToGive = veryRareRewards[rewardRoll][0]; amountToGive = veryRareRewards[rewardRoll][1]; }else if(randomReward >= 100){//Very Rare items rewardRoll = Misc.random(UltraRareRewards.length-1); itemToGive = UltraRareRewards[rewardRoll][0]; amountToGive = UltraRareRewards[rewardRoll][1]; for (int z = 0; z < Server.playerHandler.players.length; z++) { if (Server.playerHandler.players[z] != null) { Client o = (Client) Server.playerHandler.players[z]; o.sendMessage("<col=29184>["+Misc.optimizeText(c.playerName)+"]</col> <col=800000000>has just received a christmas cracker from mystery box!"); } } } if(deleteBox)//Removing the box c.getItems().deleteItem(mysteryBoxID, 1); c.getItems().addItem(itemToGive, amountToGive);//Adding reward if(itemToGive == 0) c.sendMessage("You open the box to find nothing. What bad luck.");//If you got 0, it says you find nothing. else c.sendMessage("You open the box and find " + (amountToGive > 1 ? "some " : "a ") + c.getItems().getItemName(itemToGive) + ".");//If more than one item, use some, otherwise use a. } } Somewhere in ClickItem.java add this: if (itemId == 6199) { MysteryBox.openBox(c); } If you get any errors, comment them, I should answer in the following minutes OT: I know Dan is using a custom server and the reward are custom items, so just change the rewards to match your items to your liking Edited September 19, 2016 by mathy Read the OT 1 Link to comment Share on other sites More sharing options...
Sanity 436 Posted September 19, 2016 Report Share Posted September 19, 2016 You can easily write your own just by copping old one and take little bits. Link to comment Share on other sites More sharing options...
Mathy 344 Posted September 20, 2016 Report Share Posted September 20, 2016 3 hours ago, MummaPig said: You can easily write your own just by copping old one and take little bits. Yeah basically just take what I just posted and change the rewards Link to comment Share on other sites More sharing options...
scenotaph 1 Posted September 20, 2016 Report Share Posted September 20, 2016 If the old one still works, but you just want to change the rewards, then just change that part? D: Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now