Sanity 435 Posted September 28, 2017 Report Share Posted September 28, 2017 I made a quick item on bank un-noting system that took me 5 minuites but i thought I should share. Just copy and paste the below into the itemOnObject method inside of UseItemPacket class For this to work you need to have defined that the item is noted in items.json if (item.getDefinition().isNoted() && gameObject.getDefinition().getName().toLowerCase().contains("bank")) { int id = item.getDefinition().getNoteId(); int amount = item.getAmount(); if (player.getInventory().getFreeSlots() == 0) { player.getPacketSender().sendMessage("You don't have enough space in your inventory."); return; } if (amount > player.getInventory().getFreeSlots()) amount = player.getInventory().getFreeSlots(); player.getInventory().getById(item.getId()).decrementAmountBy(amount); player.getInventory().add(id,amount); player.getPacketSender().sendMessage("You withdraw " + (amount) + " " + item.getDefinition().getName() + (amount > 1 ? "s" : "") + "."); } if (!item.getDefinition().isNoted() && item.getDefinition().getNoteId() != -1 && gameObject.getDefinition().getName().toLowerCase().contains("bank")) { player.setDialogueOptions(new DialogueOptions() { @Override public void handleOption(Player player, int option) { switch (option) { case 1: int amount = player.getInventory().getAmount(item.getId()); int id = item.getDefinition().getNoteId(); player.getInventory().delete(item.getId(),amount); player.getInventory().add(id,amount); player.getPacketSender().sendInterfaceRemoval(); break; case 2: player.getPacketSender().sendInterfaceRemoval(); break; } } }); DialogueManager.start(player, new Dialogue() { @Override public DialogueType type() { return DialogueType.OPTION; } @Override public DialogueExpression animation() { return null; } @Override public String[] dialogue() { return new String[] {"Note","Cancel"}; } }); } UPDATED: Can un-noted AND note using options Link to comment Share on other sites More sharing options...
SpiritOfTheLau 0 Posted May 9, 2020 Report Share Posted May 9, 2020 Good work! Your contributions are aweseome. Link to comment Share on other sites More sharing options...
TestySauce 1 Posted December 2, 2021 Report Share Posted December 2, 2021 thanks very helpful Link to comment Share on other sites More sharing options...
Mevaderiseenhoer 1 Posted January 19, 2022 Report Share Posted January 19, 2022 thanks Link to comment Share on other sites More sharing options...
Arsenic 0 Posted February 14, 2022 Report Share Posted February 14, 2022 Thanks, Sanity. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now