Skip to content

Conversation

@LeSiiN
Copy link

@LeSiiN LeSiiN commented Feb 13, 2025

🔄 Improve Item Drop Handling

📌 Summary
This update enhances the handling of item drops in the swapItems hook for ox_inventory. When a player drops an item into a "newdrop" inventory, the script ensures that the item is correctly removed from their inventory and spawns as an interactive drop in the world.

✨ Changes & Improvements

  • ✅ Validates whether the dropped item belongs to CARRY_ITEMS.
  • ✅ Creates a proper drop entity using ox_inventory:CustomDrop().
  • ✅ Removes the item from the player's inventory after a successful drop.
  • ✅ Automatically opens the drop inventory for player interaction.
  • ✅ Improved code readability and formatting.

🛠️ How It Works

  1. The script checks if the dropped item is eligible for dropping.
  2. If valid, it spawns the item at the player's location with appropriate metadata.
  3. The item is removed from the player's inventory.
  4. The drop inventory automatically opens, allowing interaction with the dropped item.

🚀 Why This Improvement?
This ensures smooth item dropping mechanics, preventing inventory inconsistencies and improving usability for players interacting with dropped items.

🔍 Testing

  1. Drop an eligible item into a "newdrop" inventory and confirm it spawns correctly.
  2. Check if the drop inventory opens after dropping the item.
  3. Verify that the item is properly removed from the player's inventory.

📌 Additional Notes
This PR only improves the appearance and structure of the existing code—no logic changes were made.

@itsfaizy
Copy link

That's some awesome work there! Glad to see the use of ox_invs custom drops being used here. Great example in an open source script.

➕1️⃣

@LeSiiN
Copy link
Author

LeSiiN commented Feb 25, 2025

That's some awesome work there! Glad to see the use of ox_invs custom drops being used here. Great example in an open source script.

➕1️⃣

Thank u very much! Sadly i couldnt get it to work with the same export above the one i added, which would have been better in reading and overall look/formating. But its alright.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants