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

Reduce money from player

Discussion in 'Development' started by SJames, Apr 10, 2020.

  1. SJames

    SJames Spider Jockey

    Messages:
    35
    GitHub:
    sjamese
    Hello!

    I want to modify the plugin Repair and make it so that you have to pay to Repair your tools. I am not 100% sure how to do it, that's why I've made this thread. On other threads i've seen that I have to do something like that:
    Code:
    public $economy;
    
    
    $this->economy = $this->getServer()->getPluginMananager()->getPlugin("EconomyAPI");
    One of my questions is where do I put the "public $economy;" do I put it right after the main class like that?
    Code:
    class Main extends PluginBase {
    public $economy;
    ...
    }
    To reduce money I want to make a function in the main.php file. How do I reduce money from a player? I just use the reduceMoney($player, $amount) function?
    Or do I have to check if the player has enough money and then do that ^^?

    Please don't just throw at me lines of code, because I am new at plugins coding..
    Thanks in advance =)
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
  3. Emirhan Akpınar

    Emirhan Akpınar Slime

    Messages:
    90
    PHP:
    use onebone\economyapi\EconomyAPI;

    EconomyAPI::getInstance()->reduceMoney($player$money);
     
    ethaniccc likes this.
  4. HiToLaKhanh

    HiToLaKhanh Spider Jockey

    Messages:
    25
    GitHub:
    HiToLaKhanh
    you can use /takemoney dude
     
  5. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    That doesn't solve their problem at all
     
    Primus likes this.
  6. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    why? he can use:
    PHP:
    $this->getServer()->dispatchcommand($player"takemoney 1000");
    but iknow its no good way to do that, but its working too :p
    but if player haven't 1000 money, this gives error and its not best way (i mean anyway this run it player haven't enough money)
     
  7. Primus

    Primus Zombie Pigman

    Messages:
    749
    This gives no feedback whatsoever.
    Your thought process is on point. Why don't you just try and see?
    Class properties can be defined anywhere right in the scope of class. This is more a question of language rather than pocketmine.
     
    GamakCZ likes this.
  8. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    yes i said its bad way to do, but its possible :p
     
  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.