Thread: Skilling stuff

Results 1 to 5 of 5
  1. #1 Skilling stuff 
    Registered Member
    Join Date
    Apr 2013
    Posts
    102
    Thanks given
    5
    Thanks received
    3
    Rep Power
    11
    Ok, I have a question about delays. In my crafting, when I cut gems, it is on a loop, but how can I make it only cut one gem every 1.5 seconds? Here is my current code now, and this doesn't work. It will only cut 1 gem instead of the 27 it is supposed to. If I remove the "System.currentTimeMillis() part, it works fine, without the 1.5 second delay. What would the correct way of doing this be? Thanks in advance.
    Code:
    public void craftGem(int id, int slot) {
    		for (int j = 0; j < 28; j++) {
    			if (System.currentTimeMillis() - c.craftDelay < 1500) {
    			if (c.getItems().playerHasItem(id,1)) {
    				if (c.playerLevel[c.playerCrafting] >= craftingItems[slot][2]) {
    						c.getItems().deleteItem(id, c.getItems().getItemSlot(id), 1);
    						c.getItems().addItem(craftingItems[slot][1], 1);
    						c.getPA().addSkillXP(craftingItems[slot][3], c.playerCrafting);
    						c.craftDelay = System.currentTimeMillis();
    				} else {
    						c.sendMessage("You need a crafting level of " + craftingItems[slot][2] + " to craft this gem.");
    					break;
    				}
    			} else {
    				break;
    			}
    		}
    		}
    	}
    Reply With Quote  
     

  2. #2  
    Registered Member Mr Jason's Avatar
    Join Date
    Dec 2013
    Posts
    384
    Thanks given
    37
    Thanks received
    113
    Rep Power
    0
    Try this, haven't tested yet.

    Code:
    public void craftGem(int id, int slot) {
    	       for (int j = 0; j < 28; j++) {
    		        if(c.playerLevel[c.playerCrafting] >= craftingItems[slot][2]) {
    		            if(System.currentTimeMillis() - c.craftDelay < 1500) {
    			    c.getItems().deleteItem(id, c.getItems().getItemSlot(id), 1);
    	       		    c.getItems().addItem(craftingItems[slot][1], 1);
    			    c.getPA().addSkillXP(craftingItems[slot][3], c.playerCrafting);
    			    c.craftDelay = System.currentTimeMillis();
    			    }
    		         } else {
    			    c.sendMessage("You need a crafting level of " + craftingItems[slot][2] + " to craft this gem.");
    			}
    		}
    	}
    What I've done is placed the delay below the level requirement, I think it should work now.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Apr 2013
    Posts
    102
    Thanks given
    5
    Thanks received
    3
    Rep Power
    11
    Thanks for your help, however the same thing happened as before, there is no delay it just cuts one gem into a cut gem.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    28
    Posts
    4,421
    Thanks given
    891
    Thanks received
    1,527
    Rep Power
    3285
    I think what you're referring to is the use of events. In your source you probably already have some sort of eventmanager, cycleevents. Look through some previous code to perhaps get an idea.
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Apr 2013
    Posts
    102
    Thanks given
    5
    Thanks received
    3
    Rep Power
    11
    I have cycle events, but how can I use an event to make it so it only crafts 1 gem every 1.5 seconds? I have no idea how to go about starting that.
    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: 03-28-2010, 11:34 AM
  2. Offical skill cape stuff
    By tben2004 in forum Tutorials
    Replies: 18
    Last Post: 12-09-2007, 08:18 PM
  3. Replies: 2
    Last Post: 09-01-2007, 08:34 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
  •