Jump to content

Featured Replies

Posted
comment_13277

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"};
				}
				
			});
		}

3TueeA8.gif

UPDATED:
Can un-noted AND note using options :/

  • 2 years later...
  • 1 year later...
  • 1 month later...
  • 4 weeks later...

Create an account or sign in to comment