Thread: Help Please!

Results 1 to 5 of 5
  1. #1 Help Please! 
    Registered Member r0fl dr0pped's Avatar
    Join Date
    Feb 2012
    Posts
    394
    Thanks given
    20
    Thanks received
    5
    Rep Power
    23
    Issue #1: I can either be wielding a sword OR a shield, but I can't wear both at the same time. Yes they are going into the correct slots. The issue is in that little code but I can't for the life of me get it.
    Issue #2: Fixed.

    Issue #1 - itemAssistant.java
    Code:
                } else if (targetSlot == 5) {
                    boolean wearing2h = is2handed(getItemName(player.playerEquipment[player.playerWeapon]).toLowerCase(),
                        player.playerEquipment[player.playerWeapon]);
                    if (wearing2h) {
                        toRemove = player.playerEquipment[player.playerWeapon];
                        toRemoveN = player.playerEquipmentN[player.playerWeapon];
                        player.playerEquipment[player.playerWeapon] = -1;
                        player.playerEquipmentN[player.playerWeapon] = 0;
                        updateSlot(player.playerWeapon);
                    }
                    player.playerItems[slot] = toRemove + 1;
                    player.playerItemsN[slot] = toRemoveN;
                    player.playerEquipment[targetSlot] = toEquip - 1;
                    player.playerEquipmentN[targetSlot] = toEquipN;
    Issue #2 - Fixed

    Full Code For Issue #1
    Code:
                } else if (targetSlot != 5 && targetSlot != 3) {
                    int remove_slot = getItemSlot(toRemove);
                    if (toRemove != -1 && remove_slot != -1 && ItemDefinition.forId(toRemove).isStackable()) {
                        player.playerItems[slot] = 0;
                        player.playerItemsN[slot] = 0;
                        player.playerItemsN[remove_slot] += toRemoveN;
                    } else {
                        player.playerItems[slot] = toRemove + 1;
                        player.playerItemsN[slot] = toRemoveN;
                    }
                    player.playerEquipment[targetSlot] = toEquip - 1;
                    player.playerEquipmentN[targetSlot] = toEquipN;
                } else if (targetSlot == 5) {
                    boolean wearing2h = is2handed(getItemName(player.playerEquipment[player.playerWeapon]).toLowerCase(),
                        player.playerEquipment[player.playerWeapon]);
                    if (wearing2h) {
                        toRemove = player.playerEquipment[player.playerWeapon];
                        toRemoveN = player.playerEquipmentN[player.playerWeapon];
                        player.playerEquipment[player.playerWeapon] = -1;
                        player.playerEquipmentN[player.playerWeapon] = 0;
                        updateSlot(player.playerWeapon);
                    }
                    player.playerItems[slot] = toRemove + 1;
                    player.playerItemsN[slot] = toRemoveN;
                    player.playerEquipment[targetSlot] = toEquip - 1;
                    player.playerEquipmentN[targetSlot] = toEquipN;
                } else if (targetSlot == 3) {
                    boolean is2h = is2handed(getItemName(wearID).toLowerCase(), wearID);
                    boolean wearingShield = player.playerEquipment[player.playerShield] > 0;
                    boolean wearingWeapon = player.playerEquipment[player.playerWeapon] > 0;
                    if (is2h) {
                        if (wearingShield && wearingWeapon) {
                            if (freeSlots() > 0) {
                                player.playerItems[slot] = toRemove + 1;
                                player.playerItemsN[slot] = toRemoveN;
                                player.playerEquipment[targetSlot] = toEquip - 1;
                                player.playerEquipmentN[targetSlot] = toEquipN;
                                removeItem(player.playerShield);
                            } else {
                                player.sendGameMessage("You do not have enough inventory space to do this.");
                                return false;
                            }
                        } else if (wearingShield && !wearingWeapon) {
                            player.playerItems[slot] = player.playerEquipment[player.playerShield] + 1;
                            player.playerItemsN[slot] = player.playerEquipmentN[player.playerShield];
                            player.playerEquipment[targetSlot] = toEquip - 1;
                            player.playerEquipmentN[targetSlot] = toEquipN;
                            player.playerEquipment[player.playerShield] = -1;
                            player.playerEquipmentN[player.playerShield] = 0;
                            updateSlot(player.playerShield);
                        } else {
                            int remove_slot = getItemSlot(toRemove);
                            if (toRemove != -1 && remove_slot != -1 && ItemDefinition.forId(toRemove).isStackable()) {
                                player.playerItems[slot] = 0;
                                player.playerItemsN[slot] = 0;
                                player.playerItemsN[remove_slot] += toRemoveN;
                            } else {
                                player.playerItems[slot] = toRemove + 1;
                                player.playerItemsN[slot] = toRemoveN;
                            }
                            player.playerEquipment[targetSlot] = toEquip - 1;
                            player.playerEquipmentN[targetSlot] = toEquipN;
                        }
                    } else {
                        int remove_slot = getItemSlot(toRemove);
                        if (toRemove != -1 && remove_slot != -1 && ItemDefinition.forId(toRemove).isStackable()) {
                            player.playerItems[slot] = 0;
                            player.playerItemsN[slot] = 0;
                            player.playerItemsN[remove_slot] += toRemoveN;
                        } else {
                            player.playerItems[slot] = toRemove + 1;
                            player.playerItemsN[slot] = toRemoveN;
                        }
                        player.playerEquipment[targetSlot] = toEquip - 1;
                        player.playerEquipmentN[targetSlot] = toEquipN;
                    }
                }
                resetItems(3214);
                if (targetSlot == 3) {
                    if (player.usingSpecial && player.specEffect > 0) {
                        player.specialDelay = 0;
                        player.specEffect = 0;
                    }
                    player.usingSpecial = false;
                    addSpecialBar(wearID);
                }
                if (player.getOutStream() != null && player != null) {
                    player.getOutStream().putFrameVarShort(34);
                    int offset = player.getOutStream().offset;
                    player.getOutStream().putShort(1688);
                    player.getOutStream().putByte(targetSlot);
                    player.getOutStream().putShort(wearID + 1);
    
                    if (player.playerEquipmentN[targetSlot] > 254) {
                        player.getOutStream().putByte(255);
                        player.getOutStream().putInt(player.playerEquipmentN[targetSlot]);
                    } else {
                        player.getOutStream().putByte(player.playerEquipmentN[targetSlot]);
                    }
    
                    player.getOutStream().putFrameSizeShort(offset);
                    player.flushOutStream();
                }
                EquipmentConstants.sendSoundForEquipSlot(player, slot, wearID);
                sendWeapon(player.playerEquipment[player.playerWeapon], getItemName(player.playerEquipment[player.playerWeapon]));
                resetBonus();
                getBonus();
                player.getPA().resetAutoCast();
                player.autocasting = false;
                writeBonus();
                player.getCombat().getPlayerAnimIndex(getItemName(player.playerEquipment[player.playerWeapon]).toLowerCase());
                player.getPA().requestUpdates();
                return true;
            } else {
                return false;
            }
        }
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jan 2016
    Posts
    25
    Thanks given
    20
    Thanks received
    3
    Rep Power
    0
    1. Seems like both could be registering as two-handed
    2. Search the string, see what conditions trigger it
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Banned

    Join Date
    Oct 2012
    Posts
    4,723
    Thanks given
    1,684
    Thanks received
    1,101
    Rep Power
    0
    Quote Originally Posted by r0fl dr0pped View Post
    Issue #1: I can either be wielding a sword OR a shield, but I can't wear both at the same time. Yes they are going into the correct slots
    Issue #2: When i try to wear tokhaar khal, chaotics, arcane stream or any of that it says "(Item ID) is unable to be used, if this is an error please report it!"
    Any Ideas? Thanks!
    Do not help this guy, he stole my base i sold to someone. Reported
    Reply With Quote  
     

  5. #4  
    Registered Member r0fl dr0pped's Avatar
    Join Date
    Feb 2012
    Posts
    394
    Thanks given
    20
    Thanks received
    5
    Rep Power
    23
    Quote Originally Posted by ipkmills View Post
    Do not help this guy, he stole my base i sold to someone. Reported
    Lol. what are you going on about?

    Quote Originally Posted by AuguryRSPS View Post
    1. Seems like both could be registering as two-handed
    2. Search the string, see what conditions trigger it
    #1: I think that is the issue, here is my 2h code
    Code:
                } else if (targetSlot != 5 && targetSlot != 3) {
                    int remove_slot = getItemSlot(toRemove);
                    if (toRemove != -1 && remove_slot != -1 && ItemDefinition.forId(toRemove).isStackable()) {
                        player.playerItems[slot] = 0;
                        player.playerItemsN[slot] = 0;
                        player.playerItemsN[remove_slot] += toRemoveN;
                    } else {
                        player.playerItems[slot] = toRemove + 1;
                        player.playerItemsN[slot] = toRemoveN;
                    }
                    player.playerEquipment[targetSlot] = toEquip - 1;
                    player.playerEquipmentN[targetSlot] = toEquipN;
                } else if (targetSlot == 5) {
                    boolean wearing2h = is2handed(getItemName(player.playerEquipment[player.playerWeapon]).toLowerCase(),
                        player.playerEquipment[player.playerWeapon]);
                    if (wearing2h) {
                        toRemove = player.playerEquipment[player.playerWeapon];
                        toRemoveN = player.playerEquipmentN[player.playerWeapon];
                        player.playerEquipment[player.playerWeapon] = -1;
                        player.playerEquipmentN[player.playerWeapon] = 0;
                        updateSlot(player.playerWeapon);
                    }
                    player.playerItems[slot] = toRemove + 1;
                    player.playerItemsN[slot] = toRemoveN;
                    player.playerEquipment[targetSlot] = toEquip - 1;
                    player.playerEquipmentN[targetSlot] = toEquipN;
                } else if (targetSlot == 3) {
                    boolean is2h = is2handed(getItemName(wearID).toLowerCase(), wearID);
                    boolean wearingShield = player.playerEquipment[player.playerShield] > 0;
                    boolean wearingWeapon = player.playerEquipment[player.playerWeapon] > 0;
                    if (is2h) {
                        if (wearingShield && wearingWeapon) {
                            if (freeSlots() > 0) {
                                player.playerItems[slot] = toRemove + 1;
                                player.playerItemsN[slot] = toRemoveN;
                                player.playerEquipment[targetSlot] = toEquip - 1;
                                player.playerEquipmentN[targetSlot] = toEquipN;
                                removeItem(player.playerShield);
                            } else {
                                player.sendGameMessage("You do not have enough inventory space to do this.");
                                return false;
                            }
                        } else if (wearingShield && !wearingWeapon) {
                            player.playerItems[slot] = player.playerEquipment[player.playerShield] + 1;
                            player.playerItemsN[slot] = player.playerEquipmentN[player.playerShield];
                            player.playerEquipment[targetSlot] = toEquip - 1;
                            player.playerEquipmentN[targetSlot] = toEquipN;
                            player.playerEquipment[player.playerShield] = -1;
                            player.playerEquipmentN[player.playerShield] = 0;
                            updateSlot(player.playerShield);
                        } else {
                            int remove_slot = getItemSlot(toRemove);
                            if (toRemove != -1 && remove_slot != -1 && ItemDefinition.forId(toRemove).isStackable()) {
                                player.playerItems[slot] = 0;
                                player.playerItemsN[slot] = 0;
                                player.playerItemsN[remove_slot] += toRemoveN;
                            } else {
                                player.playerItems[slot] = toRemove + 1;
                                player.playerItemsN[slot] = toRemoveN;
                            }
                            player.playerEquipment[targetSlot] = toEquip - 1;
                            player.playerEquipmentN[targetSlot] = toEquipN;
                        }
                    } else {
                        int remove_slot = getItemSlot(toRemove);
                        if (toRemove != -1 && remove_slot != -1 && ItemDefinition.forId(toRemove).isStackable()) {
                            player.playerItems[slot] = 0;
                            player.playerItemsN[slot] = 0;
                            player.playerItemsN[remove_slot] += toRemoveN;
                        } else {
                            player.playerItems[slot] = toRemove + 1;
                            player.playerItemsN[slot] = toRemoveN;
                        }
                        player.playerEquipment[targetSlot] = toEquip - 1;
                        player.playerEquipmentN[targetSlot] = toEquipN;
                    }
                }
    #2 The issue is in the itemDefinition I believe?
    wearItem.java
    Code:
    		ItemDefinition def = ItemDefinition.forId(player.wearId);
    		if (def == null || def.getSlot() == -1) {
    			player.sendGameMessage(player.wearId + " is unable to be used, if this is an error please report it!");
    			return;
    		}
    itemAssistant.java
    Code:
            if (def == null || def.getSlot() == -1) {
    			player.sendGameMessage(ItemAssistant.getItemName(wearID)+ " is unable to be used, if this is an error please report it!");
    				return false;
    	}
    ItemDefinition.java
    Code:
        /**
         * The definitions.
         */
        private static Map<Integer, ItemDefinition> definitions = new HashMap<>();
    
        /**
         * Loads item definitions from item_defs.json
         */
        public static void load() throws IOException {
            System.out.println("Loading item definitions...");
    
            List<ItemDefinition> list = new Gson().fromJson(FileUtils.readFileToString(new File("./Data/json/item_definitions.json")),new TypeToken<List<ItemDefinition>>() { }.getType());
    
            list.stream().filter(Objects::nonNull).forEach(item -> definitions.put((int) item.id, item));
            
            System.out.println("Loaded " + definitions.size() + " item definitions.");
        }
    
        /**
         * Get an items definition by id.
         *
         * @param id The id.
         * @return The item definition.
         */
        public static ItemDefinition forId(int id) {
        	if (definitions == null) {
        		return null;
        	}
            return definitions.get(id);
        }
    bumpppppp
    Reply With Quote  
     

  6. #5  
    Banned

    Join Date
    Oct 2012
    Posts
    4,723
    Thanks given
    1,684
    Thanks received
    1,101
    Rep Power
    0
    Quote Originally Posted by r0fl dr0pped View Post
    Lol. what are you going on about?


    #1: I think that is the issue, here is my 2h code
    Code:
                } else if (targetSlot != 5 && targetSlot != 3) {
                    int remove_slot = getItemSlot(toRemove);
                    if (toRemove != -1 && remove_slot != -1 && ItemDefinition.forId(toRemove).isStackable()) {
                        player.playerItems[slot] = 0;
                        player.playerItemsN[slot] = 0;
                        player.playerItemsN[remove_slot] += toRemoveN;
                    } else {
                        player.playerItems[slot] = toRemove + 1;
                        player.playerItemsN[slot] = toRemoveN;
                    }
                    player.playerEquipment[targetSlot] = toEquip - 1;
                    player.playerEquipmentN[targetSlot] = toEquipN;
                } else if (targetSlot == 5) {
                    boolean wearing2h = is2handed(getItemName(player.playerEquipment[player.playerWeapon]).toLowerCase(),
                        player.playerEquipment[player.playerWeapon]);
                    if (wearing2h) {
                        toRemove = player.playerEquipment[player.playerWeapon];
                        toRemoveN = player.playerEquipmentN[player.playerWeapon];
                        player.playerEquipment[player.playerWeapon] = -1;
                        player.playerEquipmentN[player.playerWeapon] = 0;
                        updateSlot(player.playerWeapon);
                    }
                    player.playerItems[slot] = toRemove + 1;
                    player.playerItemsN[slot] = toRemoveN;
                    player.playerEquipment[targetSlot] = toEquip - 1;
                    player.playerEquipmentN[targetSlot] = toEquipN;
                } else if (targetSlot == 3) {
                    boolean is2h = is2handed(getItemName(wearID).toLowerCase(), wearID);
                    boolean wearingShield = player.playerEquipment[player.playerShield] > 0;
                    boolean wearingWeapon = player.playerEquipment[player.playerWeapon] > 0;
                    if (is2h) {
                        if (wearingShield && wearingWeapon) {
                            if (freeSlots() > 0) {
                                player.playerItems[slot] = toRemove + 1;
                                player.playerItemsN[slot] = toRemoveN;
                                player.playerEquipment[targetSlot] = toEquip - 1;
                                player.playerEquipmentN[targetSlot] = toEquipN;
                                removeItem(player.playerShield);
                            } else {
                                player.sendGameMessage("You do not have enough inventory space to do this.");
                                return false;
                            }
                        } else if (wearingShield && !wearingWeapon) {
                            player.playerItems[slot] = player.playerEquipment[player.playerShield] + 1;
                            player.playerItemsN[slot] = player.playerEquipmentN[player.playerShield];
                            player.playerEquipment[targetSlot] = toEquip - 1;
                            player.playerEquipmentN[targetSlot] = toEquipN;
                            player.playerEquipment[player.playerShield] = -1;
                            player.playerEquipmentN[player.playerShield] = 0;
                            updateSlot(player.playerShield);
                        } else {
                            int remove_slot = getItemSlot(toRemove);
                            if (toRemove != -1 && remove_slot != -1 && ItemDefinition.forId(toRemove).isStackable()) {
                                player.playerItems[slot] = 0;
                                player.playerItemsN[slot] = 0;
                                player.playerItemsN[remove_slot] += toRemoveN;
                            } else {
                                player.playerItems[slot] = toRemove + 1;
                                player.playerItemsN[slot] = toRemoveN;
                            }
                            player.playerEquipment[targetSlot] = toEquip - 1;
                            player.playerEquipmentN[targetSlot] = toEquipN;
                        }
                    } else {
                        int remove_slot = getItemSlot(toRemove);
                        if (toRemove != -1 && remove_slot != -1 && ItemDefinition.forId(toRemove).isStackable()) {
                            player.playerItems[slot] = 0;
                            player.playerItemsN[slot] = 0;
                            player.playerItemsN[remove_slot] += toRemoveN;
                        } else {
                            player.playerItems[slot] = toRemove + 1;
                            player.playerItemsN[slot] = toRemoveN;
                        }
                        player.playerEquipment[targetSlot] = toEquip - 1;
                        player.playerEquipmentN[targetSlot] = toEquipN;
                    }
                }
    #2 The issue is in the itemDefinition I believe?
    wearItem.java
    Code:
    		ItemDefinition def = ItemDefinition.forId(player.wearId);
    		if (def == null || def.getSlot() == -1) {
    			player.sendGameMessage(player.wearId + " is unable to be used, if this is an error please report it!");
    			return;
    		}
    itemAssistant.java
    Code:
            if (def == null || def.getSlot() == -1) {
    			player.sendGameMessage(ItemAssistant.getItemName(wearID)+ " is unable to be used, if this is an error please report it!");
    				return false;
    	}
    ItemDefinition.java
    Code:
        /**
         * The definitions.
         */
        private static Map<Integer, ItemDefinition> definitions = new HashMap<>();
    
        /**
         * Loads item definitions from item_defs.json
         */
        public static void load() throws IOException {
            System.out.println("Loading item definitions...");
    
            List<ItemDefinition> list = new Gson().fromJson(FileUtils.readFileToString(new File("./Data/json/item_definitions.json")),new TypeToken<List<ItemDefinition>>() { }.getType());
    
            list.stream().filter(Objects::nonNull).forEach(item -> definitions.put((int) item.id, item));
            
            System.out.println("Loaded " + definitions.size() + " item definitions.");
        }
    
        /**
         * Get an items definition by id.
         *
         * @param id The id.
         * @return The item definition.
         */
        public static ItemDefinition forId(int id) {
        	if (definitions == null) {
        		return null;
        	}
            return definitions.get(id);
        }
    bumpppppp
    OK:
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

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

Similar Threads

  1. Help please?
    By Pablo... in forum Graphics
    Replies: 11
    Last Post: 11-18-2007, 04:12 AM
  2. Run Server? little help please :]
    By im so h00d in forum Tutorials
    Replies: 13
    Last Post: 11-11-2007, 03:59 AM
  3. Help, please
    By Zachyboo in forum Tutorials
    Replies: 4
    Last Post: 08-27-2007, 04:27 PM
  4. Webclient Help Please?
    By Spoonkitty in forum RS2 Client
    Replies: 1
    Last Post: 06-28-2007, 09:22 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •