Description: To add basic eating food to your server.
Difficulty: 1/10
Assumed Knowledge: Knowing how to add a few simple things yourself.
Files/Classes Modified: Player.java, ItemSelect.java
Procedure
Step 1:
Add these ints in your player class:
Step 2: In your Player classCode:public int eatDelay = 0;
public int isFood [] = {391, 385, 397, 315, 319, 325, 329, 339, 333, 347, 351, 355,
361, 365, 379, 373};
Add this method in your player class:
Step 3: In your Player classCode:public void eatFood(int foodId, int heal) {
if (eatDelay <= 0) {
eatDelay = 3;
for (int id : isFood) {
if (foodId == id) {
requestAnim(829, 0);
Engine.playerItems.deleteItem(this, foodId, 1);
updateHP(heal, true);
frames.sendMessage(this, "You eat the "+Engine.items.getItemName(foodId)+".");
if (skillLvl[3] < getLevelForXP(3)) {
frames.sendMessage(this, "It heals some health.");
}
}
}
}
}
Add this in your process.
Step 4: In your ItemSelect classCode:if (eatDelay > 0) {
eatDelay--;
}
As you can see that I just put Manta rays in, you guys will have to add the rest yourself.Code:case 391:
p.eatFood(391, 22);
break;
Usage for the rest:
And also, I didn't add every food id on my isFood int so just add the ids I didn't put there yourself.Code:case FOODID:
p.eatFood(FOODID, HEALAMT);
break;
Good luck and don't leech :p
Credits: Light Moger(me), and BFMV(helping me out with for each statement)
update:
Around half the foods here
Code:public int isFood [] = {391, 385, 397, 247, 315, 319, 325, 329, 339, 333, 347, 351, 355,
361, 365, 379, 373, 1861, 1942, 1957, 1963, 1969, 1973, 1982, 1985, 2102, 2108, 2120,
2126, 2128, 2140, 2142, 2209, 2213, 2309, 3151, 3228, 3369, 3371, 3373, 3381, 6297, 6701, 6794,
7062, 7072, 7078, 7082, 7084, 7946};
Code:case 247: // Jangerberries
p.eatFood(247, 2);
break;
case 315: // Shrimps
p.eatFood(315, 3);
break;
case 319: // Anchovies
p.eatFood(319, 1);
break;
case 325: // Sardine
p.eatFood(325, 4);
break;
case 329: // Salmon
p.eatFood(329, 9);
break;
case 333: // Trout
p.eatFood(333, 7);
break;
case 339: // Cod
p.eatFood(339, 7);
break;
case 347: // Herring
p.eatFood(347, 5);
break;
case 351: // Pike
p.eatFood(351, 8);
break;
case 355: // Mackerel
p.eatFood(355, 6);
break;
case 361: // Tuna
p.eatFood(361, 10);
break;
case 365: // Bass
p.eatFood(365, 13);
break;
case 373: // Swordfish
p.eatFood(373, 14);
break;
case 379: // Lobster
p.eatFood(379, 12);
break;
case 385: // Shark
p.eatFood(385, 20);
break;
case 391: // Manta Ray
p.eatFood(391, 22);
break;
case 397: // Sea turtle
p.eatFood(397, 21);
break;
case 1861: // Ugthanki meat
p.eatFood(1861, 3);
break;
case 1942: // Potato
p.eatFood(1942, 1);
break;
case 1957: // Onion
p.eatFood(1957, 1);
break;
case 1963: // Banana
p.eatFood(1963, 2);
break;
case 1969: // Spinach Roll
p.eatFood(1969, 2);
break;
case 1973: // Chocolate Bar
p.eatFood(1982, 3);
break;
case 1982: // Tomato
p.eatFood(1982, 2);
break;
case 1985: // Cheese
p.eatFood(1985, 2);
break;
case 2102: // Lemon
p.eatFood(2102, 2);
break;
case 2108: // Orange
p.eatFood(2108, 2);
break;
case 2120: // Lime
p.eatFood(2120, 2);
break;
case 2126: // Dwellberries
p.eatFood(2126, 2);
break;
case 2128: // Equa Leaves
p.eatFood(2128, 1);
break;
case 2140: // Chicken
p.eatFood(2140, 3);
break;
case 2142: // Meat
p.eatFood(2142, 3);
break;
case 2209: // Chocchip Crunchies
p.eatFood(2209, 7);
break;
case 2213: // Spicy Crunchies
p.eatFood(2213, 7);
break;
case 2309: // Bread
p.eatFood(2309, 5);
break;
case 3151: // Karambwanji
p.eatFood(3151, 3);
break;
case 3228: // Cooked Rabbit
p.eatFood(3228, 5);
break;
case 3369: // Thin Snail meat
p.eatFood(3369, (Misc.random(2)+5));
break;
case 3371: // Lean Snail meat
p.eatFood(3371, (Misc.random(2)+6));
break;
case 3373: // Fat Snail meat
p.eatFood(3373, (Misc.random(2)+7));
break;
case 3381: // Slimy Eel
p.eatFood(3381, (Misc.random(4)+6));
break;
case 6297: // Spider on Stick
p.eatFood(6297, (Misc.random(4)+7));
break;
case 6701: // Baked Potato
p.eatFood(6701, 4);
break;
case 6794: // Choc-ice
p.eatFood(6794, 7);
break;
case 7062: // Chilli con carne
p.eatFood(7062, 5);
break;
case 7072: // Spicy Sauce
p.eatFood(7072, 2);
break;
case 7078: // Scrambled Eggs
p.eatFood(7078, 5);
break;
case 7082: // Fried Mushrooms
p.eatFood(7082, 5);
break;
case 7084: // Fried Onions
p.eatFood(7084, 5);
break;
case 7946: // Monkfish
p.eatFood(7946, 16);
break;
