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

How to fix this erreur on player join

Comments in 'Plugin Development' started by GuddaJ, Aug 21, 2016.

  1. GuddaJ
    Offline

    GuddaJ New Member

    Joined:
    Aug 18, 2015
    Posts:
    47
    Minecraft User:
    YoungRichNigger9
    this is actualy my first plugin i want to do a plugin any effect you set in config when players join they will get that effect but im stuck with the join event
    (im just trying to get better in php so please do not judge me )
    PHP:
    public function onJoin(PlayerJoinEvent $event) {
            
    $cfg $this->getConfig();
            
    $p $event->getPlayer();
            
    $this->getServer()= new receiveEffect() == $p;  //This the ligne 56
        
    }
    i does get a erreur on console on line 56

    PHP:
    Fatal errorCan't use method return value in write context in C:\Users\PC\Downloads\Minecraft\Genisys Server\plugins\JoinEffect-master\src\YoungRichNigger9\Main.php on line 56
  2. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    $this->getServer() is a final function in PluginBase.
    PHP:
    = new receiveEffect() == $p;
    I do not get the point?

    Altough, "Genisys Server"...
    MikkiMCPE likes this.
  3. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    I don't know what that line is supposed to do. It is total nonsense.
    Try explaining in english what you want to do...
    SOFe, MikkiMCPE and CraftYourBukkit like this.
  4. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    Why not use $p->addEffect()?
  5. GuddaJ
    Offline

    GuddaJ New Member

    Joined:
    Aug 18, 2015
    Posts:
    47
    Minecraft User:
    YoungRichNigger9
    Im french so my englesh is kinda bad what im trying to do is when the playerà join it will get the effect that is set in the config and give it to the player
  6. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    add this after namespace:
    PHP:
    use pocketmine\entity\Effect;
    and this(Player Join event):
    PHP:
      public function onJoin(PlayerJoinEvent $event) {
         
    $player $event->getPlayer();
         
    $player->addEffect(Effect::getEffect(1)->setDuration(1200)->setAmplifier(1));
         
    //Effect::getEffect() is getting The Effect with id 1(speed)
        //setDuration() is setting duration of the effect(in ticks), 1200 ticks = 1 minute
       //setAmplifier() is setting the Amplifier of the effect
      
    }
  7. GuddaJ
    Offline

    GuddaJ New Member

    Joined:
    Aug 18, 2015
    Posts:
    47
    Minecraft User:
    YoungRichNigger9
    But it wont get the effect that i set in config it will just set the effect
  8. GuddaJ
    Offline

    GuddaJ New Member

    Joined:
    Aug 18, 2015
    Posts:
    47
    Minecraft User:
    YoungRichNigger9
    This is the config


    Effect-I:eek: 1
    Duration: 2400
    Amplifier: 0
    Particles: true
  9. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    create a config with array onEnable:
    PHP:
    $config = new Config($this->getDataFolder() . "config.yml"Config::YAML, array (
                  
    "Effect-id" => 1,
                  
    "Effect-Duration" => 2400,
                  
    "Amplifier" => 0,
                  
    "Particles" => true
           
    ));
    And change onJoin to:
    PHP:
    public function onJoin(PlayerJoinEvent $event) {
                
    $id $config->get("Effect-id");
                
    $ticks $config->get("Effect-Duration");
                
    $amplifier $config->get("Amplifier");
                
    $particle $config->get("Particles");
                
               
    $player $event->getPlayer();
               
    $player->addEffect(Effect::getEffect($id)->setDuration($ticks)->setAmplifier($amplifier)->setVisible($particle);
           }
    MikkiMCPE likes this.
  10. GuddaJ
    Offline

    GuddaJ New Member

    Joined:
    Aug 18, 2015
    Posts:
    47
    Minecraft User:
    YoungRichNigger9
    Thanks bro i try it when i finish eat i trll you if it work
  11. GuddaJ
    Offline

    GuddaJ New Member

    Joined:
    Aug 18, 2015
    Posts:
    47
    Minecraft User:
    YoungRichNigger9
  12. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    Not working?
  13. GuddaJ
    Offline

    GuddaJ New Member

    Joined:
    Aug 18, 2015
    Posts:
    47
    Minecraft User:
    YoungRichNigger9
    No check ur pm
  14. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    Nothing...
  15. GuddaJ
    Offline

    GuddaJ New Member

    Joined:
    Aug 18, 2015
    Posts:
    47
    Minecraft User:
    YoungRichNigger9
    Sorry internet connection bug .chck again
  16. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    Tell me that this line isn't supposed to be pseudocode. I'll throw up if you call it pseudocode.
  17. Yeelze
    Offline

    Yeelze New Member

    Joined:
    Apr 2, 2016
    Posts:
    31
    Minecraft User:
    Yeelze
    What? Is more easy create a folder called "resources" with a config.yml and then you put all the info
    PHP:
    $config $this->getConfig();
    Some people use that, works but isn't the good way to do it
    PHP:
    $config = new Config($this->getDataFolder()."config.yml"Config::YAML)
  18. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    PluginBase::getConfig() is a good way to do that. If it is really a config file. If you abuse the Config class to save data rather than making a config file, maybe no.
    The main advantage is that it reduces the amount of code you write (putting them in resource files instead). Usually, verbose content such as config format declaration, config default values, etc., should be placed in external files rather than in code directly.
    Yeelze likes this.

Share This Page

Advertisement