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

Tp all player need help

Comments in 'Plugin Development' started by andre_the_gamer, Jun 8, 2015.

  1. andre_the_gamer
    Offline

    andre_the_gamer Active Member

    Joined:
    Feb 5, 2015
    Posts:
    112
    Minecraft User:
    Andre_The_Gamer
    What i need

    I already cofig the sign when player touch it, they get tp to the world named {TEST}
    I need to set when player join world called test they get teleported to x,y,z
    so new players get a next x.y.z which im going to set
    This is the part of the code below

    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;
                }
                
    $sign $sign->getText();
                if(
    $sign[0]=='[Pecraft]'){
                    if(empty(
    $sign[2]) !== true){
                        
    $mapname $sign[2];
                        
    $event->getPlayer()->sendMessage("[Pecraft] Joining match... '".$mapname."'");
                        
    //Prevents most crashes
                        
    if(Server::getInstance()->loadLevel($mapname) != false){
                            
    $event->getPlayer()->sendMessage("[Pecraft] Joining match...");                    
                            
    $event->getPlayer()->teleport(Server::getInstance()->getLevelByName($mapname)->getSafeSpawn());
                        }else{
                            
    $event->getPlayer()->sendMessage("[Pecraft] Match '".$mapname."' Error");
                        }
                    }
                }
            }
        }
    Last edited by a moderator: Sep 17, 2015
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    And this is what happens when you copy the code without understanding. As said for million times, there is no block ID 323, and it is bad practice to use Server::getInstance(), and Sign::getText() always returns a string[4] array.
  3. andre_the_gamer
    Offline

    andre_the_gamer Active Member

    Joined:
    Feb 5, 2015
    Posts:
    112
    Minecraft User:
    Andre_The_Gamer
    As listed if your not going to help me, just dont
    Telling me that i copy a code dont help at all?

    All i need help with is how to tp all player to a x,z when they join a world called test
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Okay, and I just helped you by pointing out some errors in your code.
    And yes, I am telling you that copying code without understanding will make you unable to control your plugin because having code that you don't understand may make different parts conflict with each other.

    And so, bit by bit we give you code, we are fine with that. But why don't you just simply request for a plugin? Posting all these threads here is basically same with requesting the plugin except that you bundle the plugin yourself and that the process is much slower.
    HostingItAll likes this.
  5. myst02
    Offline

    myst02 Active Member

    Joined:
    Mar 23, 2015
    Posts:
    97
    Minecraft User:
    myst02
    You are right in every point. I'm making HG plugin for free for him, and he spams my inbox every day with messages like "where is the plugin i want it now" or "i give you one more day".
    He should be glad to get help...

    Sorry Andre, but that must've been said.
    PEMapModder likes this.
  6. myst02
    Offline

    myst02 Active Member

    Joined:
    Mar 23, 2015
    Posts:
    97
    Minecraft User:
    myst02
    Btw this code is copy/paste from SignPortal. Look at //prevents most crashes :D
    PEMapModder likes this.
  7. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    BTW, @PEMapModder I suggest you to make athread called "Item ID 323's error."
    I have seen enough of 323.
    PEMapModder likes this.
  8. myst02
    Offline

    myst02 Active Member

    Joined:
    Mar 23, 2015
    Posts:
    97
    Minecraft User:
    myst02
    Me made this error too at beginning ;)
    And andre: You made HG plugin once and deleted plugin source you told me. Why are you coming up with such simple questions then?
    PEMapModder likes this.
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Well it's not really an error... It is just code optimization, negligible at runtime but affects the code's look a lot (professional developers care this a lot because it helps reading what you wrote months ago, or helps other people reading it)
    CrazedMiner likes this.
  10. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    I see... I thought it should be the id 63 & 68.?
    PEMapModder likes this.
  11. CavinMiana
    Offline

    CavinMiana Active Member

    Joined:
    Aug 26, 2015
    Posts:
    101
    Minecraft User:
    CavinMiana
    Just one tip!
    You should add
    PHP:
    $event->getPlayer()->sendMessage(TextFormat::GREEN."// What ever goes here");
    // It does not haft to be that color
  12. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Better add a
    PHP:
    $player $event->getPlayer();
  13. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    $event->getPlayer() instead of a variable like $player is fine :p but using a variable might save a bit of time :)
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    As well as preventing function call overhead, which is particularly notable if you are not using PHP 7.
    CrazedMiner and Legoboy0215 like this.
  15. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    What is alternatice for Sign::getText()?
    Legoboy0215 likes this.
  16. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I didnt either.

Share This Page

Advertisement