Thread: PickUp not working

Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16
  1. #11  
    Banned

    Join Date
    Jun 2010
    Age
    23
    Posts
    4,832
    Thanks given
    1,673
    Thanks received
    1,558
    Rep Power
    0
    Quote Originally Posted by gilbo184 View Post
    Nope, once i log in, I can pick the item up once, and then not again.



    globalDrops is just a list of all the global drops. So a file called globalDrops.txt loads in the global drops. Region updating does work.

    I think I may have an issue with understanding the true difference between the ItemHandler and the GlobalDropHandler. This is the load method for changing regions in my GlobalDropHandler.

    Code:
    /**
    	 * Loads all the items when a player changes region
    	 * 
    	 * @[Only registered and activated users can see links. ] client
    	 *            the client
    	 */
    	public static void load(Client client) {
    		for (GlobalDrop drop : globalDrops) {
    			if (!drop.isTaken()) {
    				if (client.distanceToPoint(drop.getX(), drop.getY()) <= 60) {
    					client.getActionSender().createGroundItem(drop.getId(), drop.getX(), drop.getY(), drop.getAmount(), drop.getH());
    				}
    			}
    		}
    	}


    No that I am aware of. There is no errors printing, only that the item remains on the ground even though its been added to my inventory
    Sounds like it's not sending the packet to the client correctly.
    Reply With Quote  
     

  2. #12  
    Registered Member
    Join Date
    Apr 2013
    Posts
    50
    Thanks given
    2
    Thanks received
    1
    Rep Power
    11
    Quote Originally Posted by Tyluur View Post
    Sounds like it's not sending the packet to the client correctly.
    Can you confirm that I am doing this in the correct class.

    I have an itemHandler and GlobalDropsHandler class, which both really do the same thing. I'm assuming that itemHandler would be more for when I drop items or anything that isnt a tick bases such as if a player drops it and other players cant see etc.

    GlobalDropsHandler is more dealing with the global drops, and when it is removed, it needs to respawn.
    Reply With Quote  
     

  3. #13  
    Banned

    Join Date
    Jun 2010
    Age
    23
    Posts
    4,832
    Thanks given
    1,673
    Thanks received
    1,558
    Rep Power
    0
    Quote Originally Posted by gilbo184 View Post
    Can you confirm that I am doing this in the correct class.

    I have an itemHandler and GlobalDropsHandler class, which both really do the same thing. I'm assuming that itemHandler would be more for when I drop items or anything that isnt a tick bases such as if a player drops it and other players cant see etc.

    GlobalDropsHandler is more dealing with the global drops, and when it is removed, it needs to respawn.
    I'd do some debugging if i were you
    Reply With Quote  
     

  4. #14  
    Registered Member
    Join Date
    Apr 2013
    Posts
    50
    Thanks given
    2
    Thanks received
    1
    Rep Power
    11
    Quote Originally Posted by Tyluur View Post
    I'd do some debugging if i were you
    I have been doing some debugging. I have found that everything works fine. For example I was testing createGroundItem, and when an item is dropped it begins the tick timer for other players to see etc and the item is added to the item list which is called every game tick. However, the item doesnt appear when i drop it. So this leads to the ActionSender. Does this look correct?

    Code:
    public ActionSender createGroundItem(int itemID, int itemX, int itemY, int itemAmount, int height) {
    		if (player.heightLevel != height) {
    			return this;
    		}
    		player.getOutStream().createFrame(85);
    		player.getOutStream().writeByteC(itemY - 8 * player.mapRegionY);
    		player.getOutStream().writeByteC(itemX - 8 * player.mapRegionX);
    		player.getOutStream().createFrame(44);
    		player.getOutStream().writeWordBigEndianA(itemID);
    		player.getOutStream().writeWord(itemAmount);
    		player.getOutStream().writeByte(height);
    		player.flushOutStream();
    		return this;
    	}
    Reply With Quote  
     

  5. #15  
    Banned

    Join Date
    Jun 2010
    Age
    23
    Posts
    4,832
    Thanks given
    1,673
    Thanks received
    1,558
    Rep Power
    0
    Quote Originally Posted by gilbo184 View Post
    I have been doing some debugging. I have found that everything works fine. For example I was testing createGroundItem, and when an item is dropped it begins the tick timer for other players to see etc and the item is added to the item list which is called every game tick. However, the item doesnt appear when i drop it. So this leads to the ActionSender. Does this look correct?

    Code:
    public ActionSender createGroundItem(int itemID, int itemX, int itemY, int itemAmount, int height) {
    		if (player.heightLevel != height) {
    			return this;
    		}
    		player.getOutStream().createFrame(85);
    		player.getOutStream().writeByteC(itemY - 8 * player.mapRegionY);
    		player.getOutStream().writeByteC(itemX - 8 * player.mapRegionX);
    		player.getOutStream().createFrame(44);
    		player.getOutStream().writeWordBigEndianA(itemID);
    		player.getOutStream().writeWord(itemAmount);
    		player.getOutStream().writeByte(height);
    		player.flushOutStream();
    		return this;
    	}
    I don't know the packet structure - use some breakpoints to see where it fails.
    Reply With Quote  
     

  6. #16  
    Registered Member
    Join Date
    Apr 2013
    Posts
    50
    Thanks given
    2
    Thanks received
    1
    Rep Power
    11
    Quote Originally Posted by Tyluur View Post
    I don't know the packet structure - use some breakpoints to see where it fails.
    After some more debugging, items that i drop appear on the ground, and items i pick up are removed from hte ground (only the dropped ones). I think there is an issue with loading the global drops because they all appear in 2's, instead of 1. This is how it is intialised on load up:

    Code:
    	/**
    	 * loads the items
    	 */
    	public static void initialize() {
    		String Data;
    		BufferedReader Checker;
    		try {
    			Checker = new BufferedReader(new FileReader(
    					"./Data/cfg/globaldrops.txt"));
    			while ((Data = Checker.readLine()) != null) {
    				if (Data.startsWith("#")) {
    					continue;
    				}
    				String[] args = Data.split(":");
    				getGlobalDrops().add(new GlobalDrop(Integer.parseInt(args[0]), // id
    											   Integer.parseInt(args[1]), //amount
    											   Integer.parseInt(args[2]), //x
    											   Integer.parseInt(args[3]), //y
    											   Integer.parseInt(args[4]))); //height
    			}
    			Checker.close();
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    		Misc.println("Loaded " + getGlobalDrops().size() + " global drops.");
    
    	for (Player player : PlayerHandler.players) {
    		final Client client = (Client) player;
    		if (client != null) {
    		   CycleEventHandler.getSingleton().addEvent(client, new CycleEvent() {
    	            @Override
    	            public void execute(CycleEventContainer container) {
    				for (GlobalDrop drop : getGlobalDrops()) {
    					if (drop.isTaken()) {
    						if (System.currentTimeMillis() - drop.getTakenAt() >= TIME_TO_RESPAWN * 1000) {
    							drop.setTaken(false);
    								if (client.distanceToPoint(drop.getX(), drop.getY()) <= 60) {
    									System.out.println(drop.getId());
    									client.getActionSender().createGroundItem(drop.getId(), drop.getX(), drop.getY(), drop.getH(),drop.getAmount());
    								}
    							}
    						}
    					}
    				}
    	            @Override
    				public void stop() {
    					// TODO Auto-generated method stub
    				}
    				}, 1);
    			}
    		}
    	}
    Reply With Quote  
     

Page 2 of 2 FirstFirst 12

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. Client not working for You? READ!
    By Edge in forum Tutorials
    Replies: 59
    Last Post: 02-06-2020, 09:27 AM
  2. ::Pickup (not working??)
    By The Afterlife in forum Help
    Replies: 0
    Last Post: 12-18-2012, 01:34 PM
  3. [Delta] Pickup not working? [Delta]
    By Jmk600 in forum Help
    Replies: 11
    Last Post: 04-25-2011, 02:36 PM
  4. Soulsplit Pickup/Drop not working.
    By jameskmonger in forum Help
    Replies: 4
    Last Post: 12-01-2010, 06:48 PM
  5. Replies: 17
    Last Post: 11-30-2007, 04:15 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •