Thread: Faster Item Clicking into an Item Container

Results 1 to 7 of 7
  1. #1 Faster Item Clicking into an Item Container 
    Registered Member
    Join Date
    Nov 2015
    Posts
    83
    Thanks given
    9
    Thanks received
    21
    Rep Power
    30
    So I've recently coded the Pack Yak BoB feature to be able to store and remove items from that storage interface.

    The storing works just fine; however, if someone clicks faster enough on an item inside of the interface, it will add it to the player's inventory multiple times before the item is removed from that interface. I think the issue is with the delay from the interface to the player's inventory interface, and I'm not sure how to speed that up, or create a work around in my code to make sure that only one item leaves the Bob interface, and 1 item enters the player's inventory.

    Any advice would be appreciated.

    The example of what it is doing is below.

    Attached image

    Thanks.
    Reply With Quote  
     

  2. #2  
    Donator


    Join Date
    Jul 2011
    Posts
    570
    Thanks given
    135
    Thanks received
    142
    Rep Power
    291
    Quote Originally Posted by mt851 View Post
    So I've recently coded the Pack Yak BoB feature to be able to store and remove items from that storage interface.
    Well it all depends on how Items are handled in general as well as your checks. The source I work with checks this by having the remove method as a boolean. E.g.

    if (player.getInventory().remove(item)) {
    //do stuff
    }

    If your code doesnt have a check like that you need to add one yourself or see how other interfaces, such as banking, handles checks.
    Reply With Quote  
     

  3. #3  
    Respected Member


    Join Date
    Jul 2015
    Posts
    781
    Thanks given
    206
    Thanks received
    394
    Rep Power
    524
    Before it adds the item to the players inventory, put in a check to see if the item is actually still in the container.
    Reply With Quote  
     

  4. #4 Is this an okay solution? 
    Registered Member
    Join Date
    Nov 2015
    Posts
    83
    Thanks given
    9
    Thanks received
    21
    Rep Power
    30
    Quote Originally Posted by Empathy View Post
    Well it all depends on how Items are handled in general as well as your checks. The source I work with checks this by having the remove method as a boolean. E.g.

    if (player.getInventory().remove(item)) {
    //do stuff
    }

    If your code doesnt have a check like that you need to add one yourself or see how other interfaces, such as banking, handles checks.
    Quote Originally Posted by .Mayhem. View Post
    Before it adds the item to the players inventory, put in a check to see if the item is actually still in the container.
    Thank you both for your feedback. I ended up using an EventManager delay system like this:

    Code:
    		EventManager.getSingleton().addEvent(new Event() {
    			Client self = editor;
    			public void execute(EventContainer c) {
    				editor.clickCount = 0;
    				editor.clickedBob = false;
    				c.stop();
    			}
    		}, 500);
    With a conditional at the top of the add/remove item from BoB function like this:

    Code:
    if(editor.clickedBob == true && editor.clickCount == 1) return;
    With the idea that the clickCount will be set to 0 after 500 milliseconds, and any clicks made to the item in the container will not be registered until that 500 millisecond time period goes by, essentially guaranteeing it has been removed from the container.

    Do you think this is an okay solution?

    Below is the working version:

    Attached image
    Reply With Quote  
     

  5. #5  
    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 mt851 View Post
    Thank you both for your feedback. I ended up using an EventManager delay system like this:

    Code:
    		EventManager.getSingleton().addEvent(new Event() {
    			Client self = editor;
    			public void execute(EventContainer c) {
    				editor.clickCount = 0;
    				editor.clickedBob = false;
    				c.stop();
    			}
    		}, 500);
    With a conditional at the top of the add/remove item from BoB function like this:

    Code:
    if(editor.clickedBob == true && editor.clickCount == 1) return;
    With the idea that the clickCount will be set to 0 after 500 milliseconds, and any clicks made to the item in the container will not be registered until that 500 millisecond time period goes by, essentially guaranteeing it has been removed from the container.

    Do you think this is an okay solution?

    Below is the working version:

    Attached image
    Because why fix it properly, much easier, when you can cheapfix it the hard way?

    Smh. Just add a check for the item..
    if (player.getFamiliar().getBOB().containsItem(id, amount ?, slot?)
    remove + add;

    You ain't gotta overcomplicate this shit. Also this is why I hate all the released 317s. They're coded so damn terribly that even the simplest of actions have long ass delays before they get processed..
    Reply With Quote  
     

  6. #6  
    Respected Member


    Join Date
    Jul 2015
    Posts
    781
    Thanks given
    206
    Thanks received
    394
    Rep Power
    524
    Quote Originally Posted by mt851 View Post
    cheaphax
    no. just do your checks properly and remove the item, you'll be fine without over complicating this.
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Nov 2015
    Posts
    83
    Thanks given
    9
    Thanks received
    21
    Rep Power
    30
    Quote Originally Posted by Eldritch View Post
    Because why fix it properly, much easier, when you can cheapfix it the hard way?

    Smh. Just add a check for the item..
    if (player.getFamiliar().getBOB().containsItem(id, amount ?, slot?)
    remove + add;

    You ain't gotta overcomplicate this shit. Also this is why I hate all the released 317s. They're coded so damn terribly that even the simplest of actions have long ass delays before they get processed..
    As much as I hate your decision to help + flame at the same time, you are right, and I should have done that. I've fixed it accordingly and it works now. Thank you for your help.
    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: 3
    Last Post: 01-05-2013, 01:29 AM
  2. Replies: 3
    Last Post: 11-06-2011, 03:06 AM
  3. how to make an item usable on an object
    By OodlesOfNoodles in forum Help
    Replies: 4
    Last Post: 08-03-2011, 05:39 PM
  4. Replies: 5
    Last Post: 10-06-2009, 08:25 AM
  5. Anyone have an item editer? (for custom items)
    By araf5 in forum RS2 Client
    Replies: 2
    Last Post: 06-12-2008, 08:18 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
  •