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

Solved Sign Replace

Comments in 'Plugin Development' started by CaptainKenji17, Feb 17, 2016.

  1. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    I needa code for a sign that when I put {aaa} on it it runs the code...

    THIS IS NOT CORRECT CODE OR WAT THIS IS EXAMPLE FOR U TO UNDERSTAND, IM TELLING THIS TO U PEMAP IF UR READIN THIS

    $loul = sign(getText"{aaa}");

    $loul = the code

    also please add the code from public function :D
  2. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    If u place a sign with the Text {aaa} if runs a command?
  3. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    It runs what code and when? Please explain.
    applqpak likes this.
  4. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    in sign when you enter {aaa} on it it runs the code, so example we got the code getting online players in world

    if you did this to sign

    LINE1: Hub
    LINE2: <players on>
    LINE3: {aaa}
    LINE4: null

    and when you enter

    LINE1: Hub
    LINE2: <Players on>
    LINE3: 1
    LINE4: null
  5. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    You've made a million(exaggeration(or not?)) threads asking for help, maybe you should really spend a good few weeks/months studying proper PHP and proper PocketMine API?
  6. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Use SignChangeEvent::getLine($index)
    CaptainKenji17 likes this.
  7. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    This is how I learn you cant (controll(or ask)) waht should I do because every people has different types
  8. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    PHP:
    public function SignChange(SignChangeEvent $e){
    $l $e->getLines();
            
    $l implode(" "$l);
            
    $server $this->getServer();
            
    $l str_replace("{aaa}"count($server->getOnlinePlayers()), TextFormat::clean($l));
            
    $line 3;//line you want (0=Line 1, 1=Line 2, 2=Line 3, 3=Line 4);
            
    $e->setLine($line$l);
    }
  9. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    thank you! so much! I like a people like you, keep being like that
  10. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    :) Your welcome, but you should still try to learn PHP, it will be so easy to do it yourself, trust me. ;)
    applqpak likes this.
  11. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    Im trying to learn on code academy while wwtching someone

    its hard for me to learn in php.net so atm I use to copy and mix and remember the codes ive seen in my eyes thats why I've been asking alot for different codes because I can use them for different purposes like this one :)
  12. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    still didnt work it doesnt update the sign maybe?
  13. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Example
    PHP:
    public function onSign(SignChangeEvent $event){
        
    $sign $event->getLines(); // getLines() will return an array of lines
        
    if($sign[0] == '[example]'){ // Check if the first line is [example]
            
    $event->setLine(0'Hub'); // Change the first line
            
    $event->setLine(1'test'); // Change the second line
        
    }
    }
    applqpak and CaptainKenji17 like this.
  14. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    maybe use setText instead if setLine on last? idk
  15. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    I never said I could/would/want to control how you learn, everyone has their own learning styles. It was a simple suggestion, and, if you can't take a suggestion, how the heck are you going to develop good plugins?
    Vaivez66 likes this.
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    To truly help people, rather than just posting the code, also post explanation.
    applqpak and Vaivez66 like this.

Share This Page

Advertisement