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

Effect Remove Help

Comments in 'Plugin Development' started by SM11, Aug 18, 2015.

  1. SM11
    Offline

    SM11 Active Member

    Joined:
    Jun 21, 2015
    Posts:
    117
    Minecraft User:
    SM11
    I need some help, Is it Possible to Make a Plugin where on a Certain Command, All players in a Certain World Have a Certain Effect Removed. If it is Please Help me
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Yes :p
    Code:
    '/er <world> <effect>'
    
    er factions speed
    PHP:
    removeEffectFromWorld(Level $world$effectId){
    $effectName Effect::getEffect($effectId)->getName();
    foreach(
    $world->getPlayers() as $p){
    if(
    $p->hasEffect($effectId)){
    $p->removeEffect($effectId);
    $p->sendMessage('[EffectRemover] '.$effectName.' effect has been taken away');
    }
    }
    $this->getServer()->broadcastMessage('[EffectRemover] '.ucfirst($effectName).' effect have been taken away from '.$world->getName().' world');
    return 
    true;
    }
  3. SM11
    Offline

    SM11 Active Member

    Joined:
    Jun 21, 2015
    Posts:
    117
    Minecraft User:
    SM11
    I would add that In the Command Code right?
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Nah, add this function to Main class and call it from onCommand();
  5. SM11
    Offline

    SM11 Active Member

    Joined:
    Jun 21, 2015
    Posts:
    117
    Minecraft User:
    SM11
    Thanks That Was What I was going to do
  6. SM11
    Offline

    SM11 Active Member

    Joined:
    Jun 21, 2015
    Posts:
    117
    Minecraft User:
    SM11
    Error in the Code
  7. SM11
    Offline

    SM11 Active Member

    Joined:
    Jun 21, 2015
    Posts:
    117
    Minecraft User:
    SM11
    Syntax Error Unexpected $world
  8. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Can't you fix it by your own?
  9. SM11
    Offline

    SM11 Active Member

    Joined:
    Jun 21, 2015
    Posts:
    117
    Minecraft User:
    SM11
    sorry but Its a Little hard for me Since I've never used Something like this when I code, Could u help please
  10. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Line
  11. SM11
    Offline

    SM11 Active Member

    Joined:
    Jun 21, 2015
    Posts:
    117
    Minecraft User:
    SM11
    21
  12. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I dont see any error in my code that i posted can you please post here your whole code?
  13. SM11
    Offline

    SM11 Active Member

    Joined:
    Jun 21, 2015
    Posts:
    117
    Minecraft User:
    SM11
    PHP:
    <?php

    namespace SM11\EffectRemove;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\effect\Effect;

    class 
    Main extends PluginBase{

        public function 
    onEnable(){
            
    $this->getLogger()->info("EffectRemove have been Enabled!");
        }

        public function 
    onDisable(){
            
    $this->getLogger()->info("EffectRemove Have been Enabled!");
        }

       public function 
    onCommand(CommandSender $sender,Command $cmd,$label, array $args) {
         
    RemoveEffectFromWorld(Level $world $effectId){
             
    $effectName Effect::getEffect($effectId)->getName();
             foreach(
    $world->getPlayers() as $p){
             if(
    $p->hasEffect($effectId)){
             
    $p->removeEffect($effectId);
             
    $p->sendPopup('[SSM] '.$effectName.'You May now Begin');
             }
             }
             
    $this->getServer()->SendPopup('[SSM] '.ucfirst($effectName).'Game May Now Begin'.$world->getName().' world');
             return 
    true;
             }     
             }

    }
  14. Rspuds
    Offline

    Rspuds New Member

    Joined:
    Aug 4, 2015
    Posts:
    53
    On line 21 you need to add a comma between $world and $effectId. Primus had it in his code he posted you must have missed it when you copyed it. Just make sure your line 21 looks like the first line of his code.
  15. SM11
    Offline

    SM11 Active Member

    Joined:
    Jun 21, 2015
    Posts:
    117
    Minecraft User:
    SM11
    Added it Still Errored
  16. Rspuds
    Offline

    Rspuds New Member

    Joined:
    Aug 4, 2015
    Posts:
    53
    Shouldn't be. What's the error now? And can you post your new code so I can make sure u changed it correctly.
  17. SM11
    Offline

    SM11 Active Member

    Joined:
    Jun 21, 2015
    Posts:
    117
    Minecraft User:
    SM11
    PHP:
    <?php

    namespace SM11\EffectRemove;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\effect\Effect;

    class 
    Main extends PluginBase{

        public function 
    onEnable(){
            
    $this->getLogger()->info("EffectRemove have been Enabled!");
        }

        public function 
    onDisable(){
            
    $this->getLogger()->info("EffectRemove Have been Enabled!");
        }

       public function 
    onCommand(CommandSender $sender,Command $cmd,$label, array $args) {
         if (
    $cmd->getName() != "EffectRemove") return false;
         if (
    count($args) != 0) return false;
             
    RemoveEffectFromWorld(Level $world$effectId){
             
    $effectName Effect::getEffect($effectId)->getName();
             foreach(
    $world->getPlayers() as $p){
             if(
    $p->hasEffect($effectId)){
             
    $p->removeEffect($effectId);
             
    $p->sendPopup('[SSM] '.$effectName.'You May now Begin');
             }
             }
             
    $this->getServer()->SendPopup('[SSM] '.ucfirst($effectName).'Game May Now Begin'.$world->getName().' world');
             return 
    true;
             }     
             }

    }
  18. Rspuds
    Offline

    Rspuds New Member

    Joined:
    Aug 4, 2015
    Posts:
    53
    What's the error? Is it still the same?
  19. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Noo :D, you must put that function outside onCommand(); and call in it. like this: $this->removeEffectFromWorld($args[0], $args[1]);
  20. SM11
    Offline

    SM11 Active Member

    Joined:
    Jun 21, 2015
    Posts:
    117
    Minecraft User:
    SM11

Share This Page

Advertisement