1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

how can i make global $sender

Discussion in 'Development' started by Levi, Nov 23, 2017.

  1. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    oh, so this thread is actually about class properties? And not how the title suggests global vars?
     
    Karanpatel567 likes this.
  2. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    back to the title's point.
    all you have todo to make $sender global(class properties) is
    PHP:
    $this->sender $sender;
    if you want you can add
    PHP:
    public $sender;
    right under the class part where you extend PluginBase.

    example because am nice:)
    PHP:
    <?php

    namespace name\space;

    use 
    pocketmine\plugin\PluginBase;

    class 
    YourClass extends PluginBase{

    public 
    $sender# ;P

    public function onEnable(){}

    }

     
  3. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    How many times do I have to say that... Class properties are not global. If something is global, it is always the same wherever you reference it from. In this case, it's only stored in this instance, so if you have another instance e.g. if server is reloaded, it is no longer stored. :facepalm:
     
    Teamblocket and HimbeersaftLP like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.