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

Solved Create Two Php files in a plugin

Comments in 'Plugin Development' started by amiremad, Nov 2, 2015.

  1. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    example main.php and test.php

    and i want pocketmine to read them both

    in one plugin
    Martin77Epic likes this.
  2. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    public function onEnable(){
    $this->getServer()->getPluginManager()->registerEvents($this, $this);
    $this->getServer()->getPluginManager()->registerEvents(new test($this), $this);
    }
    Martin77Epic and amiremad like this.
  3. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    thx very much i will try it
    Martin77Epic likes this.
  4. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    do i need to register an event
  5. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    plugin is
    crashing
  6. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    use pocketmine\event\Listener;
    Martin77Epic and amiremad like this.
  7. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    class Main extends PluginBase implements Listener {
    Martin77Epic and amiremad like this.
  8. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    thx alot here is some likes for you
  9. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    It is not called "files", it is called "classes". Learn OOP.
  10. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    x)
    Martin77Epic likes this.
  11. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    I am a new Plugin Devloper
  12. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    please stay cool x)
    Martin77Epic and amiremad like this.
  13. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Obviously you don't know enough PHP to even be a Newbie developer.
    BTW, you r test.php, does it listen to events, or do other things?
    Use a new class: new Test();

    Theee are a lot of tutorials about PHP OOP. Google it ;)
    applqpak and hoyinm14mc like this.
  14. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    already you will learn php :)
    amiremad and Martin77Epic like this.
  15. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    saw your github you do not know coding :D
  16. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    699
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    there's something there for not staying cool
  17. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    501
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    Lol :D
  18. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    You are the first one EVER to say I don't know PHP... BTW, can you see my Private Repo XD

    2015-11-03_201944.png
  19. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    501
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    In the main class, create a function to access to test.php (Inside test.php create a class called Test)
    PHP:
    public function getTestFile(){
        return new 
    path\Test($this$other_arguments=null);
    }
    In test.php,
    PHP:
    class Test{
      private 
    $plugin;

      public function 
    __construct($plugin){
        
    $this->plugin $plugin;
      }
     
    }
    Martin77Epic likes this.
  20. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    501
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    #LearnPHP :D
    applqpak and Martin77Epic like this.

Share This Page

Advertisement