Advertisement
peacestorm

Trade gold function

Mar 7th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function tradeGold(goldAmount, itemId, itemAmount, itemDamage) {
  2.     //your code (add item and remove the gold)
  3.     var playerGoldAmount;
  4.     for(var i = 0; i <= 36; i++) {
  5.         if(Player.getInventorySlot(i) == 266) {
  6.             playerGoldAmount = playerGoldAmount + Player.getInventorySlotCount(i);
  7.         }
  8.     }
  9.     if(playerGoldAmount >= goldAmount) {
  10.         Player.addItemInventory(266, -goldAmount, 0);
  11.         Player.addItemInventory(itemId, itemAmount, itemDamage);
  12.     } else {
  13.         clientMessage(ChatColor.RED + "You need " + Math.floor(goldAmount - playerGoldAmount) + " more gold to trade!");
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement