Thread: Setting up level requirements [proper way]

Results 1 to 6 of 6
  1. #1 Setting up level requirements [proper way] 
    Member

    Join Date
    Sep 2007
    Posts
    614
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    This tutorial is intermediate. You are expected to know java knowledge pertaining to syntax, tags, and location.


    The point of this is to add requirements for items, and even for adding in items such as skillcapes. First, locate your item in "item.cfg". If its not there, put it there with the proper name. Also, keep in mind the EXACT name of the item, as the server gains its names from this list (Serverside, using the getItemName method)

    Next, open up your client. Find...
    Code:
    public boolean wear(int wearID, int slot) {
    And below this, you should see something like
    Code:
    int CLAttack = GetCLAttack(wearID);
    Duplicate this, and rename attack to what the skill you want have requirements for.

    Further below, you see this again in the form of...

    Code:
    if (CLAttack > getLevelForXP(playerXP[playerAttack])) {
    sendMessage("You need " + CLAttack + " " + statName[playerAttack] + " to equip this item.");
    GoFalse = true;
    }
    Again, duplicate and rename. Make sure the CL part matches the one you made above, and most important, "playerAttack" is the name of the skill we are checking requirements for.


    Once finished, find

    Code:
    public int GetCLAttack(int ItemID)
    Now, use the example below to construct (or you can copy and paste )


    Code:
    	public int GetCLMining(int ItemID) {
    		if (ItemID == -1) {
    			return 1;
    		}
    		String ItemName = GetItemName(ItemID);
    		if (ItemName.startsWith("Rune Pickaxe")) {
    			return 40;
    		}
    
    		return 1;
    	}
    Explanation. Duplicate and change the "if (ItemName.startsWith" part to fit your needs, make sure the name you put matches or at least the begging matches what you put in item.cfg.

    The "return 40;" is, yep, you guessed it, the level needed. First return 1 checks to see if the item ID is in valid, IE - the server cant find it in item.cfg. The last one says for it to have lvl 1 requirements for anything not listed above. This MUST be last or it will not work properly.

    Also, change the Mining part to match the other getCL you made above.


    That concludes it. This is a better and more organized way to code, even if your making it only for skillcapes, it helps with misc armor, different levels of pickaxes or axes.

    Rate/Hate/Whatever
     

  2. #2  
    kilermage
    Guest
    This is pretty nice, so I will use your minning thing to add to my server.
     

  3. #3  
    Member

    Join Date
    Sep 2007
    Posts
    614
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    Thanks. First tut here on rune-server Seems alot nicer then mopar.
     

  4. #4  
    Dharok
    Guest
    Quote Originally Posted by Dead Man Hunter View Post
    Well welcome to the community. Trust me we're not as strict as Mopar. Nice tutorial for a start
    Yeah, agreed. Welcome.
     

  5. #5  
    Member Market Banned Market Banned

    Zee Best's Avatar
    Join Date
    Feb 2007
    Age
    29
    Posts
    3,036
    Thanks given
    24
    Thanks received
    210
    Rep Power
    1171
    I posted mine ages ago...

    Althought it got deleted a while ago i still reposted before your's...

    And mine is in much more detail...

    [Only registered and activated users can see links. ]


    [Only registered and activated users can see links. ]
     

  6. #6  
    Banned

    Join Date
    Aug 2007
    Age
    29
    Posts
    705
    Thanks given
    21
    Thanks received
    30
    Rep Power
    0
    aww give him a break it's his first tut
     


Thread Information
Users Browsing this Thread

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


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •