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

How to add the possibility of losing money from the player

Discussion in 'Help' started by pixelworldserver, May 28, 2021.

  1. pixelworldserver

    pixelworldserver Spider

    Messages:
    9
    GitHub:
    pixelworldserver
    Hi, I want to create a plugin so that the player can buy something like a block. How can I allow the player to reduce the amount of money he has on the server a little and give it to the block?
     
  2. pixelworldserver

    pixelworldserver Spider

    Messages:
    9
    GitHub:
    pixelworldserver
  3. ComorDev

    ComorDev Spider

    Messages:
    11
    GitHub:
    comordev
    Hi, are you using EconomyAPI?
     
  4. pixelworldserver

    pixelworldserver Spider

    Messages:
    9
    GitHub:
    pixelworldserver
    Yes
     
  5. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    PHP:
    $amount = (int);
    // EconomyAPI main
    EconomyAPI::getInstance()->reduceMoney($player$amount); // Reduce money
    PHP:
    $amount = (int);
    EconomyAPI::getInstance()->addMoney($player$amount); // Add money
     
    Last edited: May 28, 2021
    Axon likes this.
  6. pixelworldserver

    pixelworldserver Spider

    Messages:
    9
    GitHub:
    pixelworldserver
    Thanks, can you give the code along with the classes?
     
  7. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    you find that out. I literally spoon-fed you...
     
    Last edited: May 28, 2021
  8. pixelworldserver

    pixelworldserver Spider

    Messages:
    9
    GitHub:
    pixelworldserver
    Thank you
     
  9. Axon

    Axon Zombie

    Messages:
    276
    You can use mt_rand(0,5) for a random.
    PHP:
    if(mt_rand(0,53){
     
    // minijagam code
    }
     
    Agent likes this.
  10. pixelworldserver

    pixelworldserver Spider

    Messages:
    9
    GitHub:
    pixelworldserver
    That's right, thank you
     
  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.