Thread: Players in Wilderness

Results 1 to 7 of 7
  1. #1 Players in Wilderness 
    Kairos
    Kairos..'s Avatar
    Join Date
    Dec 2015
    Posts
    154
    Thanks given
    21
    Thanks received
    20
    Rep Power
    34
    Difficult Level: Amature
    Edit Files: PlayerHandler.java
    New Files (Not required): Playerswildy.java

    Base used: Os-PvP
    ps. first time doing a snippet.

    In PlayerHadler.java search the method for Player Counting, for me it's this.

    Code:
    	public static int getPlayerCount() {
    		int count = 0;
    		for (int i = 0; i < Config.MAX_PLAYERS; i++) {
    			if (players[i] != null) {
    				count++;
    			}
    		}
    		return count;
    	}

    It will display every "Not" Nulled Account which is currently online including yourself.

    To make it ony count people in certain "areas" we have to edit the code
    Code:
    			if (players[i] != null) {

    In Player.java there should already be a boolean with coordinates for wildernes.
    Code:
    	public boolean inWild() {
    		if (absX > 2941 && absX < 3392 && absY > 3524 && absY < 3968 || absX > 2941 && absX < 3392 && absY > 9918 && absY < 10366 || absX > 2426 && absX < 2365 && absY > 3128 && absY < 3079) {
    			return true;
    		}
    		return false;
    Now to only count people in wilderness we would change the "if" statement to
    Code:
    if (players[i] != null && players[i].inWild()) {

    end result would be

    Code:
    	public static int getPlayerInWildyCount() {
    		int count = 0; //change it to -1 if you dont want to include urself when being in wilderness
    		for (int i = 0; i < Config.MAX_PLAYERS; i++) {
    			if (players[i] != null && players[i].inWild()) {
    				count++;
    			}
    		}
    		return count;


    now to simply display it through a Command , create a new file . In my case Playerswildy and copy/paste the cmd.

    Code:
    public class Playerswildy implements Command {
    
    	@Override
    	public void execute(Player c, String input) {
    
    		c.sendMessage("There are currently  @[email protected]" + PlayerHandler.getPlayerInWildyCount() + "@[email protected] players in wildy ");
    	    
    			}
    }
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Banned

    Join Date
    Mar 2011
    Posts
    657
    Thanks given
    105
    Thanks received
    75
    Rep Power
    0
    Fairly simple snippet. Thanks for the information!
    Reply With Quote  
     

  4. #3  
    Boy Wonder


    Join Date
    Mar 2012
    Posts
    849
    Thanks given
    133
    Thanks received
    80
    Discord
    View profile
    Rep Power
    99
    To improve perhaps provide the code that makes it into a task, then put it on server startup. would be much better than with a command.
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  5. #4  
    Boy Wonder


    Join Date
    Mar 2012
    Posts
    849
    Thanks given
    133
    Thanks received
    80
    Discord
    View profile
    Rep Power
    99
    Quote Originally Posted by Appealer_2 View Post
    No point in that + you could just increase/decrease the count as players leave/enter the wilderness. Regardless it doesn't really matter for something that's so negligible.
    It just easy to make a task for it. You can send all your server messages with one task without having to send a server wide message in multiple places. just consolidate it all into one task. Sounds much cleaner to me.
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  6. #5  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,108
    Thanks given
    2,402
    Thanks received
    2,825
    Rep Power
    4604
    Quote Originally Posted by Appealer_2 View Post
    No point in that + you could just increase/decrease the count as players leave/enter the wilderness. Regardless it doesn't really matter for something that's so negligible.
    You're absolutely correct, you could also utilize the observer pattern for this so it works out great.
    Reply With Quote  
     

  7. #6  
    Registered Member Lil Peep's Avatar
    Join Date
    Oct 2012
    Posts
    882
    Thanks given
    234
    Thanks received
    58
    Rep Power
    0
    Quote Originally Posted by Jason View Post
    You're absolutely correct, you could also utilize the observer pattern for this so it works out great.
    Couldn't this be done for players jumping over a certain side of the wilderness wall too? I personally would consider players in the 2 tile safezone to be in the wilderness.

    Would probably have to correspond with Appealer_2's suggestion.
    Reply With Quote  
     

  8. #7  
    Registered Member trickboy's Avatar
    Join Date
    Dec 2011
    Posts
    355
    Thanks given
    27
    Thanks received
    14
    Rep Power
    26
    +thanks button. Had some trouble to convert to my project but it worked.

    2.25x experience rate, and over 70 quests.
    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. Players in wilderness
    By Rangin Santa in forum Help
    Replies: 8
    Last Post: 09-22-2014, 07:28 AM
  2. [718] Count players in Wilderness?
    By Mayne in forum Help
    Replies: 5
    Last Post: 06-20-2013, 08:53 AM
  3. Replies: 15
    Last Post: 12-16-2012, 11:22 PM
  4. Replies: 4
    Last Post: 06-29-2012, 11:25 AM
  5. Replies: 16
    Last Post: 08-11-2011, 01: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
  •