1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Broadcast

Discussion in 'Development' started by xXNiceAssassinlo, May 6, 2017.

  1. xXNiceAssassinlo

    xXNiceAssassinlo Spider

    Messages:
    14
    GitHub:
    xXNiceAssassinlo
    Hey there can you help me how to to make Broadcast I'm new sorry.
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    hey there can you help me how to read minds?
     
  3. xXNiceAssassinlo

    xXNiceAssassinlo Spider

    Messages:
    14
    GitHub:
    xXNiceAssassinlo
    What do u mean
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    hey that's suppose to be my line!
    how are you expecting us to know what you even want, please show some examples of what you meant
    i cant read minds
     
    HimbeersaftLP likes this.
  5. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    If you're making a plugin that sends broadcast messages:
    PHP:
    $sender->getServer()->broadcastMessage("Your Message here");
    If you are making a plugin that adds a broadcast command:
    PHP:
    public $plugin_prefix "§7[§a§lBroadcast§r§7]§f ";
    public 
    $error_prefix "§7[§c§lBroadcast§r§7] ";
    public 
    $broadcast_message_prefix "§7[§a§lMyServer§r§7]§f";

    public function 
    onCommand(CommandSender $senderCommand $command, array $args) {
        if(
    $command->getName() === "broadcast") {
            if(isset(
    $args[0]) {
                
    $message implode(" "$args);
                
    $sender->getServer()->broadcastMessage($broadcast_message_prefix $message);
            } else {
                
    $sender->sendMessage($error_prefix "§cYou cannot send an empty message!");
            }
        }
    }
    If you're looking for a plugin that does Broadcast Messages on your Server:
    https://github.com/EvolSoft/Broadcaster
     
    Last edited: May 6, 2017
  6. BouncyJeffer

    BouncyJeffer Spider Jockey

    Messages:
    39
    GitHub:
    bouncyjeffer
    You can do
    PHP:
    foreach($this->getServer()->getOnlinePlayers() as $p){
         
    $p->sendMessage("Whatever you need to say...");
    }
     
  7. SkySeven

    SkySeven Baby Zombie

    Messages:
    145
    GitHub:
    SkySevenMC
    Use $this->getServer()-broadcastMessage($message), is more simple :)
     
  8. BouncyJeffer

    BouncyJeffer Spider Jockey

    Messages:
    39
    GitHub:
    bouncyjeffer
    Yeah, I think it also improves performance.
     
  9. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    fun fact they actually used the same code, just a bit abstracted so developers like us dont need to have the same thing in each of our plugins
     
  10. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    i dont think that's true by code base they still uses the foreaches like what we would do...
    or at least any noticeable improvements
     
    corytortoise likes this.
  11. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Definitely not. There is an extra method call, an also has to check permissions.
    If you want to send message to all players, not just players with the pocketmine.broadcast.user permission, don't use it.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.