Use search bar, seen alot.
|
Does anyone have a command that gives donor points to another player. Such as ::givedp (name) (amount).
Use search bar, seen alot.
I can write one for you if you tell me what class your donor points int is and also what its called ( e.g donorPoints )
Here you go mate, TESTED and is working on my own Source [PI] CHANGE "YOUDONORPOINTNAME HERE" to e.g donatorPoints You can find this in playersave.java
Code:if (playerCommand.startsWith("givedp")) { String[] args = playerCommand.split("-"); if (args.length == 3) { try { String givenPlayer = args[1]; int donorPoints = Integer.parseInt(args[2]); for(int i = 0; i < Config.MAX_PLAYERS; i++) { if(Server.playerHandler.players[i] != null) { Client c2 = (Client)Server.playerHandler.players[i]; if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(givenPlayer)) { c.sendMessage("<col=890909>You have given "+ givenPlayer +" "+donorPoints+" DonatorPoints</col>"); c2."YOUDONORPOINTNAME HERE" += donorPoints; c2.sendMessage("<col=890909>You have Recieved "+donorPoints+" DonatorPoints Thank You So Much :)</col>"); } } } } catch(Exception e) { c.sendMessage("Player is not online."); } } else { c.sendMessage("Command Error."); } }
Everytime i use this command, i get "Command Error." in my chatbox. This is my code for the givedp command.if (playerCommand.startsWith("givedp") && c.playerName.equalsIgnoreCase("Russ")) {
String[] args = playerCommand.split("-");
if (args.length == 3) {
try {
String givenPlayer = args[1];
int DonorPoints = Integer.parseInt(args[2]);
for(int i = 0; i < Config.MAX_PLAYERS; i++) {
if(Server.playerHandler.players[i] != null) {
Client c2 = (Client)Server.playerHandler.players[i];
if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(givenPlayer)) {
c.sendMessage("<col=890909>You have given "+ givenPlayer +" "+DonorPoints+" DonatorPoints</col>");
c2.DonorPoints += DonorPoints;
c2.sendMessage("<col=890909>You have Recieved "+DonorPoints+" DonatorPoints Thank You So Much </col>");
}
}
}
} catch(Exception e) {
c.sendMessage("Player is not online.");
}
} else {
c.sendMessage("Command Error.");
}
}
It doesn't work with people who have spaces in their usernames. How can i make that work?
Use as: givedp-playerName-amountOfPointsCode:if (playerCommand.startsWith("givedp")) { String[] args = playerCommand.split("-"); for (Player p : PlayerHandler.players) { if (p != null && p.playerName.equalsIgnoreCase(args[1])) { p.donorPoints += Integer.parseInt(args[2]); ((Client) p).sendMessage("You have been given " + args[2] + " donor points by " + c.playerName); } } }
russ you gotta use it like this ::givedp-name-points
This is the one i have used on all my servers:
if (playerCommand.startsWith("givepoints")) {
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])) {
Client c2 = (Client)Server.playerHandler.players[i];
c2.donatorChest += Integer.parseInt(args[2]);
c.sendMessage("You gave points to "+c2.playerName+", he has now "+c2.donatorChest+" points.");
c2.sendMessage("You recieve "+Integer.parseInt(args[2])+" donator chest points, you now have "+c2.donatorChest+".");
}
}
}
} catch(Exception e) {
c.sendMessage("Player must be offline.");
}
}
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |