Yes, I'm mostly new to Java but I'm trying to write my own command and cannot figure out why this wont work. I only really know how to take some code and transfer and use some code to figure out what you do in which situation so no I didn't write this just tried to modify it.
HELP:
So if I figure this out right I'll try to explain what I believe to be what
CMD[0] CMD[1] CMD[2]
so you set CMD[0] to "setlevel"
CMD1 to player you want to change level
Then intskill and intlevel as numbers hence setting interger value
If I'm right idk if I am "substring(cmd[1].indexOf(" ") + 1)" means space after you do CMD[1]???
So then i need another one before the last? Which wouldn't make much sense cause I never added a "substring(cmd[1].indexOf(" ") + 1)" to cmd[0]?
Idk I'm confused and I wan't to learn the language just not be spoon fed but if you fix for me; I am pretty good at knwoing what I did wrong..
Its suppose to setlevel for another person and not me
Code:
if (cmd[0].equalsIgnoreCase("setlevel")&& ((player.getRights() == 7))) {
String username = cmd[1].substring(cmd[1].indexOf(" ") + 1));
int skill = Integer.parseInt(cmd[2].substring(cmd[2].indexOf(" ") + 1);
int level = Integer.parseInt(cmd[3]);
Player other = World.getPlayerByDisplayName(username);
if (other != null) {
try {
other.setlevel(skill, level);
other.getSkills().setXp(skill, Skills.getXPForLevel(level));
other.getAppearence().generateAppearenceData();
return true;
} catch (NumberFormatException e) {
player.getPackets().sendGameMessage("Usage ::setlevel username skillId level");
return true;
}
} else {
player.getPackets().sendGameMessage("Couldn't find player " + other + ".");
}
}
Compiler Error
starting...
src\com\rs\game\player\content\Commands.java:406: error: cannot find symbol
other.setlevel(skill, level);
^
symbol: method setlevel(int,int)
location: variable other of type Player
Note: src\com\rs\utils\OnlineP.java uses or overrides a deprecated API.
Note: Recompile with -Xlinteprecation for details.
Note: src\com\rs\game\player\Inventory.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Press any key to continue . . .
Thanks!