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

On sign click and other stuff

Comments in 'Plugin Development' started by AndrewBit, Oct 3, 2015.

  1. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    How I can tp a player to a position when he click a sign?

    Also I want tp players to different position.

    I was thinking in:
    PHP:
    $lplayers count($this->getServer()->getLevelByName("mapname")->getPlayers());
    if (
    $lplayers == "0"){
    $player->teleport(#location
    )}
    elseif (
    $lplayers == "1"){
    $player->teleport(#location
    )
    }
    ...
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Why not look at the code for TapToDo by @Falk?
    Is this the request section? I don't think so.
  3. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    By looking at his code it would seem taptodo wouldnt work if he is trying to teleport a player to different locations based on how many players are in a level
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why "0" and "1"? Use numbers directly!
    AndrewBit likes this.
  5. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Oh lol, it was a small error :oops:
  6. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Is the same code for a block and a sign?
  7. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    onPlayerInteractEvent for any type of clicks by a player
    Taha_The_Hacker likes this.
  8. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    I need specify if it's a sign?
    Like
    PHP:
    public function OnClickSign(onPlayerInteractEvent $event){
    $player $event->getPlayer();
    if(
    $event->getBlock()->getID() == Item::SIGN){
    $player->teleport(#location
    )
    }
    }
  9. AppPhil
    Offline

    AppPhil Active Member

    Joined:
    Oct 3, 2015
    Posts:
    54
    If you want to check if the block is a sign do it like this:
    PHP:
    $block $event->getBlock();
    $blockID $block->getId();
    if(
    $blockID === 323 or $blockID === 63 or $blockID === 68) {
        
    // block is a sign
    } else {
        
    // block is no sign
    }
  10. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    For the last time 323 isn't a block ID, it's an ITEM ID!
    Last edited: Oct 4, 2015
  11. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    :eek:
  12. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    I strongly suggest to compare "instances of Tile Sign" instead of IDs
    PEMapModder and Legoboy0215 like this.
  13. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Can it be used to give players, items, as I am currently thinking of using it as a parkour rewarding system
  14. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Block IDs are: 63 (Standing sign) and 68 (Wall sign)
    Last edited: Oct 8, 2015
    Taha_The_Hacker likes this.
  15. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Do not even use ids.. simply use Block::WallSign and Block::SignPost
    Kvetinac97 likes this.
  16. TonyDroide
    Offline

    TonyDroide Active Member Plugin Developer

    Joined:
    Jun 5, 2015
    Posts:
    122
    Plugins:
    1
    Minecraft User:
    TonyDroidd
    Try this:
    PHP:
    public function onSignTap(PlayerInteractEvent $event)
        {
            if(
    $event->getBlock()->getID() == 63 || $event->getBlock()->getID() == 68) {
                
    $sign $event->getPlayer()->getLevel()->getTile($event->getBlock());
                
    $player $event->getPlayer();
                if(!(
    $sign instanceof Sign)) {
                    return;
                }
                
    $sign $sign->getText();
                if(
    $sign[0] == "[Text-First-Line]") {
    # Execute some
         
    }
    }
    Last edited: Oct 7, 2015
  17. TonyDroide
    Offline

    TonyDroide Active Member Plugin Developer

    Joined:
    Jun 5, 2015
    Posts:
    122
    Plugins:
    1
    Minecraft User:
    TonyDroidd
    Nope, that work correctly, I myself have tried ;)
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Please learn PHP before trying to answer a question incorrectly:
    http://php.net/manual/en/language.operators.comparison.php
  19. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    I've already told him this(in a previous post), you don't have to repeat it. Please stop trying so desperately to increase your post count.
    You're just repeating what @iksaku said in a previous post. Please don't do this(repeating the same post), as this can be considered "spam". ;)
  20. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Didn't saw that he posted it :p
    He already did? Didn't saw that

Share This Page

Advertisement