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

Top Killers in Floating Text

Discussion in 'Development' started by TheTrollArtz, May 25, 2018.

  1. TheTrollArtz

    TheTrollArtz Spider

    Messages:
    13
    GitHub:
    ithetrollidk
    They can help me, since I made a plugin of top 10 best players but if the name is smaller than the other or bigger, it looks crooked at first, and I want it to look right at the beginning and crooked at the end. Do you understand? Screenshot_2018-05-24-15-35-22.png
     
  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    You want it to be aligned? If so, here is the code that can output a string that is aligned by giving the string, line width and alignment
    PHP:
    function align($text$lineWidth$center true) {
      
    $len strlen($text);
      if(
    $center) {
          
    $half floor(($lineWidth $len) / 2);
          return 
    str_repeat(" "$half) . $text str_repeat(" "$half);
        } else {
          return 
    $text str_repeat(" "max(0$lineWidth $len));
        }
    }
    Adjust it to your needs and apply this function to every line.[/php]
     
  3. TheTrollArtz

    TheTrollArtz Spider

    Messages:
    13
    GitHub:
    ithetrollidk
    Ohhh, thanks For help!
     
  4. TheTrollArtz

    TheTrollArtz Spider

    Messages:
    13
    GitHub:
    ithetrollidk
    sorry for my ignorance but that code where it is posted?

    before or after the public function onJoin

    or on the onCommand
     
  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.