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

Solved Task goes to another player

Discussion in 'Development' started by David Flash, Aug 31, 2020.

  1. David Flash

    David Flash Spider Jockey

    Messages:
    26
    GitHub:
    davidflashcz
    Hey guys I need help pretty bad. So I have been making plugin with scheduled repeating tasks. Everything works, but when another player calls the task it continues on him. How do I make it so it will stick to the player and if another player calls it, a new local one is created.

    Task:
    PHP:
    private $time 21;


      public function 
    __construct(Main $mainObject $entityPlayer $player){ //constructor
             
    $this->main $main;
             
    $this->main->entity $entity;
             
    $this->main->player $player;
           }

           protected 
    $player;
           protected 
    $entity;

             public function 
    onRun(int $currentTick){
             
    $this->time--;
             if(
    $this->time == 20){
               
    $this->main->player->sendTip("§l§6Pulse Bomb > §a||||||||||||||||||||");
               
    $this->main->entity->setNameTag("§l§c4\n§l§6Pulse Bomb");

             }
    Main Class:
    PHP:
    $this->getScheduler()->scheduleRepeatingTask(new PulseBomb($this$entity$player), 20);
     
  2. David Flash

    David Flash Spider Jockey

    Messages:
    26
    GitHub:
    davidflashcz
    Nvm fixed it. Put classes directly to Main Class.
     
  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.