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

Solved Add money with EconomyAPI

Discussion in 'Development' started by Matrox, Feb 15, 2019.

  1. Matrox

    Matrox Slime

    Messages:
    92
    GitHub:
    MatroxMC
    I would like to know that she is my line to add money thanks to economyapi
     
  2. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    PHP:
    /** @var Player $player */
    EconomyAPI::getInstance()->addMoney($player100);
     
  3. Matrox

    Matrox Slime

    Messages:
    92
    GitHub:
    MatroxMC
    This works :)
    PHP:
    $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->addMoney($player100);
     
  4. Matrox

    Matrox Slime

    Messages:
    92
    GitHub:
    MatroxMC
    And remove money ??
     
  5. Matrox

    Matrox Slime

    Messages:
    92
    GitHub:
    MatroxMC
    Found :)
    PHP:
    $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->reduceMoney($player100);
     
  6. Matrox

    Matrox Slime

    Messages:
    92
    GitHub:
    MatroxMC
    I would like to know how to make it so that the player's wallet is below the price allor tell him no you did not asser


    instead of $wallet I want the player's account amount

    PHP:
        
             $price 
    50;

            if (
    $wallet $price) {
            
                
    $sender->sendMessage("Yes");
            } else {

                
    $sender->sendMessage("No");
                }
            }
            return 
    true;
     
  7. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    PHP:
    /** @var Player $player */
    /** @var bool|float $wallet */
    $wallet EconomyAPI::myMoney($player);
     
  8. Matrox

    Matrox Slime

    Messages:
    92
    GitHub:
    MatroxMC
    :( help
    PHP:
    public function onCommand(CommandSender $playerCommand $commandString $label, array $args) : bool {
           switch(
    $command->getName()){
          
            case 
    "buyenchant":

            
    $price 50;
            
    $wallet EconomyAPI::myMoney($player);


            if (
    $wallet $price) {
          
                
    $sender->sendMessage("Yes");
            } else {

                
    $sender->sendMessage("No");
                }
          
            return 
    true;
          
           }
        }
     
  9. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    what's the problem?
     
  10. Matrox

    Matrox Slime

    Messages:
    92
    GitHub:
    MatroxMC
    It does not work
     
  11. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    did you register the command? where is this function located?
     
  12. Matrox

    Matrox Slime

    Messages:
    92
    GitHub:
    MatroxMC
    I did not understand
     
  13. Gianluxx

    Gianluxx Slime

    Messages:
    94
    GitHub:
    Gianluxx
    What is the error?
     
  14. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    did you register the command on plugin.yml
     
  15. Gianluxx

    Gianluxx Slime

    Messages:
    94
    GitHub:
    Gianluxx
    public function onCommand(CommandSender $sender, Command $command, String $label, array $args) : bool {
    switch($command->getName()){

    case "buyenchant":

    $cost = 50;
    if(EconomyAPI::getInstance()->myMoney($sender) > $cost){
    $sender->sendMessage("Bought");
    EconomyAPI::getInstance()->reduceMoney($sender, $cost);
    }else{
    $sender->sendMessage("No money");
    }
     
  16. Matrox

    Matrox Slime

    Messages:
    92
    GitHub:
    MatroxMC
    Thanks
     
  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.