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

Per area effect

Comments in 'Plugin Development' started by dxm_hippie, Sep 19, 2015.

  1. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    So hears my issue..i am using iProtector by LDX to add a per area effect using playerMoveEvent in his plugin. I asked him if he could help out and he said yes but he is very busy, i got impatient lol I really dont understand why my code dont work. It will send the messages CORRECTLY for multiple areas but will only set the effect for the last area i make..note when i do /area it list the last area i make..well last. lol just thinking i have some sort of array issue maybe. Anywho heres the code

    onEnable..
    PHP:
    $this->config = new Config($this->getDataFolder()."config.yml"Config::YAML, array());
    $this->areas = array();
    contains =...
    PHP:
    public function contains($pos,$level) {
        if((
    min($this->pos1->getX(),$this->pos2->getX()) <= $pos->getX()) && (max($this->pos1->getX(),$this->pos2->getX()) >= $pos->getX()) && (min($this->pos1->getY(),$this->pos2->getY()) <= $pos->getY()) && (max($this->pos1->getY(),$this->pos2->getY()) >= $pos->getY()) && (min($this->pos1->getZ(),$this->pos2->getZ()) <= $pos->getZ()) && (max($this->pos1->getZ(),$this->pos2->getZ()) >= $pos->getZ()) && ($this->level == $level)) {
          return 
    true;
        }
        return 
    false;
      }
    MoveEv..
    PHP:
    public function onMove(playerMoveEvent $event){
          foreach(
    $this->areas as $area) {
              
    $p $event->getPlayer();
          
              
    $areaName = ($area->getName());
              
    $ID $this->config->get("$areaName");
          
          if(
    $area->contains(new Vector3($p->getX(),$p->getY(),$p->getZ()),$p->getLevel()->getName() and $ID != NULL)) {
          
              
    $effect Effect::getEffect($ID);
              
    $boost $this->config->get("$areaName-Amplifier");
       
          if(!
    $p->hasEffect($ID)){
           
    $effect->setAmplifier($boost);
           
    $effect->setVisible(false);
           
    $effect->setDuration(999999);
       
         
               
    $p->addEffect($effect); //only sets the effect for the last /area i make
               
    $p->sendMessage("$ID"); //just for testing WORKS
               
    $p->sendMessage("$areaName");//just for testing WORKS
               
    $p->sendMessage("$boost");//just for testing WORKS
          
    }
     
        }else{
        
    $p->removeAllEffects();
       }
      }
    }
    I just write the area names in the config like so..
    Code:
    test2: 3
    test2-Amplifier: 20
    
    test: 2
    test-Amplifier: 5
    
    arena: 20
    arena-Amplifier: 5
    Last edited: Sep 19, 2015
  2. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Variables and strings are different...
    Last edited: Sep 19, 2015
  3. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Ok..lol a string cant be stored in a variable is what your saying? 0.o
  4. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    and wat were you thinking for the line where you defined $boost...
  5. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    No... I mean why are you putting quotation marks around variables...
  6. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Bc i figured it was for a message or when "getting" a string
  7. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    You do NOT put quotation marks around variables... Ever. (Unless you're a noob :p)
    dxm_hippie likes this.
  8. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    BTW a player is a vector so no need for ;)
    PHP:
    new Vector3($p->getX(), $p->getY(), $p->getZ())
    just put your player variable
  9. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I cant remove that..its a big part of the iProtector plugin lol i could make it diffrent tho right? like $this->Areassss lol
  10. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    also..why do i need to get the plugin i am using this in the iProtector plugin on the main.php
  11. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I is :/ lol but i took them away from the sendMessage..and it wont send the message right soo wouldnt i need to put quots around it in that case?
  12. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    It doesn't matter if the variable is a string or not. Do you even know what you're doing?...
  13. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Kinda..lol and what do you mean? im saying when sending a message as a variable it wont work unless theirs quots around it. well this time anyway. nevermind the quots i still dont understand why this is not working properly lol it is getting the information correct for as many areas as i make but will only set the effect for the last area i make
  14. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    That didnt work btw
  15. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
  16. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Cause you're not doing what you want correctly.
  17. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    You might as well request the plugin instead... You don't know what you're doing at all...
    (I could make it if you want)
  18. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I still dont understand it is getting the area correctly..area name and id and amp from the config all correctly. Wouldnt i have to use iP api to get the area?
  19. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Im not making a whole new plugin i just added playermoveevnet to iprotector
  20. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    But..it almost works XD

Share This Page

Advertisement