Resources for FiveM allowing the user to access to an inventory and for developpers to add and remove items from the inventory. It’s a resource more for developers.
Requirements
ESM v2
MySQL Async
Installation
Download the resource here :
Place the folder “vdk_inventory” to resources folder of FiveM
Execute dump.sql file in your database (will create the tables and the constraints)
Populate the items and user user_inventory tables to test
Usage
For users : Press your Replay Help Button (usually ‘K’) to show the menu
For developers : Use “player:receiveItem” and “player:looseItem” events with the item id and quantity as parameters events to add or remove items from the inventory
Thanks
For the menu
Notes
It’s my first LUA script so please be indulgent with me and all valuable proposals are more than welcome.
For help
Guys if you want some help you need to help me/us to help you so if you have any problem you need at least to share a screen of client/server error or a part of code… I’m not a genius so I can’t help you if you just say “why I don’t see anything ?”… So please be smart enough to search a minimum by yourself and don’t ask me that…
Thank you
Problems
MySQL 1071 : I think it’s because you have fields in your table too long like VARCHAR(300) or int(50), try to change them to VARCHAR(255) and int(11) OR change user_id varchar(255) CHARACTER SET utf8mb4 NOT NULL DEFAULT ‘’ TO user_id varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT ‘’ in my dump.sql (thanks to @SADoJ_Kuro)
Update
21/04 : Update dump.sql file → delete the primary key on users table and delete the foreign constraint in user_inventory table. Thanks to @GeekRiot
22/04 :
-Add sellItem event to earn money and loose an
-Add export to get the quantity of object of a player
This update allow me to introduce the recolting/treatment/selling system that I will soon release
23/04 : performance improvement by separating from essentialmode event who slowdown the script, thanks to @GeekRiot
23/04 20:20 : fix another bug when player get a totally new item and go back to TriggerEvent(‘es:getPlayerFromId’, source, function(user) actually necessary to my next script
24/04
Adding maximun capacity of inventory
minor fix on a sql request
06/05
I add the possibility to trade items between near players, I remove the possibility to add and remove items and fix the max capacity
03/06
It’s not only an inventory but more a personal menu. You can access to the inventory but also to animations menu and give money to near player.
I also made a system of temporary items to limit SQL queries. Change the refreshTimer like you want
I add the usable items system : in items table I add canUse column (for now 1 is for drink, 2 is for eat)
I also include the MySQL Async library, thanks to @Brouznouf
10/06
Include PutInCoffre function who introduce my next release
You probably have something like IsControlReleased( 0, 311 ) in your code and then in your post you’re telling people to press [K] to show the menu. It triggers the FiveM devs that people are assuming keys are constants (they’re not the same for everybody). So if you edit your post and change it to:
For users : Press your Replay Help button (usually: k) to show the menu
Personnaly, i have to create the user_inventory by my own but not a problem ! (Thanks to FiveM and scripters for learning me how to manage a DB lol :))