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

Sign Text

Comments in 'Plugin Development' started by imJayL, Mar 4, 2016.

  1. imJayL
    Offline

    imJayL Active Member

    Joined:
    Aug 5, 2015
    Posts:
    52
    Minecraft User:
    PHC_imJayL
    I need help Guys
    I want to make Signportal with player counter .



    public function playerBlockTouch(PlayerInteractEvent $event){
    if($event->getBlock()->getID() == 323 || $event->getBlock()->getID() == 63 || $event->getBlock()->getID() == 68){
    $sign = $event->getPlayer()->getLevel()->getTile($event->getBlock());

    if(!($sign instanceof Sign)){
    return;
    }
    $s = $sign->getText();
    if($s[0] == "[GAME]"){
    $s2 = $s[2];
    if($this->getOwner()->getServer()->isLevelLoaded($s2) == true){
    $ol = count($this->getOwner()->getServer()->getLevelByName($t2)->getPlayers());
    $tile->setText($s[0], "World:" , $s[2], "Players:" . $ol);

    $event->getPlayer()->sendMessage("[ADMIN] Preparing world '".$mapname."'");
    //Prevents most crashes
    if(Server::getInstance()->loadLevel($mapname) != false){
    $event->getPlayer()->teleport(Server::getInstance()->getLevelByName($mapname)->getSafeSpawn());
    }else{
    $event->getPlayer()->sendMessage("[ADMIN] World '".$mapname."' not found.");
    }
    }
    }
    }
    }
  2. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Well, first use PHP tags, we can't read your code properly...
    Code:
    [PHP] CODE [/PHP]
    
    Then If you want add a player counter, you should create a repeating task for update every x (I suggest, 20) ticks how many players are inside the map.
    PocketKiller and Vaivez66 like this.
  3. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    PHP:
     public function playerBlockTouch(PlayerInteractEvent $event){
    if(
    $event->getBlock()->getID() == 323 || $event->getBlock()->getID() == 63 || $event->getBlock()->getID() == 68){
    $sign $event->getPlayer()->getLevel()->getTile($event->getBlock());

    if(!(
    $sign instanceof Sign)){
    return;
    }
    $s $sign->getText();
    if(
    $s[0] == "[GAME]"){
    $s2 $s[2];
    if(
    $this->getOwner()->getServer()->isLevelLoaded($s2) == true){
    $ol count($this->getOwner()->getServer()->getLevelByName($t2)->getPlayers());
    $tile->setText($s[0], "World:" $s[2], "Players:" $ol);

    $event->getPlayer()->sendMessage("[ADMIN] Preparing world '".$mapname."'");
    //Prevents most crashes
    if(Server::getInstance()->loadLevel($mapname) != false){
    $event->getPlayer()->teleport(Server::getInstance()->getLevelByName($mapname)->getSafeSpawn());
    }else{
    $event->getPlayer()->sendMessage("[ADMIN] World '".$mapname."' not found.");
    }
    }
    }
    }
    }

  4. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    What's the point of a counter that never get updated? (Only when a player click the sign)
    Like I said before your post, he should use a task.
  5. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    second, use [PLAIN][/PLAIN] for the BBCode and smiles to not show up.
    Create a task that will update it everytime.
    use the search bar for signs.

Share This Page

Advertisement