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

Solved <-ProbalySolved Commands MADNESS

Comments in 'Plugin Development' started by Tim // robske Büba, Jan 5, 2016.

  1. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Okay, first of all CODE:
    screenshot.png
    Really do not look at the do not look at this area most stupid code i wrote
    But that's not the problem
    The problem is if I execute any command anywhere it always comes with the last message (That ERR_Irgendj..._CONSOLEissued_TPA)
    I only get that message why?
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Did you register alias for Player?

    Also, sorry for looking, but do NOT use globals in plugins.
  3. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    What alias for an player? (No I didn't register an alias, because I don't even know what it is)
    What should I use then? I use globals in all my plugins and they work fine...
    And the problem is ^PLAYER ISSUED TPA^ isn't even called only ERR_GermanBla_CONSOLEissued_TPA...
  4. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Did you use pocketmine\Player ?
  5. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Yes
    Why do I manage to programm code, wich fails and no one knows why?
  6. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    var_dump something just after case "tpa": and see if it shows
  7. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Yes, there it shows even an ServerBroadcast message but it never says ^PLAYER ISSUED TPA^ but i am executing it ingame! So I've made an mistake there...
    Last edited: Jan 6, 2016
  8. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Try var_dump $sender
  9. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Okay found the issue, typed use /pocketmine/Entity/Player; instead of use pocketmine\Player;
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You want his console spammed for eternity :p
  11. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Yes my console was spammed!
    And i noticed my mistake wrote use pocketmine/Playerr instead of you know
    SOLVED
    But one question @PEMapModder why should i not use globals and what are my alternatives?
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Using globals easily results in conflicts between plugins. Unless you label all variables with the plugin's name, but that is so annoying. Why don't you just use $this->*** properties? This is what everyone uses and the most convenient way that you can ensure it won't collide with other plugins. And $this->*** is also more memory-efficient if you declared the class properties properly. Also, they reset after a /reload, while globals don't. But a plugin should try to work like server restarted when users execute /reload.
  13. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    I tried to use this-> but that never worked for me :(
  14. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Here is an example:
    PHP:
    Class YourClass {
      public 
    $message;

      
    //Public function onJoin(PlayerJoinEvent $event) {
          
    $this->message "Hello, welcome to the server";
          
    $event->getPlayer()->sendMessage($this->message);
        }
    }
    Or you can define it by doing:
    PHP:
    public $message "Hello, welcome to the server";
    You can also declare the variable as public, private or protected. Learn about that here:
    http://php.net/manual/en/language.oop5.visibility.php
    Primus and HotFireyDeath like this.
  15. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Will try that
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder

Share This Page

Advertisement