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