Thread: Private Dice 718

Results 1 to 6 of 6
  1. #1 Private Dice 718 
    BoomScape #1
    BoomScape's Avatar
    Join Date
    May 2013
    Posts
    2,422
    Thanks given
    289
    Thanks received
    234
    Rep Power
    48
    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);
    	}
    Attached image
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Donator
    Esper's Avatar
    Join Date
    Jun 2011
    Age
    30
    Posts
    108
    Thanks given
    13
    Thanks received
    6
    Rep Power
    1
    nice just noticed that
    Reply With Quote  
     

  4. #3  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    Nice. I would add these few though:

    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);
    }
    Still, it's a good and clean release.
    Project thread
    Reply With Quote  
     

  5. #4  
    Banned

    Join Date
    Mar 2010
    Posts
    2,218
    Thanks given
    170
    Thanks received
    262
    Rep Power
    0
    Quote Originally Posted by James Lewis View Post
    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);
    	}
    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.");
    Reply With Quote  
     

  6. #5  
    BoomScape #1
    BoomScape's Avatar
    Join Date
    May 2013
    Posts
    2,422
    Thanks given
    289
    Thanks received
    234
    Rep Power
    48
    Quote Originally Posted by clem585 View Post
    Nice. I would add these few though:

    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);
    }
    Still, it's a good and clean release.
    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);
    	}
    Attached image
    Reply With Quote  
     

  7. #6  
    BoomScape #1
    BoomScape's Avatar
    Join Date
    May 2013
    Posts
    2,422
    Thanks given
    289
    Thanks received
    234
    Rep Power
    48
    Quote Originally Posted by Teek View Post
    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.");
    Sends to players within 14 spaces only not the world & private is for people around you im 95% sure could be wrong though
    Attached image
    Reply With Quote  
     


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. Dicing [718]
    By Wolf Scape in forum Help
    Replies: 8
    Last Post: 12-21-2014, 12:33 AM
  2. Dicing [718]
    By Wolf Scape in forum Help
    Replies: 1
    Last Post: 12-19-2014, 06:49 AM
  3. Replies: 12
    Last Post: 02-07-2014, 08:05 PM
  4. Replies: 1
    Last Post: 11-07-2013, 10:09 AM
  5. Replies: 0
    Last Post: 01-22-2012, 07:48 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
  •