Shop Bug!

Discussion in 'Plugin Development' started by AdityaTD, Mar 5, 2015.

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

    AdityaTD

    Ok so bug is that People can buy even if they don't have enough coins! Code below!

    Code:
            if (cmd.getName().equalsIgnoreCase("buy-snowballgadget")) {
                        if (!player.hasPermission("gadget.snowball")){
                            getServer().dispatchCommand(getServer().getConsoleSender() , "eco take " + player.getName() + " 8000");
                            getServer().dispatchCommand(getServer().getConsoleSender() , "manuaddp " + player.getName() + " gadget.snowball");
                            player.sendMessage(ChatColor.BLUE + "Gadgets> " + ChatColor.WHITE +  "You bought Snowball Gadget, costing you 8000 NovaCoins!");
                        return true;
               
            }else{
                            if(player.hasPermission("gadget.snowball")){
                                player.sendMessage(ChatColor.BLUE + "Gadgets> " + ChatColor.WHITE + "You already have this gadget! Use /gadgets to access it.");
                            }
                        }
     
  2. Offline

    mine-care

    You simply perform a command regardles of its output so if I have 5$ your code will attempt to take 8k but it will simply take my 5$ and then the code will continue executing even tho I don't have enough money. To solve this, use vault API.
     
  3. Offline

    MordorKing78

    You aren't checking if a player has enough coins? You will need to link the Vault API to your plugin to do this
     
Thread Status:
Not open for further replies.

Share This Page