Thread: Apollo click object

Results 1 to 1 of 1
  1. #1 Apollo click object 
    Registered Member
    Join Date
    Jul 2016
    Posts
    69
    Thanks given
    8
    Thanks received
    17
    Rep Power
    64
    Hi everyone, I would love some help with this issue I am having.
    On Apollo I have this ObjectActionEventHandler class
    Code:
    /**
     * An event handler which broadcasts public chat messages.
     * 
     * @author Graham
     */
    public final class ObjectActionEventHandler extends EventHandler<ObjectActionEvent> {
    
    	@Override
    	public void handle(EventHandlerContext ctx, Player player, ObjectActionEvent event) {
    		StaticObject obj = World.getWorld().getObject(event.getId(), new Position(event.getPosition().getX(), event.getPosition().getY(), player.getPosition().getHeight()));
    		if(obj == null){
    			player.sendMessage("Invalid object!");
    			return;
    		}
                    int offX = player.getLastKnownRegion().getTopLeftSectorX() * 8;
                    int offY = player.getLastKnownRegion().getTopLeftSectorY() * 8;
    		boolean reached = PathFinder.findRoute(player, event.getPosition().getX(), event.getPosition().getY(), true, 1, obj);
    		if (player.getWalkingQueue().size() > 0) player.send(new MinimapFlagEvent(player.getDestination().getX() - offX, player.getDestination().getY() - offY)); else player.send(new MinimapFlagEvent(player.getPosition().getX() - offX, player.getPosition().getY() - offY));
    		player.sendMessage("Object Option " + event.getOption() + " for ID: " + event.getId() + ", [" + event.getPosition().getX() + ", " + event.getPosition().getY() + ", " + player.getPosition().getHeight() + "], Reached: " + reached);
    		// I would like this action to happen once I'm in front of the specified object.
    		switch (event.getId()) {
    		case 11744:
    			player.openBank();
    			break;
    		}
    	}
    
    }
    Does anyone know which method I have to use to check whether I'm infront of the object? I tried to do it with a while loop like this:
    Code:
    while(player.getWalkingQueue().size() == 0) {
    // Open bank or do w/e you want here.
    }
    and put that while loop in a new Runnable (thread)
    However this way seems super inconvenient, I think there is some kind of method for this but I can't find out.
    Thanks in advance.

    Edit: N.v.m. I already found it out. I had to add some methods in Player and in PlayerSynchronizationTask.
    Last edited by BertJan0; 10-25-2016 at 12:04 PM. Reason: I found it out already.
    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. [Help] Clicking object [help]
    By Mocro in forum Help
    Replies: 6
    Last Post: 10-28-2008, 02:33 PM
  2. Replies: 2
    Last Post: 10-03-2008, 10:37 AM
  3. [474][TUT] First Click Object [Packet 31][TUT]
    By noobbjorn999 in forum Tutorials
    Replies: 3
    Last Post: 07-11-2008, 09:00 AM
  4. [RS2D] First click object
    By Zachyboo in forum Tutorials
    Replies: 27
    Last Post: 06-12-2008, 06:50 PM
  5. Clicked Object Makes NPC Dialouge
    By Seven Lives in forum Tutorials
    Replies: 3
    Last Post: 03-23-2008, 04:58 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
  •