I need help repeating the message

Discussion in 'Help' started by MBIM, Nov 17, 2019.

  1. MBIM

    MBIM Creeper

    Messages:
    1
    I want to repeat the message you do not have enough money in a shorter way
    case 1:
    $item1 = Item::get(257, 0, 1);

    $money = $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->myMoney($sender);
    if ($money < 100){
    $sender->sendMessage("You do not have enough money");
    }
    else{
    $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->reduceMoney($sender->getName(), 100);
    $sender->getInventory()->addItem($item1);
    $sender->sendMessage("§e You have won an item");
    }
    return true;
    break;
    case 2:
    $item2 = Item::get(264, 0, 5);

    $money = $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->myMoney($sender);
    if ($money < 100){
    $sender->sendMessage("You do not have enough money");
    }
    else{
    $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->reduceMoney($sender->getName(), 100);
    $sender->getInventory()->addItem($item2);
    $sender->sendMessage("§e You have won an item");
    }
    return true;
    break
     
  2. Primus

    Primus Zombie

    Messages:
    327
    Oh cmon, the price is the same in both cases. Check the money before the switch.
     

Share This Page

  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.