Thread: [Elvarg / OSRSPK] Item on bank un-noting.

Results 1 to 9 of 9
  1. #1 [Elvarg / OSRSPK] Item on bank un-noting. 
    Registered Member Farage's Avatar
    Join Date
    Jan 2017
    Posts
    252
    Thanks given
    24
    Thanks received
    22
    Rep Power
    0
    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
    Code:
    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 :/
    Have a nice day!
    Иди в пизду!
    Bonne journée!
    Einen schönen Tag noch!
    Hezký den!
    祝你今天愉快!
    Reply With Quote  
     

  2. #2  
    Extreme Donator


    Join Date
    Oct 2010
    Posts
    2,853
    Thanks given
    1,213
    Thanks received
    1,622
    Rep Power
    5000
    Thanks, although you shouldn't be using a loop
    [Today 01:29 AM] RSTrials: Nice 0.97 Win/Loss Ratio luke. That's pretty bad.
    [Today 01:30 AM] Luke132: Ok u fucking moron i forgot i could influence misc.random
    Reply With Quote  
     

  3. #3  
    Registered Member Farage's Avatar
    Join Date
    Jan 2017
    Posts
    252
    Thanks given
    24
    Thanks received
    22
    Rep Power
    0
    Quote Originally Posted by Professor Oak View Post
    Thanks, although you shouldn't be using a loop
    Your probably right, but i used it cos it will check every time if the player has inv space than when the un-noting commences and they obtain an item and they lose their note.

    nvm
    updated so now it doesn't use loop. should be as improved as possible lmao.
    only made it quickly so i can use it for runecrafting. which i should have released soon. just need to gather data about things like xp and object ids, shouldnt be long.
    Have a nice day!
    Иди в пизду!
    Bonne journée!
    Einen schönen Tag noch!
    Hezký den!
    祝你今天愉快!
    Reply With Quote  
     

  4. #4  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    I was confused as fuck until I read the first comment. Code itself contains no loop but it clearly shows on the gif how the items are being added one by one.. Until I saw the replies.
    You might want to add a check if the amount is 0, returning the code.
    Attached image
    Reply With Quote  
     

  5. #5  
    Registered Member Farage's Avatar
    Join Date
    Jan 2017
    Posts
    252
    Thanks given
    24
    Thanks received
    22
    Rep Power
    0
    Quote Originally Posted by Kris View Post
    I was confused as fuck until I read the first comment. Code itself contains no loop but it clearly shows on the gif how the items are being added one by one.. Until I saw the replies.
    You might want to add a check if the amount is 0, returning the code.
    Good idea! Changed now
    Have a nice day!
    Иди в пизду!
    Bonne journée!
    Einen schönen Tag noch!
    Hezký den!
    祝你今天愉快!
    Reply With Quote  
     

  6. #6  
    Extreme Donator


    Join Date
    Oct 2010
    Posts
    2,853
    Thanks given
    1,213
    Thanks received
    1,622
    Rep Power
    5000
    Quote Originally Posted by S C A P E View Post
    Good idea! Changed now
    Code:
    			int amount = item.getAmount();
                            if (amount <= 0) 
                                    return;
    			if (amount > player.getInventory().getFreeSlots()) 
    				amount = player.getInventory().getFreeSlots();
    I'd put the check after the inventory check:
    Code:
    			int amount = item.getAmount();
    			if (amount > player.getInventory().getFreeSlots()) 
    				amount = player.getInventory().getFreeSlots();
                            if (amount <= 0) 
                                    return;
    That way, if player has no free inventory slots (amount will be 0), it won't continue.
    Your current check simply checks if the player's noted items amount is 0, which really isn't realistic since they used at least one on the bank

    A nice little addition though, thanks again.
    [Today 01:29 AM] RSTrials: Nice 0.97 Win/Loss Ratio luke. That's pretty bad.
    [Today 01:30 AM] Luke132: Ok u fucking moron i forgot i could influence misc.random
    Reply With Quote  
     

  7. #7  
    Registered Member Farage's Avatar
    Join Date
    Jan 2017
    Posts
    252
    Thanks given
    24
    Thanks received
    22
    Rep Power
    0
    Quote Originally Posted by Professor Oak View Post
    Code:
    			int amount = item.getAmount();
                            if (amount <= 0) 
                                    return;
    			if (amount > player.getInventory().getFreeSlots()) 
    				amount = player.getInventory().getFreeSlots();
    I'd put the check after the inventory check:
    Code:
    			int amount = item.getAmount();
    			if (amount > player.getInventory().getFreeSlots()) 
    				amount = player.getInventory().getFreeSlots();
                            if (amount <= 0) 
                                    return;
    That way, if player has no free inventory slots (amount will be 0), it won't continue.
    Your current check simply checks if the player's noted items amount is 0, which really isn't realistic since they used at least one on the bank

    A nice little addition though, thanks again.
    Blame that on Kris
    Have a nice day!
    Иди в пизду!
    Bonne journée!
    Einen schönen Tag noch!
    Hezký den!
    祝你今天愉快!
    Reply With Quote  
     

  8. #8  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    Quote Originally Posted by S C A P E View Post
    Blame that on Kris
    Why on me? I never said put it right after its initial declaration. Of course I meant below the last one, an item's amount cannot be zero (unless you have some serious core problems) by default; it can only be set to zero if there are no free inventory spaces.
    Attached image
    Reply With Quote  
     

  9. #9  
    Registered Member Farage's Avatar
    Join Date
    Jan 2017
    Posts
    252
    Thanks given
    24
    Thanks received
    22
    Rep Power
    0
    Quote Originally Posted by Kris View Post
    Why on me? I never said put it right after its initial declaration. Of course I meant below the last one, an item's amount cannot be zero (unless you have some serious core problems) by default; it can only be set to zero if there are no free inventory spaces.
    Ah, you need to word it better then.
    Have a nice day!
    Иди в пизду!
    Bonne journée!
    Einen schönen Tag noch!
    Hezký den!
    祝你今天愉快!
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 9
    Last Post: 01-15-2012, 02:28 AM
  2. Replies: 5
    Last Post: 06-10-2011, 07:46 PM
  3. [508/525] Bank Noting/Un noting
    By surreal in forum Requests
    Replies: 0
    Last Post: 12-05-2010, 08:27 PM
  4. Replies: 4
    Last Post: 10-03-2010, 12:54 AM
  5. Bank - Items in bank [Interface add on]
    By Dexter Morgan in forum Snippets
    Replies: 21
    Last Post: 11-17-2009, 06:35 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •