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

How to get a thing from a task?

Comments in 'Plugin Development' started by Legoboy0215, Aug 6, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    We all know that on a task, you can use $this->getOwner()->happyguyname to get $this->happyguyname, but how would I get a value I set in the task return to the owner file? I have a $this->mostplayers in my Task.php, but I wanna get that in my Main.php. Thanks!
  2. KnownUnown
    Offline

    KnownUnown Active Member Plugin Developer

    Joined:
    Aug 22, 2013
    Posts:
    65
    Plugins:
    1
    Minecraft User:
    KnownUnown
    You should make a function in your main class and call that function from the task on completion.

    edit: or alternatively, make a public global variable in the main class and set that with the task value from your task.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Global variable? Probably doesn't really work well from /reload.

    P.S. I thought you're never on PocketMine Forums.
  4. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    How would I solve it? My string changes every time a task runs so IDK how to return the data to the Main.php. Also, @KnownUnown is a inactive member for a long time. Hi!
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What's the question? Since you know how to get, you should know how to set.
  6. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    I have $this->players on a task. I want that value in my main.

Share This Page

Advertisement