Originally Posted by
Expire
Code:
if (playerCommand.startsWith("give")) {
try {
String[] args = playerCommand.split(" ");
for(int i = 0; i < Config.MAX_PLAYERS; i++) {
if(Server.playerHandler.players[i] != null) {
if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(args[1])) {
int amountpoints = Integer.parseInt(args[2]);
int oldpoints = c.donPoints;
int newpoints = amountpoints + oldpoints;
c.donPoints = newpoints;
((Client) Server.playerHandler.players[i]).getPA()
.requestUpdates();
}
}
}
} catch(Exception e) {
c.sendMessage("Player must be offline.");
}
}
This, is my ::give command for donator points.
It works, but it's temporary doesn't write to the playerfile.
Can anyone help me?
also, how do i read from it for my variable of donorpoints?
First, this:
Code:
int oldpoints = c.donPoints;
int newpoints = amountpoints + oldpoints;
c.donPoints = newpoints;
Could be shortened to:
Code:
c.donPoints += amountpoints;
For writing to player files, use a BufferedWriter. Be sure there is a donator points variable already set up.