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

Using PocketMoney Api

Comments in 'Plugin Development' started by AndrOyuN, Apr 16, 2016.

  1. AndrOyuN
    Offline

    AndrOyuN New Member

    Joined:
    Apr 12, 2016
    Posts:
    2
    For example, how can I add money to a player with pocketmoney api? I dont understand using another plugins.
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    public function getAPI(string $name){
    return 
    $this->getServer()->getPluginManager()->getPlugin($name);
    }

    // Use this: (I think the plugin name is PocketMoney, but idk)
    $this->getAPI("PocketMoney")->functionOfPocketMoney();
  3. AndrOyuN
    Offline

    AndrOyuN New Member

    Joined:
    Apr 12, 2016
    Posts:
    2
  4. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Usually, function name gives you the hint of what it is meant to do.
    It would be better if you explained what you don't understand, but what it is meant to do is that it does work for you. Instead of calling all this:
    PHP:
    if (!is_numeric($amount) or $amount 0) return false;
    if (!
    $this->isRegistered($sender)) return false;
    if (!
    $this->isRegistered($sender)) return false;
    if (!
    $this->grantMoney($sender, -$amountfalse)) return false;
    if (!
    $this->grantMoney($receiver$amountfalse)) return false;
    $this->getServer()->getPluginManager()->callEvent(
    new 
    MoneyUpdateEvent(
    $this,
    $sender,
    $this->getMoney($sender),
    MoneyUpdateEvent::CAUSE_PAY));
    $this->getServer()->getPluginManager()->callEvent(
    new 
    MoneyUpdateEvent(
    $this,
    $receiver,
    $this->getMoney($receiver),
    MoneyUpdateEvent::CAUSE_PAY));
    $this->getServer()->getPluginManager()->callEvent(
    new 
    TransactionEvent(
    $this,
    $sender,
    $receiver,
    $amount,
    TransactionEvent::TRANSACTION_PAY));
    return 
    true;
    Don't tell me to indent it, that just happened for some reason.
    You can just call:
    PHP:
    public function payMoney($sender$receiver$amount)
    But of course, you need to set who is going to pay, who is going to receive all that money, and how much he should send. That is the variable you need to put into the function when you are using it.
    Sorry if I have explained something you are already aware of. As I said, explaining what you are not understanding would be good.

Share This Page

Advertisement