Thread: Making a message broadcast to surrounding players as a public message?

Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1 Making a message broadcast to surrounding players as a public message? 
    Registered Member
    Join Date
    Feb 2017
    Posts
    83
    Thanks given
    5
    Thanks received
    3
    Rep Power
    11
    Before, my rollDice would just show in the chat box on ONLY the client of whoever rolled the dice, however you can still see the roll above the head (forcetext)
    I want to do something where it broadcasts to surrounding players, in hopes of preventing scams etc.
    This is what I've got so far, and I KNOW "playerss" obviously isn't correct, but I don't know what I'd change it to.

    Code:
    	public static void rollDice(Player c) {
    		if (!c.inGamble()) {
    			c.sendMessage("Please go to @red@::gamble@bla@ to dice.");
    			return;
    		}
    		int rand = Misc.random(100);
    		c.getPA().removeAllWindows();
    		PlayerHandler.sendMessage("I HAVE ROLLED A "+rand+" ON MY DICE!", playerss);
    	}
    Reply With Quote  
     

  2. #2  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    Be more specific about I want to do something where it broadcasts to surrounding players
    Cause is it all players in an area or just who is in a clan chat? If in an area how big should that area be?
    Once you have that, need to write a code from your players position and whoever is in this specific area will have a message pop up for them.


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Feb 2017
    Posts
    83
    Thanks given
    5
    Thanks received
    3
    Rep Power
    11
    Quote Originally Posted by arch337 View Post
    Be more specific about I want to do something where it broadcasts to surrounding players
    Cause is it all players in an area or just who is in a clan chat? If in an area how big should that area be?
    Once you have that, need to write a code from your players position and whoever is in this specific area will have a message pop up for them.
    How can I be more specific lol
    here's the coords :
    Code:
    	private static final Boundary BOUNDS = new Boundary(2583, 3169, 2606, 3153);
    Code:
    if (!c.inGamble()) {
    edit:
    however, if you do know how to do this for clan chat, that would be preferred.
    Reply With Quote  
     

  4. #4  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    Quote Originally Posted by zayuhh View Post
    How can I be more specific lol
    here's the coords :
    Code:
    	private static final Boundary BOUNDS = new Boundary(2583, 3169, 2606, 3153);
    Code:
    if (!c.inGamble()) {
    edit:
    however, if you do know how to do this for clan chat, that would be preferred.
    Find your clanchat pm send packet and have it send the text.
    About the area, you will need to grab all players in that specific "bound" and have it send a message to them.


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  5. #5  
    Donator

    Join Date
    Feb 2017
    Posts
    24
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Instead of Clanchat, why not just do it by Playerupdating? Playerannounce, if that is something your source supports?

    Like you want a global message, with the dice roll?
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Feb 2017
    Posts
    83
    Thanks given
    5
    Thanks received
    3
    Rep Power
    11
    Quote Originally Posted by xyz. View Post
    Instead of Clanchat, why not just do it by Playerupdating? Playerannounce, if that is something your source supports?

    Like you want a global message, with the dice roll?
    I don't want GLOBAL, as global would announce to EVERYONE. I just wanted it to be like the player was talking, forcechat/forcetext doesn't do that.
    Reply With Quote  
     

  7. #7  
    Theory Wins?
    Greyfield's Avatar
    Join Date
    Nov 2008
    Age
    32
    Posts
    1,585
    Thanks given
    61
    Thanks received
    265
    Rep Power
    310
    Quote Originally Posted by zayuhh View Post
    I don't want GLOBAL, as global would announce to EVERYONE. I just wanted it to be like the player was talking, forcechat/forcetext doesn't do that.
    Code:
    Stream.of(playerCollection).filter(p -> boundary.isWithinBounds(p)).forEach(p -> p.sendMessage(rollMessage));
    That's what you want to do.



    Reply With Quote  
     

  8. Thankful user:


  9. #8  
    Registered Member OP411's Avatar
    Join Date
    May 2014
    Posts
    293
    Thanks given
    28
    Thanks received
    31
    Rep Power
    0
    Quote Originally Posted by Greyfield View Post
    Code:
    Stream.of(playerCollection).filter(p -> boundary.isWithinBounds(p)).forEach(p -> p.sendMessage(rollMessage));
    That's what you want to do.
    What the hell is that

    PlayerHandler.sendMessage("I HAVE ROLLED A "+rand+" ON MY DICE!", playerss);

    ^ is force text which makes the player talk but is not properly implemented

    you need to send c.sendMessage(c.getUserName() + " has rolled a " + rand);

    somewhere it collects all the players ie. world class so you would do

    for (Player c : World.getPlayers()) {
    if (c.inGamble())
    c.sendMessage("");
    }

    or you could cache every player that joins the dice area
    Reply With Quote  
     

  10. #9  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    Quote Originally Posted by OP411 View Post
    What the hell is that

    PlayerHandler.sendMessage("I HAVE ROLLED A "+rand+" ON MY DICE!", playerss);

    ^ is force text which makes the player talk but is not properly implemented

    you need to send c.sendMessage(c.getUserName() + " has rolled a " + rand);

    somewhere it collects all the players ie. world class so you would do

    for (Player c : World.getPlayers()) {
    if (c.inGamble())
    c.sendMessage("");
    }

    or you could cache every player that joins the dice area
    That is a much neater way of doing what you just did with this:
    Code:
    for (Player c : World.getPlayers()) {
    if (c.inGamble())
    c.sendMessage("");
    }
    Questions like those are the reason why you have a red bar directly above your avatar.
    Attached image
    Reply With Quote  
     

  11. Thankful user:


  12. #10  
    Blurite

    Corey's Avatar
    Join Date
    Feb 2012
    Age
    26
    Posts
    1,491
    Thanks given
    1,245
    Thanks received
    1,729
    Rep Power
    5000
    Quote Originally Posted by OP411 View Post
    somewhere it collects all the players ie. world class so you would do
    Quote Originally Posted by Greyfield View Post
    Code:
    boundary.isWithinBounds(p)
    ???

    nice red bar btw
    Attached image
    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. Replies: 7
    Last Post: 07-28-2010, 11:47 AM
  2. [508 How To Make Your Self Inv To Players 508]
    By Timo123 in forum Tutorials
    Replies: 1
    Last Post: 07-06-2010, 08:29 PM
  3. Replies: 5
    Last Post: 04-02-2010, 02:23 AM
  4. Replies: 3
    Last Post: 10-30-2009, 10:40 PM
  5. Replies: 9
    Last Post: 07-21-2009, 01:42 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
  •