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 ");
}
}