Thread: Almost have xp lock added ran into one little problem

Results 1 to 4 of 4
  1. #1 Almost have xp lock added ran into one little problem 
    Registered Member Larabeast's Avatar
    Join Date
    Jun 2011
    Age
    31
    Posts
    155
    Thanks given
    12
    Thanks received
    2
    Rep Power
    19
    I was told to do this:

    Code:
    public boolean addSkillXP(int amount, int skill) {
    		int oldLevel = getLevelForXP(playerXP[skill]);
    		playerXP[skill] += amount;
    		if (oldLevel < getLevelForXP(playerXP[skill])) {
    			animation(199, absY, absX);
    			playerLevel[skill] = getLevelForXP(playerXP[skill]);
    			updateRequired = true;
    			appearanceUpdateRequired = true;
    			levelup(skill);
    			
    			setSkillLevel(skill, playerLevel[skill], playerXP[skill]);
    		}
    		refreshSkills();
    		if (skill == 2) {
    			CalculateMaxHit();
    		}
    		return true;
    
    	}
    Now underneath public boolean addSkillXP(int amount, int skill) {

    Add this:

    Code:
    if (expLock) {
        return;
    }
    So it is at the top of the method.

    Now mine looks like this:
    Code:
    public boolean addSkillXP(int amount, int skill){
                    if (expLock); {
                        return;
                    }
    		if (amount+c.playerXP[skill] < 0 || c.playerXP[skill] > 200000000) {
    			if(c.playerXP[skill] > 200000000) {
    				c.playerXP[skill] = 200000000;
    			}
    			return false;
    		}
    And when I compile it I get these 2 errors,
    Code:
    src\server\model\players\PlayerAssistant.java:1972: cannot find symbol
    symbol  : variable expLock
    location: class server.model.players.PlayerAssistant
                    if (expLock); {
                        ^
    src\server\model\players\PlayerAssistant.java:1973: missing return value
                        return;
                        ^
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    2 errors
    Press any key to continue . . .

    This is exactly what the tutorial said to copy and paste into player.java and it compiled fine, so I don't see how it isn't recognizing it.

    Code:
    	    }
           public boolean expLock;
    	
    }
    ^ I don't understand why this was in the tutorial and it excludes returning to a value, doesn't it have to return to a true or false value? When I try to make it return I get errors.
    Reply With Quote  
     

  2. #2  
    Registered Member DestriX's Avatar
    Join Date
    Nov 2008
    Posts
    1,323
    Thanks given
    490
    Thanks received
    152
    Rep Power
    257
    well for the first error, it can't find the variable 'explock' so you have to add it.(or reference it from another class)
    Attached image
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Dec 2010
    Posts
    536
    Thanks given
    61
    Thanks received
    25
    Rep Power
    4
    Either way you need to declare expLock as an int or boolean in Player.java, or a private statement.
    Reply With Quote  
     

  4. #4  
    Registered Member Larabeast's Avatar
    Join Date
    Jun 2011
    Age
    31
    Posts
    155
    Thanks given
    12
    Thanks received
    2
    Rep Power
    19
    I've already done this in player.java, and it compiled fine....... So why isn't it recognizing that's it's been declared? I'll post where I put it at in my player.java

    This is exactly what the tutorial said to copy and paste into player.java

    Code:
    	    }
           public boolean expLock;
    	
    }
    Someone said it doesn't recognize that the boolean was declared because I needed to make the public boolean return to false, so I changed the boolean to
    Code:
    public boolean expLock = false;
    And I still get the same two compiling errors, you all said the errors were because it wasn't recognizing the boolean I put.

    vAnd here's the error code I'm getting.
    Code:
    src\server\model\players\PlayerAssistant.java:1972: cannot find symbol
    symbol  : variable expLock
    location: class server.model.players.PlayerAssistant
                    if (expLock); {
                        ^
    src\server\model\players\PlayerAssistant.java:1973: missing return value
                        return;
                        ^
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    2 errors
    Press any key to continue . . .
    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. Replies: 0
    Last Post: 05-17-2011, 10:26 PM
  2. [PI] Woodcutting problem V2! >.< (added code)
    By Snow Cat123 in forum Help
    Replies: 3
    Last Post: 10-27-2010, 06:33 PM
  3. [FIXED]Class Problem. Lock please.
    By Poindexter in forum Help
    Replies: 3
    Last Post: 04-30-2010, 09:44 PM
  4. added donater rank but one problem
    By Buckshot in forum Help
    Replies: 8
    Last Post: 10-05-2009, 12:52 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
  •