Thread: [PI] Fletching, Please Explain

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 [PI] Fletching, Please Explain 
    Banned

    Join Date
    Oct 2009
    Posts
    734
    Thanks given
    168
    Thanks received
    54
    Rep Power
    0
    Code:
    package server.model.players.skills;
    
    import server.model.players.Client;
    import server.event.*;
     
    public class Fletching extends SkillHandler {
    
    	private static final int[][] ITEM_ON_ITEM = {
    		{52,314,53,1,1}, 	{53,39,882,3,1},
    		{53,40,884,4,15}, 	{53,41,886,6,30},
    		{53,42,888,8,45}, 	{53,43,890,11,60},
    		{53,44,892,14,75}, 	{53,11237,11212,16,90},
    		{314,819,806,2, 1}, 	{314,820,807,4,22},
    		{314,821,808,8,37}, 	{314,822,809,11,52},
    		{314,823,810,15,67}, 	{314,824,811,19,81},
    		{314,11232,11230,25,95},
    	};
    
    	public static boolean arrows(Client c, int item1, int item2) {
    		for(int i = 0; i < ITEM_ON_ITEM.length; i++) {
    			if((item1 == ITEM_ON_ITEM[i][0] || item1 == ITEM_ON_ITEM[i][1]) &&
    				(item2 == ITEM_ON_ITEM[i][1] || item2 == ITEM_ON_ITEM[i][0])) {
    				return true;
    			}
    		}
    		return false;
    	}
    
    	public static void makeArrows(Client c, int item1, int item2) {
    		for (int j = 0; j < ITEM_ON_ITEM.length; j++) {
    			if ((item1 == ITEM_ON_ITEM[j][0] && item2 == ITEM_ON_ITEM[j][1]) 
    					|| (item2 == ITEM_ON_ITEM[j][0] && item1 == ITEM_ON_ITEM[j][1])) {
    
    				if(!hasRequiredLevel(c, c.playerFletching, ITEM_ON_ITEM[j][4], "fletching", 
    					"make "+c.getItems().getItemName(ITEM_ON_ITEM[j][2])+"")) {
    					return;
    				}
    
    				if(!noInventorySpace(c, "fletching")) {
    					return;
    				}
    				int amount1 = c.getItems().getItemAmount(item1);
    				int amount2 = c.getItems().getItemAmount(item2);
    				int otherAmount = 0;
    				if(amount1 >= 15) {
    					amount1 = 15;
    				}
    				if(amount2 >= 15) {
    					amount2 = 15;
    				}
    				if(amount1 > amount2) {
    					otherAmount = amount1 - amount2;
    					amount1 = amount1 - otherAmount;
    				} else if(amount2 > amount1) {
    					otherAmount = amount2 - amount1;
    					amount2 = amount2 - otherAmount;
    				}
    				int xp = 0;
    				if(amount1 >= amount2) {
    					xp = amount1;
    				} else {
    					xp = amount2;
    				}
    				if (c.getItems().playerHasItem(item1, amount1) && c.getItems().playerHasItem(item2,amount2)) {
    					c.getItems().deleteItem(item1, c.getItems().getItemSlot(item1), amount1);
    					c.getItems().deleteItem(item2, c.getItems().getItemSlot(item2), amount2);
    					c.getItems().addItem(ITEM_ON_ITEM[j][2], amount1);
    					c.getPA().addSkillXP((ITEM_ON_ITEM[j][3] * xp) * FLETCHING_XP, c.playerFletching);
    				}
    			}	
    		}	
    	}
    
    	public static void normal(Client c, int itemUsed, int useWith) {
    		if((itemUsed == 946 && useWith == 1511) || (itemUsed == 1151 && useWith == 946)) {
    			showInterfaceFletching(c, new int[] { 841, 839, 52 }, 0);
    		}
    	}
    
    	public static void others(Client c, int itemUsed, int useWith) {
    		for(int i = 0; i < DATA.length; i++) {
    			if((itemUsed == 946 && useWith == DATA[i][0]) || (itemUsed == DATA[i][0] && useWith == 946)) {
    				showInterfaceOthers(c, new int[] { DATA[i][1], DATA[i][4], }, DATA[i][7]);
    			}
    		}
    	}
    
    	private static final int[][] DATA = {
    		{1521, 843, 20, 17, 845, 25, 25, 0},
    		{1519, 849, 35, 33, 847, 40, 41, 1},
    		{1517, 853, 50, 50, 851, 55, 58, 2},
    		{1515, 857, 65, 68, 855, 70, 75, 3},
    		{1513, 861, 80, 83, 859, 85, 91, 4},
    	};
    
    	private static void showInterfaceOthers(Client c, int[] items, int type) {
    		for(int i = 0; i < DATA.length; i++) {
    			if(type == DATA[i][7]) {
    				for(int l = 0; l < DATA.length; l++) {
    					c.playerSkillProp[9][l] = DATA[i][l];
    				}
    			}
    		}
    		c.getPA().sendFrame164(8866);
    		c.getPA().sendFrame246(8869, 190, items[0]);
         		c.getPA().sendFrame246(8870, 190, items[1]);
         		c.getPA().sendFrame126(""+c.getItems().getItemName(items[0])+"", 8874);
         		c.getPA().sendFrame126(""+c.getItems().getItemName(items[1])+"", 8878);
    	}
    
    	private static void showInterfaceFletching(Client c, int[] items, int type) {
    		c.getPA().sendFrame164(8880);
    		c.getPA().sendFrame126("What would you like to make?", 8879);
    		c.getPA().sendFrame246(8884, 190, items[0]);
         		c.getPA().sendFrame246(8883, 190, items[1]);
         		c.getPA().sendFrame246(8885, 190, items[2]);
         		c.getPA().sendFrame126(""+c.getItems().getItemName(items[1])+"", 8889);
         		c.getPA().sendFrame126(""+c.getItems().getItemName(items[0])+"", 8893);
    		c.getPA().sendFrame126(""+c.getItems().getItemName(items[2])+"", 8897);
    		c.playerFletch = true;
    	}
    
    	public static int[][] normal = {
    		{1511, 841, 839, 50, 1, 0, 6684, 52},
    	};
    
    	public static void attemptData(Client c, int amount, int type) {
    		c.playerSkillProp[9][0] = normal[0][0];	//LOG
    		int[][] i = { {841, 5}, {839, 10}, {52, 1}, };
    		c.playerSkillProp[9][1] = i[type][0];
    		c.playerSkillProp[9][2] = i[type][1];
    		c.playerSkillProp[9][3] = i[type][1];
    		attemptData(c, amount, false);
    	}
    
    	public static void attemptData(final Client c, int amount, boolean second) {
    		if(!hasRequiredLevel(c, 9, c.playerSkillProp[9][2], "fletching", "fletch this")){
    			return;
    		}
    		int item = c.getItems().getItemAmount(c.playerSkillProp[9][0]);
    		if(amount > item) {
    			amount = item;
    		}
    		c.doAmount = amount;
    		if(c.playerSkilling[9]) {
    			return;
    		}
    		c.playerSkilling[9] = true;
    		c.stopPlayerSkill = true;
    		c.getPA().removeAllWindows();
    
    		final int itemToDelete = c.playerSkillProp[9][0];
    
    		final int addItem = second ? c.playerSkillProp[9][4] : c.playerSkillProp[9][1];
    		final int addXP = (second ? c.playerSkillProp[9][6] : c.playerSkillProp[9][3]) * FLETCHING_XP;
    
    		c.startAnimation(6702);
    		CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
    			@Override
    			public void execute(CycleEventContainer container) {
    				if(c.playerSkillProp[9][0] > 0) {
    					c.getItems().deleteItem(itemToDelete, c.getItems().getItemSlot(itemToDelete), 1);
    					c.getItems().addItem(addItem, c.playerSkillProp[9][1] == 52 ? 15 : 1);
    					c.sendMessage("You make a "+ c.getItems().getItemName(addItem).toLowerCase() +".");
    					c.getPA().addSkillXP(addXP, 9);
    				}
    				c.startAnimation(6702);
    				deleteTime(c);
    				if(!c.getItems().playerHasItem(c.playerSkillProp[9][0], 1) || c.doAmount <= 0) {
    					resetFletching(c);
    					container.stop();
    				}
    				if(!c.stopPlayerSkill) {
    					resetFletching(c);
    					container.stop();
    				}
    			}
    			@Override
    			public void stop() {
    
    			}
    		}, 2);
    	}
    
    	public static void resetFletching(Client c) {
    		c.playerSkilling[9] = false;
    		c.stopPlayerSkill = false;
    		c.playerFletch = false;
    		for(int i = 0; i < 9; i++) {
    			c.playerSkillProp[9][i] = -1;
    		}
    		c.startAnimation(65535);
    	}
    }
    So I added this amazing fletching system (no errors) but only normal logs are fletchable. So my question is how/where do I add new logs. Atm when I use a knife on my logs the interface DOES show up, but when you click it/right click it, it doesn't fletch anything except for normal logs. I'm pretty sure I added all of the actionbuttons correctly as well (some of them where missing from the tut I followed), here's my actionbuttons for fletching:

    Code:
    			case 34185:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 1, 0);
    				} else {
    
    				}
    				break;
    			case 34184:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 5, 0);
    				} else {
    
    				}
    				break;
    			case 34183:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 10, 0);
    				} else {
    
    				}
    				break;
    			case 34182:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 28, 0);
    				} else {
    
    				}
    				break;
    			case 34189: 
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 1, 1);
    				} else {
    
    				}
    				break;
    			case 34188: 
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 5, 1);
    				} else {
    
    				}
    				break;
    			case 34187: 
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 10, 1);
    				} else {
    
    				}
    				break;
    			case 34186: 
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 28, 1);
    				} else {
    
    				}
    				break;
    			case 34193:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 1, 2);
    				} else {
    
    				}
    				break;
    			case 34192:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 5, 2);
    				} else {
    
    				}
    				break;
    			case 34191:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 10, 2);
    				} else {
    
    				}
    				break;
    			case 34190:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 28, 2);
    				} else {
    
    				}
    				break;
    			case 34170:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 1, 0);
    				} else {
    				
    				}
    				break;
    			case 34169:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 5, 0);
    				} else {
    				
    				}
    				break;
    			case 34168:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 10, 0);
    				} else {
    				
    				}
    				break;
    			case 34167:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 28, 0);
    				} else {
    				
    				}
    				break;
    			case 34174:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 1, 1);
    				} else {
    				
    				}
    				break;
    			case 34173:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 5, 1);
    				} else {
    				
    				}
    				break;
    			case 34172:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 10, 1);
    				} else {
    				
    				}
    				break;
    			case 34171:
    				if(c.playerFletch) {
    					Fletching.attemptData(c, 28, 1);
    				} else {
    				
    				}
    				break;
    I will rep and thank any helpful posts on this thread.
    Reply With Quote  
     

  2. #2  
    ~! Legit ~!

    Join Date
    Nov 2010
    Posts
    1,973
    Thanks given
    183
    Thanks received
    211
    Rep Power
    237
    ive had the same problem lol, wat source u using?
    [Only registered and activated users can see links. ]
    Spoiler for My Vouches:
    Quote Originally Posted by mattsforeal View Post
    I paid $5 went first, he fixed my problem and it worked. 100% legit would do it again.
    Quote Originally Posted by Mythic View Post
    Vouch for him, very smooth and fast trade, purchased his last 4m. Have fun with your new membership
    Quote Originally Posted by Harlan View Post
    Vouch, trustworthy guy.
    Quote Originally Posted by iPhisher™ View Post
    Vouch for Super-Man, he is a very legit and trustable guy.
    Reply With Quote  
     

  3. #3  
    Registered Member Technooo's Avatar
    Join Date
    Mar 2010
    Posts
    200
    Thanks given
    33
    Thanks received
    10
    Rep Power
    39
    itemonitem.java
    Reply With Quote  
     

  4. Thankful user:


  5. #4  
    Banned

    Join Date
    Oct 2009
    Posts
    734
    Thanks given
    168
    Thanks received
    54
    Rep Power
    0
    Quote Originally Posted by Coder Kieran View Post
    itemonitem.java
    Thanks but explain?


    Code:
    if((useWith == 1511 || itemUsed == 1511) && (useWith == 946 || itemUsed == 946)) {
    			Fletching.normal(c, itemUsed, useWith);
    		} else if(useWith == 946 || itemUsed == 946) {
    			Fletching.others(c, itemUsed, useWith);
    		} else if(Fletching.arrows(c, itemUsed, useWith)) {
    			Fletching.makeArrows(c, itemUsed, useWith);
    }
    Reply With Quote  
     

  6. #5  
    Donator


    Join Date
    Jun 2011
    Posts
    2,555
    Thanks given
    539
    Thanks received
    402
    Rep Power
    658
    itemonitem.java
    Reply With Quote  
     

  7. Thankful user:


  8. #6  
    The One And Only

    01053's Avatar
    Join Date
    Apr 2011
    Age
    25
    Posts
    2,888
    Thanks given
    416
    Thanks received
    884
    Rep Power
    856
    Code:
    if((useWith == 1511 || itemUsed == 1511) && (useWith == 946 || itemUsed == 946)) {
    			Fletching.normal(c, itemUsed, useWith);
    		} else if(useWith == 946 || itemUsed == 946) {
    			Fletching.others(c, itemUsed, useWith);
    		} else if(Fletching.arrows(c, itemUsed, useWith)) {
    			Fletching.makeArrows(c, itemUsed, useWith);
    }
    That's why it only works for normal logs you have to do that for all the logs also not just 1511 which is Logs lol.


    Reply With Quote  
     

  9. Thankful user:


  10. #7  
    Banned

    Join Date
    Oct 2009
    Posts
    734
    Thanks given
    168
    Thanks received
    54
    Rep Power
    0
    Quote Originally Posted by 'Phantom View Post
    Code:
    if((useWith == 1511 || itemUsed == 1511) && (useWith == 946 || itemUsed == 946)) {
    			Fletching.normal(c, itemUsed, useWith);
    		} else if(useWith == 946 || itemUsed == 946) {
    			Fletching.others(c, itemUsed, useWith);
    		} else if(Fletching.arrows(c, itemUsed, useWith)) {
    			Fletching.makeArrows(c, itemUsed, useWith);
    }
    That's why it only works for normal logs you have to do that for all the logs also not just 1511 which is Logs lol.
    Yeah I tried that but it still didn't work for me

    Code:
     		if((useWith == 1511 || itemUsed == 1511) && (useWith == 946 || itemUsed == 946)) {
    			Fletching.normal(c, itemUsed, useWith);
    		} else if((useWith == 1521 || itemUsed == 1521) && (useWith == 946 || itemUsed == 946)) {
    			Fletching.others(c, itemUsed, useWith);
    		} else if(Fletching.arrows(c, itemUsed, useWith)) {
    			Fletching.makeArrows(c, itemUsed, useWith);
    1521 is oak logs and they don't fletch still.
    Reply With Quote  
     

  11. #8  
    Banned
    Join Date
    Aug 2011
    Posts
    16
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    Quote Originally Posted by anarchypk508 View Post
    bump
    Well, first off that tutorial by Dr House isn't very good. The code is terrible and i know that's the tut you used by reading your class.

    To fix this, i'd suggest double checking your action buttons as i just tested out his class and it worked fine for me.

    If still nothing, you must have missed a step.
    Reply With Quote  
     

  12. Thankful user:


  13. #9  
    Banned

    Join Date
    Oct 2009
    Posts
    734
    Thanks given
    168
    Thanks received
    54
    Rep Power
    0
    Quote Originally Posted by Sextacy View Post
    Well, first off that tutorial by Dr House isn't very good. The code is terrible and i know that's the tut you used by reading your class.

    To fix this, i'd suggest double checking your action buttons as i just tested out his class and it worked fine for me.

    If still nothing, you must have missed a step.
    I'm pretty sure I got the actionbuttons 100% right, I added them myself because the tut seemed to have missed some. I clicked each button to find the ID and added it accordingly as you can see in my OP.

    Also I'm not sure why I got an infraction for this thread, all of my bumps where about 24 hours apart. You can't honestly expect me to post exactly 24 hours apart, if I posted a bump after 17-20 hours that should be fine...
    Reply With Quote  
     

  14. #10  
    Registered Member
    Join Date
    Jun 2011
    Posts
    329
    Thanks given
    76
    Thanks received
    25
    Rep Power
    6
    Okay if you don't understand what I'm about to say, sorry but it's the easiest I can do

    I haven't dealt with this or even tried your code, or fletched on my server before, but I think you're going to have to make it so say you use normal logs on knife, it opens the same interface as if you use magic logs on knife, correct?

    Well I believe you're going to have to use a variable, say variable "woodType" and if it's normal you'd be like woodType=1;, but if magic, woodType=7; or something, you know?

    Then in the interface, clickingbutton for making a shortbow, it would check if woodType=1, you get normal, if woodType=7, you get magic.

    Hope that helps.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

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. explain this please
    By D-I-V-I-N-E in forum Help
    Replies: 9
    Last Post: 07-03-2010, 06:54 AM
  2. Can someone explain to me.
    By Soulzz in forum Help
    Replies: 2
    Last Post: 06-28-2009, 08:54 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
  •