|
Not sure if anyone needed this but was just playing round and saw this didn't work properly for most 718's too so I fixed it
Code:public static void privateRoll(final Player player, final int itemId, int graphic, final int lowest, final int highest) { player.lock(2); player.getPackets().sendGameMessage("Rolling...", true); player.getInventory().deleteItem(itemId, 1); player.setNextAnimation(new Animation(11900)); player.setNextGraphics(new Graphics(graphic)); Random rand = new Random(); int diceN = rand.nextInt(100); System.out.println(diceN); WorldTasksManager.schedule(new WorldTask() { @Override public void run() { player.getInventory().addItem(itemId, 1); for (Player players : World.getPlayers()) { if (players.withinDistance(player, 14)) { players.getPackets().sendGameMessage("" + player.getDisplayName() + "</col> rolled <col=db3535>" + diceN + "</col> on " + diceText(itemId) + " die."); } } } }, 1); }
nice just noticed that
Nice. I would add these few though:
Still, it's a good and clean release.Code:public static void privateRoll(final Player player, final int itemId, int graphic, final int lowest, final int highest) { player.lock(2); player.getPackets().sendGameMessage("Rolling...", true); player.getInventory().deleteItem(itemId, 1); player.setNextAnimation(new Animation(11900)); player.setNextGraphics(new Graphics(graphic)); final int n = Math.abs(highest - lowest); final int diceRoll = Math.min(lowest, highest) + (n == 0 ? 0 : random(n));//copied from Utils.java, but has lowest/higstest instead of fixed value if (System.DEBUG)//Could Spam 30/s so debug mode. Option: Disable and make it save in a file to prevent scamming issues. System.out.println(diceRoll); WorldTasksManager.schedule(new WorldTask() { @Override public void run() { player.getInventory().addItem(itemId, 1); for (Player players : World.getPlayers()) { if (players.withinDistance(player, 14)) { players.getPackets().sendGameMessage("" + player.getDisplayName() + "</col> rolled <col=db3535>" + diceRoll + "</col> on " + diceText(itemId) + " die."); } } } }, 1); }
What the f?....
"Private Roll" and it sends a message to everyone in the world?... mhmm...
1) Isn't it meant to be "private" for you only?
2) If you was going to use it for other players you would use the arraylist in the friendschatmanager not world..
Code:for (Player players : World.getPlayers()) { if (players.withinDistance(player, 14)) { players.getPackets().sendGameMessage("" + player.getDisplayName() + "</col> rolled <col=db3535>" + diceN + "</col> on " + diceText(itemId) + " die.");
Didn't remove the out print lol but use this it's better uses the correct method
Code:public static void privateRoll(final Player player, final int itemId, int graphic, final int lowest, final int highest) { player.lock(2); player.getPackets().sendGameMessage("Rolling...", true); player.getInventory().deleteItem(itemId, 1); player.setNextAnimation(new Animation(11900)); player.setNextGraphics(new Graphics(graphic)); int diceN = getRandom(lowest, highest); System.out.println(diceN); WorldTasksManager.schedule(new WorldTask() { @Override public void run() { player.getInventory().addItem(itemId, 1); player.setNextForceTalk(new ForceTalk("" + player.getDisplayName() + "</col> rolled <col=db3535>" + diceN + "</col> on " + diceText(itemId) + " die.")); for (Player players : World.getPlayers()) { if (players.withinDistance(player, 14)) { players.getPackets().sendGameMessage("" + player.getDisplayName() + "</col> rolled <col=db3535>" + diceN + "</col> on " + diceText(itemId) + " die."); } } } }, 1); }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |