Wait what do you want to do? Please explain
|
How would I make an array/for loop that'll check my equipped items?
I have tried this:
It doesn't work it'll allow those items in my array even if I have them equipped.Code:public void checkItems() { int[]equipItems = { 4151, 6570, 11694,......}; for (int i = 0; i < equipItems.length; i++) { if (c.playerEquipment[c.playerWeapon] != equipItems[i]){ } else if (c.playerEquipment[c.playerHat] != equipItems[i]){ } else if (c.playerEquipment[c.playerHands] != equipItems[i]){ } else if (c.playerEquipment[c.playerChest] != equipItems[i]){ } else if (c.playerEquipment[c.playerLegs] != equipItems[i]){ } else if (c.playerEquipment[c.playerFeet] != equipItems[i]){ } else if (c.playerEquipment[c.playerShield] != equipItems[i]){ c.sendMessage("You cannot bring those items with you to play."); } else { c.sendMessage("Your items are ok. Please continue."); } } }
Wait what do you want to do? Please explain
Yes basically the items inside
Code:int[]equipItems = { 4151, 6570, 11694,......};
just use something like
Use as:Code:public static boolean equipmentCheck(Player p, int[][] data) { for (int i = 0; i < data.length; i++) { if (p.playerEquipment[data[i][0]] != data[i][1]) { System.out.println("Doesn't have required equipment."); return false; } } return true; }
int[][] data = { {equipmentSlot, equipmentItemId}, {equipmentSlot2, equipmentItemId2} };
equipmentCheck(((Player)c), data);
I don't see how that'll check certain equipment, like if I don't want a player to be able to wear an Abyssal whip or a Firecape when entering a minigame, I can't do playerHasItem because I want to do it with multiple items.
If I'm wrong please explain. I'm trying to learn how to use these methods better.
in your entering shitCode:public static boolean hasUnavailableEquipment(Client p) { for (int i = 0; i < restrictedItems.length; i++) { for (int equip = 0; equip < 14; equip++) { if (p.playerEquipment[equip] == restrictedItems[i]) { c.sendMessage("You can not bring "+c.getItems().getItemName(p.playerEquipment[equip]); return true; } } } return false; } static int [] restrictedItems = {4151};
Code:if (hasUnavailableEquipment(c) return;
Code:public static boolean isWearingItems(Player player, int[][] items) { for(int i = 0; i < items.length; i++) { if(player.playerEquipment[items[i][0]] != items[i][1]) { return false; } } return true; }Code:int[][] requiredItems = { {PlayerConstants.CAPE, 6570}, {PlayerConstants.WEAPON, 4153} } if(!isWearingItems(player, requiredItems)) { // not wearing the items }
Same shit I just posted, but ok. .__.
@ Jads, what are you talking about? I even told you how to use it, just add the method in ItemAssistant and then when you want to check use:
int[][] data = { {equipmentSlot}, {equipmentId} };
if (ItemAssistant.equipmentCheck(player, data)) {
}
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |