Thread: setlevel command gone wrong

Results 1 to 6 of 6
  1. #1 setlevel command gone wrong 
    Registered Member
    Join Date
    Nov 2011
    Posts
    23
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    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!
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Nov 2011
    Posts
    47
    Thanks given
    4
    Thanks received
    0
    Rep Power
    11
    if (playerCommand.startsWith("setlevel") && c.playerRights == 7) {

    try {
    String[] args = playerCommand.split(" ");
    int skill = Integer.parseInt(args[1]);
    int level = Integer.parseInt(args[2]);
    if (level > 99)
    level = 99;
    else if (level < 0)
    level = 1;
    c.playerXP[skill] = c.getPA().getXPForLevel(level)+5;
    c.playerLevel[skill] = c.getPA().getLevelForXP(c.playerXP[skill]);
    c.getPA().refreshSkill(skill);
    } catch (Exception e){}

    }

    replace with this if u use PI
    Reply With Quote  
     

  3. #3  
    Hella Hard Homie


    Join Date
    Jan 2011
    Posts
    600
    Thanks given
    185
    Thanks received
    43
    Rep Power
    111
    What base are you using?

    Quote Originally Posted by Winston Churchill
    "Success is the ability to go from one failure to another with no loss of enthusiasm"
    Austin still owes me $43
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Mar 2013
    Posts
    10
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Well, i'm using a PI server on 317 and here is mine, see if it works for you:

    Spoiler for setlevel:
    if (playerCommand.startsWith("setlevel") && c.playerRights == 7) {

    try {
    String[] args = playerCommand.split(" ");
    int skill = Integer.parseInt(args[1]);
    int level = Integer.parseInt(args[2]);
    if (level > 99)
    level = 99;
    else if (level < 0)
    level = 1;
    c.playerXP[skill] = c.getPA().getXPForLevel(level)+5;
    c.playerLevel[skill] = c.getPA().getLevelForXP(c.playerXP[skill]);
    c.getPA().refreshSkill(skill);
    } catch (Exception e){}

    }
    Scheiße auf meinen Schwanz.

    http://www.tracadite.com/

    ^
    I hope to get my server up in a few weeks
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Nov 2011
    Posts
    23
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    Hey guys, Its not suppose to set my level its suppose to set someone else s level. My base is Zenithscape 667/728


    For example,
    I am suppose to say

    :etlevel usernamehere levelid# level#

    and the person who donated on my server gets the level
    Reply With Quote  
     

  6. #6  
    Registered Member
    Karma_K's Avatar
    Join Date
    Nov 2012
    Posts
    4,283
    Thanks given
    152
    Thanks received
    610
    Rep Power
    108
    Quote Originally Posted by johnyboy2600 View Post
    Hey guys, Its not suppose to set my level its suppose to set someone else s level. My base is Zenithscape 667/728


    For example,
    I am suppose to say

    :etlevel usernamehere levelid# level#

    and the person who donated on my server gets the level
    Youll probably get more help in the 503+ section
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. UnMute command gone wrong?
    By xCoDeR Aj in forum Help
    Replies: 2
    Last Post: 05-19-2011, 11:00 PM
  2. ::setlevel command
    By Raiden1 in forum Requests
    Replies: 3
    Last Post: 02-13-2009, 02:52 AM
  3. ::Setlevel command like battlescape?
    By Runebay™ in forum Help
    Replies: 8
    Last Post: 02-08-2009, 10:23 PM
  4. ::setlevel Command
    By wh1p in forum Help
    Replies: 3
    Last Post: 02-07-2009, 07:21 PM
  5. setlevel command
    By Sway in forum Requests
    Replies: 2
    Last Post: 10-15-2008, 05:35 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •