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

Call a function of the API

Comments in 'Plugin Development' started by Guillaume351, Jul 23, 2014.

  1. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    I'm really sorry, I know this is simple but :
    I can't find how to use the function setTime and stopTime of Level.php.
    PHP:
    public function changeTime(Level $setTime){
       


       
       
        
    $this->setTime(6000);
                    
    $this->stopTime();
               
           
       
    }
    I didn't forget to use the Level file at the beginning of the code. It says :
    Thank you and sorry once again !
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The whole code?
    Guillaume351 likes this.
  3. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    Yes sorry
    PHP:
    <?php

    namespace RealTime;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Server;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\level\Level;

    class 
    MainClass extends PluginBase implements Listener{

        public function 
    onLoad(){
            
    $this->getLogger()->info(TextFormat::WHITE "RealTime loaded.");
        }

        public function 
    onEnable(){
           
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->changeTime();                                                                            //    Schedule tell hour instead  after            
            
    $this->getLogger()->info(TextFormat::DARK_GREEN "RealTime enabled.");
       
      
       
       
       
       

           
        }
       
       
        public function 
    onDisable(){
            
    $this->getLogger()->info(TextFormat::DARK_RED "RealTime disabled.");
        }

       
       
       

    public function 
    changeTime(Level $setTime){
       


       
       
        
    $this->setTime(6000);
                    
    $this->stopTime();
               
           
       
    }



    public function 
    tellTime(){

           
        
    $times date('H');
        
    $minutes date('i');
        
    $time $times + ($modify);

            if (
    $time 23){
            
    $time $time 24;
        }
       

    $this->broadcast("[RealTime] It is "$time .":"$minutes ."");
        }
       
       
       












    }
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I just don't understand why everyone wants to add a message "enabled" when there is already an "Enabling Plugin vVersion by Author" message.
    swagboy47 likes this.
  5. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    Il just followed a plugin example available on github. Do you have any idea why it don't work ? Thanks
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You called the function $this->changeTime() when you enable it, but you didn't pass parameters.

    I only have one answer:
    Learn PHP.
    Guillaume351 likes this.
  7. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    You're right, thanks. I finished the code academy tutorial, I think I will do it again.. Thanks anyways
  8. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    I understand if you don't want to answer, but can somebody explain me which parameters do I have to put ? It will help me to undersatnd parameters. Thanks.
    Last edited: Jul 24, 2014
  9. DA_Swagnemite
    Offline

    DA_Swagnemite Notable Member Plugin Developer

    Joined:
    Nov 17, 2013
    Posts:
    388
    Plugins:
    7
    Minecraft User:
    DA_SWAGNEMITE
    Try reading the DOCS a little more. ;)
    Guillaume351 likes this.
  10. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    Am I far from what I want to do ? ^^ I found the function I want I think, but I can't find how to call it, will I find this in the docs ?
  11. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    Thank you !!! I didn't need any parametres in fact, and I understood a very useful thing thanks to you :))
    Comedyman937 likes this.
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You need no parameters. And you have no reason to put the Level $level parameter in the function declaration.
    Guillaume351 likes this.
  13. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    Yes sorry :/

Share This Page

Advertisement