Thread: Delay after clicking on object

Results 1 to 3 of 3
  1. #1 Delay after clicking on object 
    Registered Member
    Join Date
    Jun 2016
    Posts
    163
    Thanks given
    9
    Thanks received
    11
    Rep Power
    15
    Help a dude over here yo! Whenever i spammclick on the object, my inv explodes with items. I want a delay for 5 seconds until you can click on it again. I have tried this out: https://www.rune-server.ee/runescape...ck-object.html
    but it did not help. I have tried many other methods but cant get it right. This is how my code looks like right now after so many editing n balling around;


    player.animate(new Animation(832));
    long objectDelay = 0;
    if (System.currentTimeMillis() - objectDelay > 5000) {
    objectDelay = System.currentTimeMillis();
    System.out.println("object delay!");
    } else {
    player.send(new SendMessage("Wait 5 seconds.."));
    }
    chestLoot(player);
    //return;
    /* World.schedule(new Task(3) {
    @Override
    public void execute() {
    chestLoot(player);
    cancel();
    }
    });*/
    return;

    Am I missing anything? I would appreciate every single help! Thanks in advance
    Attached image
    Reply With Quote  
     

  2. #2  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    You can't have the variable objectDelay in the same method; it's always going to be zero, meaning the first if-sentence will always be true. You have to save the System.currentTimeMillis() variable on the player's character and compare it then. Additionally you're missing returns.
    Attached image
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    Join Date
    Jun 2016
    Posts
    163
    Thanks given
    9
    Thanks received
    11
    Rep Power
    15
    Quote Originally Posted by Kris View Post
    You can't have the variable objectDelay in the same method; it's always going to be zero, meaning the first if-sentence will always be true. You have to save the System.currentTimeMillis() variable on the player's character and compare it then. Additionally you're missing returns.
    wow it worked! thanks for the explanation, repped+++

    edit: i was your 400 thank giver
    Attached image
    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: 0
    Last Post: 04-26-2010, 09:39 PM
  2. Replies: 2
    Last Post: 03-25-2010, 09:12 AM
  3. Replies: 1
    Last Post: 08-16-2009, 06:55 PM
  4. Get Experience when click on Object
    By rb0opkz in forum Requests
    Replies: 5
    Last Post: 08-16-2009, 03:46 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
  •