Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Chat message length

Comments in 'Plugin Development' started by IronPony, Oct 20, 2013.

  1. IronPony
    Offline

    IronPony Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    93
    Plugins:
    4
    Minecraft User:
    1ron_pon3
    Is there any ability to control the length of message? If players have long prefixes, part of message is out of the screen, so how can I trim the message and put the rest of it on the next line?
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    final $LINE_LENGTH=40;
    $lines=floor(strlength($message)/$LINE_LENGTH)+1;
    $output=array();
    for(
    $i=0;$i<$lines;$i++){
      
    $output[$i]=substr($message,$i*$LINE_LENGTH,$LINE_LENGTH);
    $player->sendchat(implode('\n',$output));
    }
    Is it substr or substring?
    IronPony likes this.
  3. wies
    Offline

    wies Notable Member

    Joined:
    Aug 23, 2013
    Posts:
    392
    substr
    PEMapModder and IronPony like this.
  4. IronPony
    Offline

    IronPony Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    93
    Plugins:
    4
    Minecraft User:
    1ron_pon3
    Thanks, I will try this!
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I hope more servers use this especially lbsg.net servers.
  6. JassperBeastHD
    Offline

    JassperBeastHD Banned

    Joined:
    Aug 27, 2013
    Posts:
    436
    Minecraft User:
    JassperBeastHD
    Where do i put this?
  7. IronPony
    Offline

    IronPony Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    93
    Plugins:
    4
    Minecraft User:
    1ron_pon3
    Hm, it's not working for me.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I know 99% sure it needs debugging.
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    in the src folder where output client messages are sent (finally, ultimate code)
  10. JassperBeastHD
    Offline

    JassperBeastHD Banned

    Joined:
    Aug 27, 2013
    Posts:
    436
    Minecraft User:
    JassperBeastHD
    Where scr/???? Idk where help
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    In /pocketmine/src/api/ChatAPI.php:
    PHP:
        public function send($owner$text$whitelist false$blacklist false){
            
    $message = array(
                
    "player" => $owner,
                
    "message" => $text,
            );
            if(
    $owner !== false){
                if(
    $owner instanceof Player){
                    if(
    $whitelist === false){
                        
    console("[INFO] <".$owner->username."> ".$text);
                    }
                }else{
                    if(
    $whitelist === false){
                        
    console("[INFO] <".$owner."> ".$text);
                    }
                }
            }else{
                if(
    $whitelist === false){
                    
    console("[INFO] $text");
                }
                
    $message["player"] = "";
            }
    ////////--------********This is the place********--------////////
            
    $this->server->handle("server.chat", new Container($message$whitelist$blacklist));
        }
    }
    This is not the ultimate code of chat output, but this is the boundary of my knowledge to pocketmine.
    Add the code there (of course change the variable names.
    CAUTION: YOU MUST KNOW WHAT YOU ARE DOING WHEN ADDING THE CODE BECAUSE THIS IS SRC CODE AND MOREOVER IT IS NOT DEBUGGED. Also this is just purely theory don't tell me what severe consequences it brings. I am not responsible for them.
  12. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    Do u replace it with the code that is already there or not I pasted them together then just that code still both didn't work they just crashed sever
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Change the variable names.

Share This Page

Advertisement