TungstenX Posted February 19 Share Posted February 19 (edited) Good day, I'm trying to "drop" all items in the player's inventory. The issue that I'm facing now is that the items are on the floor, the player's inventory shows empty but the attachment/equip dot is shown and you have to unequip the item before you can wear it. Also, the items are still shown on the player's model (as well as the floor). This is the current iteration of my code: local container = player:getInventory() player:dropHandItems() -- works well local items = container:getItems() for i = 0, items:size() -1, 1 do local item = items:get(i) currentSquare:AddWorldInventoryItem(item, 0, 0, 0) -- Put on floor if item:isEquipped() then -- unequip player:removeAttachedItem(item) else player:getInventory():DoRemoveItem(item) -- :clear() didn't work end end 1. Is my approach correct? (I can't find a "drop" function) 2. How do I unequip (clothing, bags, etc) and remove item from the player's inventory 3. How do I remove non-wearing items such as water bottles, etc. Edited February 19 by TungstenX Adding a line of code for clarity Link to comment Share on other sites More sharing options...
TungstenX Posted March 1 Author Share Posted March 1 (edited) Here is how the function evolved so far: (There was a glitch and the stuff that was on the floor wasn't there when I started the game again - thus this must be verified carefully) Currently I'm calling this method via a context menu to speed up the testing function UndressAll(x, y, z) local player = getPlayer() local container = player:getInventory() local currentSquare = getSquare(x, y, z) local items = container:getItems() player:dropHandItems() -- Worn items local wornItems = player:getWornItems() local size = wornItems:size() for i = 0, size - 1, 1 do local wItem = wornItems:get(0) if wItem ~= nil then local item = wItem:getItem() currentSquare:AddWorldInventoryItem(item, 0, 0, 0) player:removeWornItem(item) container:Remove(item) wornItems:remove(item) end end items = container:getItems() size = items:size() for i = 0, size - 1, 1 do local item = items:get(0) if item ~= nil then local itemDisplayName = item:getDisplayName() currentSquare:AddWorldInventoryItem(item, 0, 0, 0) container:Remove(item) end end end Is this correct? Is there a better way to do this? Edited March 1 by TungstenX Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now