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

Code help appriciated

Comments in 'Plugin Development' started by Mineblast, Nov 21, 2014.

  1. Mineblast
    Offline

    Mineblast

    Joined:
    May 25, 2014
    Posts:
    18
    Hey, I need help with leonchang99's plugin. Before I have been using the simple @player to display the players name. Apperently that feature is gone so I need to display it with a tiny bit of code. I have tried so many times, with diffrent combinations from other plugins and from help on the forums but cannot simply get it to work. Not more than Player(1), Player(2)...

    What would need to be coded for this too work?

    This is what I would like to do:

    if(Server::getInstance()->loadLevel($mapname) != false){
    $event->getPlayer()->sendMessage("[Mineblast] Teleporting $player To $mapname");


    Thanks.
  2. Sergey_D
    Offline

    Sergey_D Active Member

    Joined:
    Jan 19, 2014
    Posts:
    75
    Minecraft User:
    CLILLZ
    You want check level exists?
    P.S. Bad English.
  3. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,434
    Plugins:
    14
    Add this line first.
    PHP:
    $player $event->getPlayer()->getName();
    Mineblast likes this.
  4. Mineblast
    Offline

    Mineblast

    Joined:
    May 25, 2014
    Posts:
    18
    Thank you!
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use $this->getServer() or pass the server instance around instead of using Server::getInstance()!
    LDX likes this.
  6. 64FF00
    Offline

    64FF00 Active Member Plugin Developer

    Joined:
    May 11, 2014
    Posts:
    298
    Plugins:
    2
    Minecraft User:
    64FF00
    ?

    PHP:
    $player $event->getPlayer();

    if(
    $this->getServer()->isLevelLoaded($levelName))
    {
        
    $player->sendMessage("[Mineblast] Teleporting " $player->getName() . " to $levelName");

        
    // ...
    }
    Last edited by a moderator: Nov 22, 2014
  7. Mineblast
    Offline

    Mineblast

    Joined:
    May 25, 2014
    Posts:
    18
    $player = $event->getPlayer()->getName(); was just fine. Tried the code above in combination with another line which made the server crash. Turned out only 1 was needed. Thanks anyways

Share This Page

Advertisement