nice job
|
This Tutorial is for (::give username itemid), that way when people use it they will have the item pop up in the given username above.
Difficulty: 1/10
Needed Knowledge: Copy & Paste
Files Edited: Client Class
Step 1.
AddAfterpublic boolean startsWithVowel(String input) {
try {
if (input.startsWith("a")
|| input.startsWith("e")
|| input.startsWith("i")
|| input.startsWith("o")
|| input.startsWith("u")) {
return true;
}
return false;
} catch (Exception e) {
sM("Error with checking for vowels.");
}
}
Step 2.public class client extends Player implements Runnable {
Add this anywhere in your commands area.
Save & Close then Compile & Run.if (s.startsWith("give ") && playerRights == 3) {
String[] args = command.split(" ");
if (args.length != 3) {
sM("Invalid command typed - \"::give itemId playerName\".");
return;
}
try {
String oName = command.subString(args[2]).replaceAll("_", " ");
int oID = PlayerHandler.getPlayerID(otherPName);
if (oID != -1) {
client p = (client) server.playerHandler.players[otherPIndex];
String name = GetItemName(Integer.parseInt(args[1])).toLowerCase();
p.addItem(Integer.parseInt(args[1]), 1);
p.sM("You have been given a" + (itemName.startsWith(startsWithVowel(name) ? "n" : "") + " by " + playerName + ".");
sM("You give a" + (itemName.startsWith(startsWithVowel(name) ? "n" : "") + " to " + p.playerName + ".");
} else {
sM("Player is not online.");
}
} catch (Exception e) {
sM("Exception was caught while excecuting command \"" + playerCommand + "\".");
}
return;
}
Credits:
100% Me
nice job
Nvm.
Last edited by Hunter K0 U All; 03-09-2009 at 05:44 AM. Reason: DIDNT WORK OH WELL.
Code:lient.java:7209: ')' expected .sM("You have been given a" + (itemName.startsWith(startsWithVowe "") + " by " + playerName + "."); ^ lient.java:7210: ')' expected M("You give a" + (itemName.startsWith(startsWithVowel(name) ? "n" + p.playerName + ".");
Erm, who the hell cares if its using correct grammar? Makes the code very messy.
Not to mention there are so many simpler ways of doing this. Look up regex pattern splitting.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |