Thread: Player location (PI) - easily converted.

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1 Player location (PI) - easily converted. 
    Registered Member

    Join Date
    May 2012
    Posts
    253
    Thanks given
    5
    Thanks received
    146
    Rep Power
    122
    This basically tells a player where another player is located (for administration use and general player purpose use). This will go nicely with an interface (Owner is at Edgeville) - for now I've just used the 'sendStatement' method, along with the 'sendMessage' method.
    This is not a location/regional system.

    Create a new class called LocationHandler.java, add this in it:

    Code:
    package rs2.model.content;
    
    import rs2.model.players.Client;
    import rs2.model.players.Player;
    
    /**
     * 
     * @author Rhubarb/Int Bauk
     * @author lare96
     *
     */
    public class LocationHandler {
    	
        private static Player player;
        
        /**
         * Constructor of class.
         * @param player
         */
        public LocationHandler(Player player) {
            this.player = player;
        }
        
        /**
         * Handles all locations via an enum.
         * @param x, y, x1, y1.
         *
         */
        public enum Location {
           EDGEVILLE(3084, 3111, 3483, 3509,"Edgeville"),
           LUMBRIDGE(3199, 3199, 3265, 3296, "Lumbridge");
           
           private int x, y, x1, y1;
           private String locationName;
     
          /**
           * Our location constructor.
           * @param x
           * @param y
           * @param x1
           * @param y1
           * @param name
           */
          private Location(int x, int y, int x1, int y1, String name) {
               this.x = x;
               this.y = y;
               this.x1 = x1;
               this.y1 = y1;
               this.locationName = name;
           }
     
          /**
           * Gets the location name.
           * @return
           */
           public String getLocationName() {
               return locationName;
           }
       }
     
       /**
        * Checks if you're in a specified location
        * 
        * @param region
        *            The location
        * 
        * @return if you are in the location specified or not
        */
       public static boolean isInLocation(Location region) {
           int x = player.absX;
           int y = player.absY;
     
           if (x > region.x && x < region.x1
                   && y > region.y && y < region.y1) {
               return true;
           }
           return false;
       }
     
       /**
        * Gets the name of the Location you are currently in.
        * @return the name.
        */
       public static String getLocation() {
           for (Location all : Location.values()) {
               if (isInLocation(all)) {
                   return all.getLocationName();
               }
           }
           return "Location not in database.";
       }
    	
       /**
        * Prints location of region.
        * @param c
        */
    	public static final void printLocation(Client c) {
    		c.getDH().sendStatement("Where am I?");
    		c.sendMessage(c.playerName + " is in the city of: " + getLocation() + ".");
    	}
    }
    Then in ClickItem.java:
    Code:
    		/**
    		 * Create new switch statement.
    		 * @param itemId.
    		 */
    		switch(itemId) {
    		case 611:
    			LocationHandler.printLocation(c);
    			break;
    		}
    Enjoy.

    Credits:

    lare96 - for one/two skeleton methods.
    Me - of course.

    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,472
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    Looks good I was actually about to make something like this

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  4. #3  
    Donator


    Join Date
    Mar 2011
    Posts
    2,362
    Thanks given
    1,193
    Thanks received
    824
    Rep Power
    856
    Simple and very useful. Good job
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  5. #4  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,472
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    Sorry for posting again but wanted to aaa this was done really good

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  6. #5  
    Super Donator


    Join Date
    Sep 2008
    Age
    27
    Posts
    1,897
    Thanks given
    677
    Thanks received
    776
    Rep Power
    456
    Also with this you can have like;
    Code:
    public void moveToLocation(Location location){
      int x = location.x;
      x += location.x1 - x;
      int y = location.y;
      y= location.y1 -y;
      moveTo(x, y, 0);
    }
    Code:
      moveToLocation(Location.EDGEVILLE);
    Reply With Quote  
     

  7. #6  
    Father Of Lies


    Join Date
    May 2012
    Age
    23
    Posts
    1,216
    Thanks given
    267
    Thanks received
    289
    Rep Power
    242
    Thanks man, I've used.

    (Added more regions).

    Also, convert for runesource:

    Spoiler for RuneSource Convert:

    Code:
    package com.rs2.model;
     
    import com.rs2.model.players.Player;
    import com.rs2.model.Position;
     
    /**
     * 
     * @author Rhubarb/Int Bauk
     * @author lare96
     * @author Jakeyy/Jake Bellotti
     */
    public class LocationHandler {
         
        private static Player player;
    	private static Position position;
         
        /**
         * Constructor of class.
         * @param player
         */
        public LocationHandler(Player player) {
            this.player = player;
        }
         
        /**
         * Handles all locations via an enum.
         * @param x, y, x1, y1.
         *
         */
        public enum Location {
          EDGEVILLE(3084, 3111, 3483, 3509,"Edgeville"),
           LUMBRIDGE(3199, 3199, 3265, 3296, "Lumbridge"),
    	   BANDIT_CAMP(3192, 3154, 2998, 2968, "Bandit Camp"),
    	   WILDERNESS(2944, 3520, 3392, 6400, "Wilderness"),
    	   TUTORIAL_ISLAND(2625, 2687, 4670, 4735, "Tutorial Island"),
    	   BARROWS(3520, 3598, 9653, 9750, "Barrows"),
    	   DUEL_ARENA(3322, 3394, 3195, 3291, "Duel Arena"),
    	   DUEL_ARENA2(3311, 3323, 3223, 3248, "Duel Arena"),
    	   FIGHT_CAVES(2360, 2445, 5045, 5125, "Fight Caves"),
           PIRATES_HOUSE(3038, 3044, 3949, 3959, "Pirates House"),
    	   GOD_WARS(2699, 2769, 5051, 5124, "God Wars Dungeon"),
    	   APE_ATOL(2760, 2780, 2790, 2819, "Ape Atol"),
    	   BARBATIAN_ASSAULT(2576, 2623, 3145, 3179, "Barbarian Assault");
            
           private int x, y, x1, y1;
           private String locationName;
      
          /**
           * Our location constructor.
           * @param x
           * @param y
           * @param x1
           * @param y1
           * @param name
           */
          private Location(int x, int y, int x1, int y1, String name) {
               this.x = x;
               this.y = y;
               this.x1 = x1;
               this.y1 = y1;
               this.locationName = name;
           }
      
          /**
           * Gets the location name.
           * @return
           */
           public String getLocationName() {
               return locationName;
           }
       }
      
       /**
        * Checks if you're in a specified location
        * 
        * @param region
        *            The location
        * 
        * @return if you are in the location specified or not
        */
       public static boolean isInLocation(Location region) {
           int x = position.getX();
           int y = position.getY();
      
           if (x > region.x && x < region.x1
                   && y > region.y && y < region.y1) {
               return true;
           }
           return false;
       }
      
       /**
        * Gets the name of the Location you are currently in.
        * @return the name.
        */
       public static String getLocation() {
           for (Location all : Location.values()) {
               if (isInLocation(all)) {
                   return all.getLocationName();
               }
           }
           return "Location not in database.";
       }
         
       /**
        * Prints location of region.
        * @param c
        */
        public static final void printLocation(Player player) {
            player.getDialogue().sendStatement1("Where am I?");
            player.getActionSender().sendMessage("I am in the city of: " + getLocation() + ".");
        }
    }
    Reply With Quote  
     

  8. #7  



    Join Date
    Oct 2011
    Posts
    875
    Thanks given
    301
    Thanks received
    373
    Rep Power
    338
    Can be used for many useful things like a music system, etc. Good job.
    Reply With Quote  
     

  9. #8  
    Banned

    Join Date
    Jun 2010
    Age
    23
    Posts
    4,836
    Thanks given
    1,676
    Thanks received
    1,563
    Discord
    View profile
    Rep Power
    0
    Looks nice, good job.
    Reply With Quote  
     

  10. #9  
    ~! Legit ~!

    Join Date
    Nov 2010
    Posts
    1,973
    Thanks given
    183
    Thanks received
    211
    Rep Power
    237
    Looks good, nice job

    Quote Originally Posted by Tyluur View Post
    Looks nice, good job.
    See what I did their?
    [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  
     

  11. #10  
    q.q


    Join Date
    Dec 2010
    Posts
    6,535
    Thanks given
    1,072
    Thanks received
    3,534
    Rep Power
    4752
    Code:
      private static Player player;
         
        /**
         * Constructor of class.
         * @param player
         */
        public LocationHandler(Player player) {
            this.player = player;
        }
    much pointlessness
    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. [718] saving player location
    By Monum3ntal in forum Snippets
    Replies: 27
    Last Post: 12-11-2012, 11:10 PM
  2. Checking Player Location
    By I'm A Jerk in forum Help
    Replies: 6
    Last Post: 07-24-2011, 07:57 AM
  3. Player location bug --
    By Clienthax in forum Help
    Replies: 0
    Last Post: 10-26-2010, 01:38 AM
  4. Replies: 16
    Last Post: 01-30-2010, 03:30 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
  •