Thread: PickUp not working

Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1 PickUp not working 
    Registered Member
    Join Date
    Apr 2013
    Posts
    50
    Thanks given
    2
    Thanks received
    1
    Rep Power
    11
    I'm a noob, sorry for all the questions.

    EDIT: I have been able to add the item to the player but the item on the ground still remains, and unable to pick up again (which is good as thats what its meant to do). However, I can't seem to
    remove the item after picking up

    GlobalDropsHandler.java

    Code:
    public static void pickup(Client client, int itemId, int itemX, int itemY, int itemH) {
    		GlobalDrop drop = itemExists(itemId, itemX, itemY, itemH);
    		if (drop == null) {
    			return;
    		}
    		if (drop.isTaken()) {
    			return;
    		}
    		drop.setTakenAt(System.currentTimeMillis());
    		drop.setTaken(true);
    		if (client.getItemAssistant().freeSlots() > 0) {
    			System.out.println("pick up item"); //This prints on first time i pick up the item, but not after (which means it works but the model remains)
    			client.getItemAssistant().addItem(drop.getId(), drop.getAmount());
    			client.getActionSender().removeGroundItem(drop.getId(), drop.getX(), drop.getY(), drop.getAmount(),drop.getH());
    			globalDrops.remove(drop);
    		}
    		for (Player player : PlayerHandler.players) {
    			Client cl = (Client) player;
    			if (cl != null) {
    				if (cl.distanceToPoint(drop.getX(), drop.getY()) <= 60) {
    					cl.getActionSender().removeGroundItem(drop.getId(), drop.getX(), drop.getY(), drop.getAmount(),drop.getH());
    				}
    			}
    		}
    	}

    In the PickUpItem.java

    Code:
    public class PickupItem implements PacketType {
    
    
    	@Override
    	public void processPacket(final Client player, int packetType, int packetSize) {
    		player.pItemY = player.getInStream().readSignedWordBigEndian();
    		player.pItemId = player.getInStream().readUnsignedWord();
    		player.pItemX = player.getInStream().readSignedWordBigEndian();
    		
    		System.out.println("Step 1 - start pick up packet");
    		GlobalDropsHandler.pickup(player, player.pItemId, player.pItemX, player.pItemY, player.heightLevel);

    Then in the ActionSender.java

    Code:
    	
    	public ActionSender removeGroundItem(int itemID, int itemX, int itemY, int Amount, int height) {
    		if (player == null) {
    			return this;
    		}
    		player.getOutStream().createFrame(85);
    		player.getOutStream().writeByteC(itemY - 8 * player.mapRegionY);
    		player.getOutStream().writeByteC(itemX - 8 * player.mapRegionX);
    		player.getOutStream().createFrame(156);
    		player.getOutStream().writeByteS(height);
    		player.getOutStream().writeWord(itemID);
    		player.flushOutStream();
    		return this;
    	}
    I've toiled away at this without much success. Any guidance would be appreciated.

    Thanks.
    Reply With Quote  
     

  2. #2  
    Donator


    Join Date
    Jul 2011
    Posts
    926
    Thanks given
    194
    Thanks received
    169
    Rep Power
    189
    I'm wondering how come you don't have item pickup handled already.

    Have you got the packet in place and is it being called?

    If so, then just keep adding printouts starting from the pickup packet and see how far it gets. This way you will find out where it fails.
    Code:
    System.out.println("Step 1");
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Apr 2013
    Posts
    50
    Thanks given
    2
    Thanks received
    1
    Rep Power
    11
    Quote Originally Posted by Blaketon View Post
    I'm wondering how come you don't have item pickup handled already.

    Have you got the packet in place and is it being called?

    If so, then just keep adding printouts starting from the pickup packet and see how far it gets. This way you will find out where it fails.
    Code:
    System.out.println("Step 1");
    When you say "already" what should I have? I thought thats what the itemhandler does, plus the globalitemshandler does.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Melvin's Avatar
    Join Date
    Aug 2011
    Posts
    976
    Thanks given
    472
    Thanks received
    291
    Rep Power
    883
    Code:
    	public static void pickup(Client client, int a, int b, int c, int d) {
    		GlobalDrop drop = itemExists(a, b, c, d); //Check whether it actually exists.
    please refactor this my god. Also, what is the exact issue im confused? Is it not going to the players inventory? Is it not disappearing from the ground?

    Code:
    		if (drop == null) {
    			return;
    		}
    		else {
    			System.out.println("Item Exists!"); //Test statement
    		}
    		if (drop.isTaken()) {  //If the drop is taken
    			return;
    		}
    this is also top tier


    A creative man is motivated by the desire to achieve, not by the desire to beat others.


    ― Ayn Rand
    Reply With Quote  
     

  5. #5  
    Registered Member
    Optimum's Avatar
    Join Date
    Apr 2012
    Posts
    3,520
    Thanks given
    829
    Thanks received
    1,574
    Rep Power
    5000
    it would be nice to NEVER name ur variables 1 letter long unless inside a for loop

    Quote Originally Posted by DownGrade View Post
    Don't let these no life creeps get to you, its always the same on here. They'd rather spend hours upon hours in the rune-server spam section then getting laid! ha ha!Its honestly pathetic i haven't seen so many lowlifes in my life its actually insane i wish that this section would just vanish its probably the only way to get these people out of the community...
    PLEASE BE AWARE OF IMPOSTERS MY DISCORD ID: 362240000760348683
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Apr 2013
    Posts
    50
    Thanks given
    2
    Thanks received
    1
    Rep Power
    11
    Quote Originally Posted by Melvin View Post
    Code:
    	public static void pickup(Client client, int a, int b, int c, int d) {
    		GlobalDrop drop = itemExists(a, b, c, d); //Check whether it actually exists.
    please refactor this my god. Also, what is the exact issue im confused? Is it not going to the players inventory? Is it not disappearing from the ground?

    Code:
    		if (drop == null) {
    			return;
    		}
    		else {
    			System.out.println("Item Exists!"); //Test statement
    		}
    		if (drop.isTaken()) {  //If the drop is taken
    			return;
    		}
    this is also top tier
    My bad I have edited the post. I have fixed some of the issues, but having problems with removing the item in game, even though the player has the item in the inventory after pick up

    Quote Originally Posted by Optimum View Post
    it would be nice to NEVER name ur variables 1 letter long unless inside a for loop
    I updated the thread
    Reply With Quote  
     

  7. #7  
    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
    My bad I have edited the post. I have fixed some of the issues, but having problems with removing the item in game, even though the player has the item in the inventory after pick up



    I updated the thread
    Is the player able to pick up the item more than once?
    Reply With Quote  
     

  8. #8  
    Donator


    Join Date
    Jul 2011
    Posts
    926
    Thanks given
    194
    Thanks received
    169
    Rep Power
    189
    Any errors client sided?
    Reply With Quote  
     

  9. #9  
    Registered Member
    Melvin's Avatar
    Join Date
    Aug 2011
    Posts
    976
    Thanks given
    472
    Thanks received
    291
    Rep Power
    883
    Quote Originally Posted by gilbo184 View Post
    My bad I have edited the post. I have fixed some of the issues, but having problems with removing the item in game, even though the player has the item in the inventory after pick up



    I updated the thread
    thanks, the constructor could also just be Item item, and then below just do (item.getId(), item.getX(), item.getY(), item.getHeight())

    Code:
    globalDrops.remove(drop);
    check this, its not removing from the region. No idea what globalDrops is, but probably a list used in your region class.


    A creative man is motivated by the desire to achieve, not by the desire to beat others.


    ― Ayn Rand
    Reply With Quote  
     

  10. #10  
    Registered Member
    Join Date
    Apr 2013
    Posts
    50
    Thanks given
    2
    Thanks received
    1
    Rep Power
    11
    Quote Originally Posted by Tyluur View Post
    Is the player able to pick up the item more than once?
    Nope, once i log in, I can pick the item up once, and then not again.

    Quote Originally Posted by Melvin View Post
    thanks, the constructor could also just be Item item, and then below just do (item.getId(), item.getX(), item.getY(), item.getHeight())

    Code:
    globalDrops.remove(drop);
    check this, its not removing from the region. No idea what globalDrops is, but probably a list used in your region class.
    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());
    				}
    			}
    		}
    	}
    Quote Originally Posted by Blaketon View Post
    Any errors client sided?
    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
    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. 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
  •