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

How To lock sign with time ?

Comments in 'Plugin Development' started by TutoGamerWalid, Jan 13, 2016.

  1. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    hellos , I would know how to lock a sign when the game starts ?
  2. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    What do you mean by "lock"?
  3. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    I mean that when the game starts I wanted the players can not join the game as it has already begun. :(
  4. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    It would be a lot easier to help you if you showed your code.
    wolfdale likes this.
  5. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Something like
    PHP:
    PlayerInteractEvent
    //check that it is the sign you want
    if($this->gameStarted){
    return;
    }
    //code to join game
  6. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    Thank
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Maybe you should first tell us how come the sign is not locked. We can't lock something unless we know there is a door.
    Like, what plugin are you using that makes the sign a portal?
    KubixQ, applqpak and CraftYourBukkit like this.
  8. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    another example as code ?
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    We can't help you. You have to do that yourself. We don't even know how you define that a game has started.
    Vaivez66 likes this.
  10. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    Lol, i sent a post why? For help :)
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yes, and we don't know your situation well enough, so we can't help you.
    For example, we don't even know what you meant by "when the game starts". What game is that? Anything not from default PocketMine and you didn't mention what plugin it is, we have no idea.
    applqpak likes this.
  12. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    What @PEMapModder is trying to say is that we can't help you without seeing your code, or atleast the part that starts games.
    So post the code for further help.
  13. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    Here code sorry . :D
    PHP:
        public function onPlayerTouch(PlayerInteractEvent $event) {
            if(
    $event->getBlock()->getId() == 68 || $event->getBlock()->getId() == 63) {
                
    $sign $event->getPlayer()->getLevel()->getTile($event->getBlock());
                if(
    $sign instanceof Sign) {
                    
    $signtext $sign->getText();
                     if(
    $signtext[0] == "[Game]"){
                        
    $player $event->getPlayer();
                        
    $name $player->getName();
                        
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new Task1($this), 20*60);
                        if(empty(
    $signtext[3]) !== true) {
                            
    $worlds $signtext[3];
                            
    $this->getServer()->loadLevel($worlds);
                             
    $event->getPlayer()->teleport(Server::getInstance()->getLevelByName($worlds)->getSafeSpawn());
                             if ((
    $world $this->getServer()->getLevelByName($worlds))) {
                                
    $count count($world->getPlayers());
                                 
    $player->sendTip(TextFormat::GREEN"§l§[Game] Teleporting .....  !");
                                
    $this->getServer()->broadcastMessage("§l§6[Game]§a $name join game §7[$count/8]");
                                
    $player->setNameTag("§c" .$player->getName());
                                 
    $duration $this->cfg->get("Duration");
                                 
    $particles $this->cfg->get("Particles");
                                 
    $amplifier $this->cfg->get("Amplifier");
                                
    $id $this->cfg->get("Effect-ID");
                                
    $effect Effect::getEffect($id);
                                 
    $effect->setVisible($particles);
                                 
    $effect->setAmplifier($amplifier);
                                 
    $effect->setDuration($duration);
                                
    $player->addEffect($effect);
                                
    $player->getInventory()->clearAll();
                                if(
    $this->gameStarted === true $this->start count($this->players)> 8){
                                    
    $player->sendMessage("§l§4[Game] the game is full !");
                                    
    $player->isOp();
                                    
    $this->refreshSign();
                                    return 
    true;
                                    
    //sign event use
                                 
    }
                             }
                         }
                    }
                }
            }
         }
    Last edited: Jan 13, 2016
  14. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    what do you want if you want refresh sign ?
    on start games ?
  15. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    PHP:
    $event->setCancelled();
    ?
  16. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    For refreshsign =>
    PHP:
        public function refreshSign() {
            foreach(
    $this->getServer()->getLevels() as $levels) {
                
    $tiles $this->getServer()->getLevelByName("test")->getTile(new Vector3(-94730));
                 if(
    $tiles instanceof Sign) {
                    if ((
    $world $this->getServer()->getLevelByName("world"))) {
                        
    $count count($world->getPlayers());
                         
    $tiles->setText("§l§6[Game]""§l§bJoin !""[$count/8]""world");
    //code Full Help And Time For join .
  17. basprohop
    Offline

    basprohop Active Member Plugin Developer

    Joined:
    Aug 8, 2015
    Posts:
    128
    Plugins:
    3
    Minecraft User:
    basprohop
    Just cancel the event on playerinteract event if the sign is a game sign and the gamestate is started...
    TutoGamerWalid likes this.
  18. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Cancelling the event will not exit the event handler in the plugin
  19. basprohop
    Offline

    basprohop Active Member Plugin Developer

    Joined:
    Aug 8, 2015
    Posts:
    128
    Plugins:
    3
    Minecraft User:
    basprohop
    What? I'm saying cancel the player touch event if the player is touches the sign and the sign is a game sign and the game is in the started state.
    TutoGamerWalid likes this.
  20. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You mean in another plugin right?
    1. You need to consider handler priority
    2. The sign tp event handler should have @ignoreCancelled turned on, or it would be impossible (unless you cancel the tp event).

Share This Page

Advertisement