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

Solved Sign Format

Comments in 'Plugin Development' started by Taha_The_Hacker, Sep 19, 2015.

  1. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Hi,

    I am thinking of how to change the Sign's Text? by lines.

    thanks
  2. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Taha_The_Hacker likes this.
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    PHP:
    $signTile->setText("""""""");
    Taha_The_Hacker likes this.
  4. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Oh Thanks now i understand :)
  5. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    But it's Not working :/ this is the function:

    PHP:
    public function onSignCreate(SignChangeEvent $event){
    $player $event->getPlayer();
    $sign $event->getPlayer()->getLevel()->getTile($event->getBlock());
    if(
    $event->getBlock()->getID() == 323 || $event->getBlock()->getID() == 63 || $event->getBlock()->getID() == 68){
    if(
    $sign instanceof Sign){
    $line_0 $event->getLine(0);
    $line_1 $event->getLine(1);
    $lvl $player->getServer()->getLevelByName($line_1);
    if(
    $line_0 =="[SG]"){
    if(empty(
    $line_1) !== true){
    if(!
    $player->getServer()->isLevelGenerated($line_1)){
    $player->sendMessage("Faild, Not found.");
    return 
    false;
    }
    //Level
    if($player->getServer()->isLevelGenerated($line_1)){
    $player->sendMessage("Created!.");
    if(
    $lvl instanceof Level){
    foreach(
    $lvl->getPlayers() as $p){
    $sign->setText("§c[§l§6SG§r§c]"$line_1"[" $lvl->getPlayers() . '/10]'"§l§aTap To Join");
    }
    }
    }
    }
    //empty!
    }//sg
    }//sign
    }//block
    }//Event
    I get no errors in console :( i get the success message but the sign won't change :/
    Please help!
  6. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    WTF 323 is not a block ID. Did you copy code, or did you hear about 323 somewhere?
    Legoboy0215 likes this.
  7. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Idk... But anyway there is an ||
  8. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Anyways learn how to indent your code, it hurts our eyes. *rubs eyes*
    Taha_The_Hacker likes this.
  9. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    But.. What is wrong???
  10. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Lemme tell you what is id 323:
    It is bad practice and I hate it :p
  11. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    @PEMapModder will scream his head off at you for using 323 as a block ID. And use indents.
    * @PEMapModder screams his head off at @Taha_The_Hacker for using 323 as a block ID*
    Legoboy0215 likes this.
  12. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Here:
    PHP:
    use pocketmine\level\Level;
    use 
    pocketmine\event\block\SignChangeEvent;

        public function 
    onSignCreate(SignChangeEvent $event){
            
    $player $event->getPlayer(); //Get the player
            
    $line_0 $event->getLine(0); //The sign's line 1 (Despite the number)
            
    $line_1 $event->getLine(1); //The sign's line 2
            
    if(strtolower($line_0) === "[sg]" && !empty($line_1)){ //Check if the line 1 is equal to [sg] (Since strtolower) and if line 1 is not empty
                
    $level $this->getServer()->getLevelByName($line_1); //Get the level object with the name of $line_1
                
    if(!$this->getServer()->isLevelGenerated($line_1)){ //Check if level is generated
                    
    $player->sendMessage("Failed, Not found."); //LOL
                    
    return false//Return a boolean value of false
                
    }
                
    $player->sendMessage("Created!"); //AGAIN LOL
                
    if($level instanceof Level){ //No need this but I am Bored
                    
    $event->setLine("§c[§l§6SG§r§c]"$line_1"[" count($level->getPlayers()) . "/10]""§l§aTap To Join"); //Set the text. BTW, better use TextFormat::**
                
    }
            }
        }
    Correct me @Gamecrafter... I am not sure.
  13. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    No need to return anything.
  14. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    She/He (Whatever) had it inside, so just leave it :p
  15. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    BTW, if it is a SignChangeEvent why would you need to check if it is a sign or not again? You messed up PlayerInteractEvent and SignChangeEvent.
    PEMapModder likes this.
  16. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Some people just blindly copy code, without understanding what it does. In fact I could give him a script that downloaded viruses and he could've blindly added it to his plugin.
    Last edited: Sep 20, 2015
    Taha_The_Hacker likes this.
  17. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
  18. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Does it work?
  19. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
  20. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Errors?PM me the whole code?

Share This Page

Advertisement