VaultAPI | Checking Groups | Checking Money

Discussion in 'Plugin Development' started by Niknea, Apr 1, 2014.

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

    Niknea

    Hey guys,

    I am creating a scoreboard plugin, and I have two questions involving vault, and one about something else.

    Firstly, how can I check what the group name is called that a player is in (using vault to connect with their permissions plugin), then display it on the scoreboard.

    Secondly, how can I get the players money from Vault?

    Finally, this is more of a question combing the two questions stated above, is it possible for me to get what group the player is in from reading the text on the scoreboard, that was created by question 1, then grabbing there money and subtracting it from a certain amount per rank? As I am adding a feature where it will say the money needed for rank up.

    EX - If a player is in group "A" and you need $5000 to rank up, and the player only has $100, it will say something like this on the scoreboard

    MONEY NEEDED:
    $4900

    @xXSniperxxXx_SD any chance you know any of these questions? As I know you did do most of these in your plugin "Info Board".

    Thanks,
    Niknea.
     
  2. Offline

    St3venAU

    First, initialize vault as per the instructions and code on the vault bukkit page.

    To get the group that a player is in:
    Code:java
    1. String group = permission.getPrimaryGroup(player);


    To change the group that a player is in:
    Code:java
    1. permission.playerAddGroup(player,"OldGroupName");
    2. permission.playerRemoveGroup(player,"NewGroupName");


    To take money from a player (in this example its 1000 money):
    Code:java
    1. int cost = 1000;
    2. if(economy.has(player.getName(),cost))
    3. {
    4. economy.withdrawPlayer(player.getName(),cost);
    5. }
    6. else
    7. {
    8. // Player has less than 1000, send a message or whatever you want to do here
    9. }


    As for displaying the information on the scoreboard, there is a good tutorial here: https://forums.bukkit.org/threads/tutorial-scoreboards-teams-with-the-bukkit-api.139655/
     
    Niknea likes this.
  3. Offline

    Niknea

    St3venAU Question 2 wasent answer, how can I get the players balance?
     
  4. Offline

    St3venAU

    Code:java
    1. Double balance = economy.getBalance(player.getName());
     
Thread Status:
Not open for further replies.

Share This Page