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

Undefined method

Discussion in 'Development' started by A354-PH, Feb 14, 2019.

  1. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    How to fix?
    ERROR:
    Code:
    [11:53:00] [Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\utils\Color::getDyeColor()" (EXCEPTION) in "plugins/TheBridge v1.1.8.phar/src/bridge/utils/arena/ArenaManager" at line 858
    CODE:
    PHP:
    $color Color::getDyeColor(1); //Line 858
            
    $damage 14;
            
            
    $team $this->getTeam($name);
            if(!
    is_null($team)){
                switch(
    $team){
                    case 
    "blue":
                    
    $color Color::getDyeColor(4);
                    
    $damage 11;
                    break;
                    case 
    "red":
                    
    $color Color::getDyeColor(1);
                    
    $damage 14;
                    break;
                }
            }
     
  2. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    it means there's no function called getDyeColor();

    I don't know what you're trying to do, but you can try Color::fromRGB();
     
  3. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    The code is trying to dye the leather armor the player has
     
  4. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    can you show your code?
     
  5. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    you can use an RGB to HEX calculator online, then put it as the first parameter in Color::fromRGB();
    example:
    PHP:
    $color Color::fromRGB(0xFF1940);
     
  6. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    Like this?
    PHP:
    if(!is_null($team)){
                switch(
    $team){
                    case 
    "blue":
                    
    $color Color::fromRGB(0x3C44AA);
                    
    $damage 11;
                    break;
                    case 
    "red":
                    
    $color Color::fromRGB(0xFF5555);
                    
    $damage 14;
                    break;
                }
            }
     
  7. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    Heres the whole function
    PHP:
    public function addItens($p$v true){
            
            
    $p->setGamemode(Player::SURVIVAL);
            
    $p->setHealth($p->getMaxHealth());
            
    $p->setFood(20);
            
            if(!
    $v){
                
    $p->removeAllEffects();
                
    $inv $p->getInventory();
                
    $inv->clearAll();
                
                
    $inv->setItem(8Item::get(35501)->setCustomName("§L§cReturn To Lobby"));
                return 
    true;
            }
            
            
    $name strtolower($p->getName());
            
    $color Color::fromRGB(0xFF5555);
            
    $damage 14;
            
            
    $team $this->getTeam($name);
            if(!
    is_null($team)){
                switch(
    $team){
                    case 
    "blue":
                    
    $color Color::fromRGB(0x3C44AA);
                    
    $damage 11;
                    break;
                    case 
    "red":
                    
    $color Color::fromRGB(0xFF5555);
                    
    $damage 14;
                    break;
                }
            }
            
    $inv $p->getInventory();
            
    $arminv $p->getArmorInventory();
            
    $inv->clearAll();
            
            
    $esp Item::get(26701);
            if(
    $this->hasHab($p"matador")){
                
    $ench Enchantment::getEnchantment(9);
                
    $ench->setLevel(1);
                
                
    $esp->addEnchantment($ench);
            }
            
    $pic Item::get(27801);
            if(
    $this->hasHab($p"destruidor")){
                
    $ench Enchantment::getEnchantment(15);
                
    $ench->setLevel(5);
                
                
    $pic->addEnchantment($ench);
            }
            
    $arco Item::get(26101);
            
    $flecha Item::get(26208);
            
    $food Item::get(36405);
            
    $food2 Item::get(32202);
            
    $block Item::get(159$damage64);
            
            
    $inv->setItem(0$esp);
            
    $inv->setItem(1$pic);
            
    $inv->setItem(2$arco);
            
            
    $inv->setItem(3$block);
            
    $inv->setItem(4$block);
            
    $inv->setItem(6$food2);
            
    $inv->setItem(7$food);
            
    $inv->setItem(32$flecha);
            
            
    $cap Item::get(29801);
            
    $cap->setCustomColor($color);
            
            
    $peit Item::get(29901);
            
    $peit->setCustomColor($color);
            if(
    $this->hasHab($p"tank")){
                
    $peit Item::get(31101);
            }
            
            
    $calc Item::get(30001);
            
    $calc->setCustomColor($color);
            
            
    $bot Item::get(30101);
            
    $bot->setCustomColor($color);
            
            
    $arminv->setHelmet($cap);
            
    $arminv->setChestplate($peit);
            
    $arminv->setLeggings($calc);
            
    $arminv->setBoots($bot);
        }
        
     
  8. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    yup
     
  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.