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

[Solved] Messages sending multiple times

Discussion in 'Development' started by Redux, Jan 23, 2017.

  1. Redux

    Redux Spider Jockey

    Messages:
    49
    GitHub:
    reduxredstone
    I've noticed while testing out a few things that messages to players seem to be sent multiple times. Aspecific example being this:
    Code:
    $list = '§a==========§6§lCitizens§r§a==========§r';
    foreach ($this->plugin->npcs as $npc) {
        $name = $npc["name"];
        $id = $npc["npc_id"];
        $x = $npc["pos"]["x"];
        $y = $npc["pos"]["y"];
        $z = $npc["pos"]["z"];
        $list .= "\n§b".$name."§r§b ID: §9".$id."§r§b Pos: §a".$x.", ".$y.", ".$z."";
    }
    $list .= "\n§a============================§r";
    $sender->sendMessage($list);
    
    This code sends the message every time the loop executes, which is not what I wanted or expected. I expected it to simply build the string and then send it once.
    [​IMG]
    Has anyone else encountered this problem? A friend of mine who plays MCPE regularly says he has encountered this same issue in single-player as well, But I have seen other servers and plugins that manage to only send the message once. This issue is also persistent in my HelperAI plugin (found here https://github.com/ReduxRedstone/MCPE-HelperAI/). So I'm clearly missing something here, what is it?
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    tempted to rule it out as a bug
     
  3. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    As far as I know, this is an MCPE client issue. There are some hacks that some spoons may be using, but I imagine it is pretty messy and will be obsolete once Mojang fixes it.

    Edit: Did some research, a PR was recently made in PMMP to fix this. See here.
     
    Last edited: Jan 23, 2017
  4. Redux

    Redux Spider Jockey

    Messages:
    49
    GitHub:
    reduxredstone
    Much appreciated! Thank you for showing me this.
     
    corytortoise likes this.
  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.