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

Effect Help

Discussion in 'Help' started by SomeServerOwner, May 28, 2021.

  1. SomeServerOwner

    SomeServerOwner Spider Jockey

    Messages:
    40
    Hey, so I'm using a plugin where if you select a class in-game, it will give you that effect perm. In the config, I set up the effects, but for some reason, it doesn't work. It isn't my mistake with setting up the config.


    <?php

    namespace benzo\task;

    use benzo\Loader;
    use pocketmine\{entity\Effect, entity\EffectInstance, scheduler\Task};

    class ClassTask extends Task{

    /** @var Loader */
    private $plugin;

    public function __construct(Loader $plugin){
    $this->plugin = $plugin;
    }

    public function onRun(int $currentTick){
    $data = $this->plugin->getData();
    foreach($this->plugin->getServer()->getOnlinePlayers() as $player){
    if(!$data->exists($player->getName())){
    continue;
    }
    $class_name = $data->get($player->getName())["class"];
    $class_data = $this->plugin->getConfig()->getNested("class.ui");
    if(!isset($race_data[$class_name])){
    continue;
    }
    $effects_data = $race_data[$class_name]["effects"];
    foreach($effects_data as $datum){
    $player->addEffect(new EffectInstance(Effect::getEffect($datum["id"]), $datum["duration"] * 20, $datum["amplifier"], $datum["visible"]));
    }
    }
    }
    }
     
  2. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Are you sure that the code is running? If so, double-check that the values returning from your configuration file is correct.
     
  3. SomeServerOwner

    SomeServerOwner Spider Jockey

    Messages:
    40
    Everything works, except the effect part. Im only showing the effect part atm, do you want to see anything else?
     
  4. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    But is the code running though. Add a debugging message to see if the code is running
     
  5. SomeServerOwner

    SomeServerOwner Spider Jockey

    Messages:
    40
    I mean, I get the plugin enable message, and I get the class selector ingame, if thats what you mean
     
  6. SomeServerOwner

    SomeServerOwner Spider Jockey

    Messages:
    40
    do you mean add a debug message only to the effect part? im sorry I do not understand.
     
  7. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Add a debugging message after the $player->addEffect()
     
  8. SomeServerOwner

    SomeServerOwner Spider Jockey

    Messages:
    40
    Im sorry, but how? I do not know much of php
     
  9. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Simply add
    PHP:
    echo 'The code is being executed';
    And check your console
     
  10. SomeServerOwner

    SomeServerOwner Spider Jockey

    Messages:
    40
    I do not see that message in the console when I added it.
     
  11. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Bingo. The code isn't being executed, so there should be something wrong with one of your checks.
     
  12. SomeServerOwner

    SomeServerOwner Spider Jockey

    Messages:
    40
    what do you is most likely wrong?
     
  13. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Hmm...since i haven't seen the full code, I'm not sure. But try adding debugging messages on your checks and see if the checks are working.
    PHP:
    // Like this!
    if(blah blah blah) {
        echo 
    'Worked1';
    }
    if(
    another blah blah) {
        echo 
    'Worked 2';
    }
     
  14. SomeServerOwner

    SomeServerOwner Spider Jockey

    Messages:
    40
    here
     

    Attached Files:

  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.