cant take money from players

Discussion in 'Plugin Development' started by tommycake50, Aug 31, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    tommycake50

    OK i dont really know why i am getting this error
    its probably something really simple :rolleyes: but
    the code thats getting the error is
    Code:
    withdrawPlayer(player,getConfig().getInt("price"));
    and the error is
    Code:
    The method withdrawPlayer(Player, int) is undefined for the type Enchant4cash
     
  2. Offline

    MrZoraman

    Have you created the method 'withdrawPlayer'? What does that code look like?
     
  3. Offline

    tommycake50

    it belongs to vault should have said in the OP
     
  4. Offline

    slater96

    You have to do economy.withdrawPlayer for vault I think.
     
  5. Offline

    MrZoraman

    Do you have the economy setup in your onEnable() method?

    You need to make an instance of the economy object.

    Code:
    public Economy econ = null;
     
    @Override
    public void onEnable()
    {
        setupEconomy();
    }
     
    private boolean setupEconomy()
    {
        RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
        if(rsp == null)
        {
            return false;
        }
        econ = rsp.getProvider();
        return econ != null;
    }
     
    //in your code when you transact you use this
     
    EconomyResponse r = econ.withdrawPlayer(player.getName(), getConfig().getDouble("price"));
    //note that is a getDouble
    if(r.transactionSuccess())
    {
        player.sendMessage(ChatColor.GREEN + "Transaction success!");
    }
    else
    {
        player.sendMessage(String.format("An error has occured: %s", r.errorMessage));
    }
    
    For more details and a better example, look here:
    https://github.com/MilkBowl/Vault/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  6. Offline

    tommycake50

    thanks but i get these errors
    Code:
    Multiple markers at this line
        - REconomyResponse cannot be resolved to a
        type
    and
     
    econ cannot be resolved
     
  7. Offline

    MrZoraman

    Is eclipse giving you those errors, or are they being spit out by the console?
     
  8. Offline

    tommycake50

    eclipse
     
  9. Offline

    tommycake50

    wait it worked! dunno why i got the errors but it works now thanks so much
     
Thread Status:
Not open for further replies.

Share This Page