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

Solved Stopping effect from ticking

Comments in 'Plugin Development' started by MCPEPIG, Nov 3, 2016.

  1. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    I want effects to stop ticking when I want them to. For example, I want it so effects on unlogged players freeze until they login.
    EdwardAllington likes this.
  2. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    I think it already does that and believe it can't run a timer of a effect on a offline player.
  3. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    try this
    onprelogin
    save all effects into tmp cache
    on login
    apply all effects from tmp cache and destroy the cache

    on logout (and havent logged in)
    apply effects from cache and destroy chace
    as recommended by primus
    Last edited: Nov 3, 2016
    Primus likes this.
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Also don't forget to give the effects back if player disconnects without logging in. For example - if someone, not you, joins with your name and logouts because doesn't know password, all effects will be lost.
    Thunder33345 likes this.
  5. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Is there a way to keep the effects on?
  6. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    more detail?
  7. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    I want the time to stop but with the effects still on.
  8. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    If effects timer don't stop do it like this maybe:
    PHP:
    private $temp = [];

    public function 
    quit(\pocketmine\event\player\PlayerQuitEvent $e){
       
    $this->temp[strtolower ($e->getPlayer()->getName())] = $player->getEffects();
    }

    public function 
    login(\pocketmine\event\player\PlayerPreLoginEvent $e){
    //Clear effect, don't know the function 
    if(!empty($this->temp[strtolower($e->getPlayer ()->getName())]){
    foreach(
    $this->temp[strtolower($e->getPlayer ()->getName())] as $effect){
    $player->addEffect($effect);
    }
    }
    }
    Note: I don't know the effect functions, I never have messed with effects.
    HimbeersaftLP likes this.

Share This Page

Advertisement