Thread: Help With Some Noob Code Please

Results 1 to 6 of 6
  1. #1 Help With Some Noob Code Please 
    Jake from State Farm

    FKN Jake's Avatar
    Join Date
    Nov 2013
    Posts
    675
    Thanks given
    45
    Thanks received
    58
    Rep Power
    153
    I'm not very good at creating things from scratch.. I managed to get this code in eclipse without any errors but it doesn't work.

    I'm trying to make it so when you click on an NPC it will repair your degrading armours for a price.

    Code:
    package com.mpk.world.content;
    
    import com.mpk.model.Item;
    import com.mpk.world.entity.impl.player.Player;
    
    public enum RepairArmour {
    	DHAROKS_HELM(4880, 4716, 5000000);
    
     RepairArmour(int item, int NewItem, int Cost) {
    		this.item = item;
    		this.Cost = Cost;
    		this.item = NewItem;
     }
    
    	private int item;
    	private int Cost;
    	private boolean RepairArmour;
    
     
    	private RepairArmour(Player c) {
    		c.getPacketSender().sendInterfaceRemoval();
    		RepairArmour = false;
    		
    			if(c.getInventory().containsAny(item)) {
    				RepairArmour = true;
    
    		if(RepairArmour = true) {
    			for(Item item : c.getInventory().getValidItems()) {
    				c.getInventory().delete(item, 1);
    				c.getInventory().delete(995, Cost);
    				c.getInventory().add(item);
    				c.getInventory().refreshItems();
    				c.getPacketSender().sendMessage("You've repaired your armours.");
    
    	return;
    				}
    			}
    		}
    	}
    }
    Will Rep++, please don't flame it's my first code from scratch and I'd like to know what I did wrong.
    Reply With Quote  
     

  2. #2  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    What you did wrong: Not added a npc check for this method "RepairArmour". If you did make sure it's actually sending it correctly.


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  3. #3  
    Jake from State Farm

    FKN Jake's Avatar
    Join Date
    Nov 2013
    Posts
    675
    Thanks given
    45
    Thanks received
    58
    Rep Power
    153
    Quote Originally Posted by arch337 View Post
    What you did wrong: Not added a npc check for this method "RepairArmour". If you did make sure it's actually sending it correctly.
    For a different NPC that purchases artificacts, all there is for dialogue for him is

    Code:
    			case 10:
    				Artifacts.sellArtifacts(player);
    So I tried RepairArmour.RepairArmour(player);
    Reply With Quote  
     

  4. #4  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    Quote Originally Posted by Jc6689 View Post
    For a different NPC that purchases artificacts, all there is for dialogue for him is

    Code:
    			case 10:
    				Artifacts.sellArtifacts(player);
    So I tried RepairArmour.RepairArmour(player);
    Try this and tell me if something gets written out in the command prompt:
    Code:
    	private RepairArmour(Player c) {
            System.out.println("Worked?");
    		c.getPacketSender().sendInterfaceRemoval();
    		RepairArmour = false;
    		
    			if(c.getInventory().containsAny(item))
    				RepairArmour = true;
    
    		if(RepairArmour = true) {
    			for(Item item : c.getInventory().getValidItems()) {
    				c.getInventory().delete(item, 1);
    				c.getInventory().delete(995, Cost);
    				c.getInventory().add(item);
    				c.getInventory().refreshItems();
    				c.getPacketSender().sendMessage("You've repaired your armours.");
    				}
    			}
    		}


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  5. #5  
    Jake from State Farm

    FKN Jake's Avatar
    Join Date
    Nov 2013
    Posts
    675
    Thanks given
    45
    Thanks received
    58
    Rep Power
    153
    Quote Originally Posted by arch337 View Post
    Try this and tell me if something gets written out in the command prompt:
    Code:
    	private RepairArmour(Player c) {
            System.out.println("Worked?");
    		c.getPacketSender().sendInterfaceRemoval();
    		RepairArmour = false;
    		
    			if(c.getInventory().containsAny(item))
    				RepairArmour = true;
    
    		if(RepairArmour = true) {
    			for(Item item : c.getInventory().getValidItems()) {
    				c.getInventory().delete(item, 1);
    				c.getInventory().delete(995, Cost);
    				c.getInventory().add(item);
    				c.getInventory().refreshItems();
    				c.getPacketSender().sendMessage("You've repaired your armours.");
    				}
    			}
    		}
    Nothing in chatbox, in-game console, or server console :/
    Reply With Quote  
     

  6. #6  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    Quote Originally Posted by Jc6689 View Post
    Nothing in chatbox, in-game console, or server console :/
    Then it do not even send the code. Try and make it when you click talk on a npc it sends it. See if it says anything in the console.


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    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: 6
    Last Post: 01-08-2011, 11:56 AM
  2. [Need help with some npc coding]
    By babich in forum Help
    Replies: 1
    Last Post: 02-14-2010, 05:20 AM
  3. Replies: 0
    Last Post: 02-08-2010, 10:02 PM
  4. Replies: 4
    Last Post: 08-04-2009, 05:03 PM
  5. [Delta] Need help with some codes!
    By Dimitry in forum Help
    Replies: 2
    Last Post: 05-06-2009, 03:12 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
  •