QBCore Inventory decriptiond

HI on the id cards in qbcore the description of the item says the owner of the id cards name etc like this:
image
But when I add my new item that I want to have a similar description to the player in the same why as the id card is added to the player the new item just has the default description that is set inte the iteminfo int the qbcore shared items

So I was looking to do the same thing. I figured out how to do identification type items just by looking around. You’ll need to do these things:

1: have the new item(s) in the qb-core/shared/items.lua

  • put whatever description you want for this

2: add the new item(s) to the qb-cityhall/config.lua with (under Config.Cityhalls.licenses)

  • you will have to set the metadata field to whatever name matches the item; this is what the script will look for to determine if someone can buy the new item

3: add the new item(s) to qb-core/server/player.lua (under PlayerData.metadata) and set to true to grant access to the new item by default, or false to make it where someone will have to grant the license

  • the metadata table in your database will automatically update based on the new entry/entries for new characters

  • the fields will have to be added manually to the database for existing players

  • if you set it up to where the item will need to be granted, you’ll need to add the license type to a command such as the “grantlicense” command for police; this MUST match the name you put for the metadata field in the previous step

4: set up the fields you want in the qb-cityhall/server/main.lua similar to the ones already there (under the qb-cityhall:server:requestId event)

  • you can define new parameters if you choose as well

5: configure the new item(s) in the qb-inventory/html/js/app.js

  • here you will set the item up to show your custom description fields instead of the one from the items.lua

  • it’s best to look at what’s already there to write the code correctly

After a restart the new items should work…unless I left something out :sweat_smile: I also set up my new licenses and badges to be useable and send the custom info in chat like the id card does, but don’t worry about that until you get them working in the first place. Hope this helps!

3 Likes