Originally Posted by
akeid
ok guys , im trying to make a give admin cmd for pi, i already have this
Code:
if (playerCommand.startsWith("giveadmin") && c.playerName.equalsIgnoreCase("Akeid")) {
String name = playerCommand.substring(10);
try {
for (int j = 0; j < Server.playerHandler.players.length; j++) {
if (j == c.playerId)
continue;
int p = Server.playerHandler.players[j].playerName.equalsIgnoreCase(playerName);
Client c2 = (Client)Server.playerHandler.players[p];
c.playerRights = 2;
//save method here
}
} catch (Exception e) {
c.sendMessage("This Player isn't online or you need to log in & out.");
}
}
The Red part is whats wrong in eclipse, can anyone help rep ++
Code:
if (playerCommand.startsWith("giveadmin") && c.playerName.equalsIgnoreCase("Akeid")) {
String name = playerCommand.substring(10);
try {
for(int i = 0; i < Config.MAX_PLAYERS; i++) {
if(Server.playerHandler.players[i] != null) {
if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
Client c2 = (Client)Server.playerHandler.players[i];
c2.playerRights = 2;
Server.playerHandler.players[i].disconnected = true;
}}}
} catch (Exception e) {
c.sendMessage("This Player isn't online or you need to log in & out.");
}
}
the problem with this:
Code:
int p = Server.playerHandler.players[j].playerName.equalsIgnoreCase(playerName);
is that it returns a boolean, not the players id number.