Is there any guide on how to add items to the QB-core server? Been looking for a beginner tutorial or guide. [ SOLVED ]
1 Like
Hey
It’s pretty straight forward. You just have to do the following :
- In the ‘qb-core/shared/items.lua’ file you add your item to the table :
QBShared.Items = {
['joint'] = {['name'] = 'joint', ['label'] = 'Joint', ['weight'] = 0, ['type'] = 'item', ['image'] = 'joint.png', ['unique'] = false, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Sidney would be very proud at you'},
}
- Then you give it the functionnality you want, by implementing the ’ CreateUseableItem()’ function in the server lua file of the script using the item (or a more global one if the item isn’t related to a specific script)
QBCore.Functions.CreateUseableItem('joint', function()
print("SMOKING A JOINT")
end)
2 Likes
I really appreciate your help!
F**king legend, I should of figured it out myself lol, managed to add a bunch of custom items lmao, thank you!
How would one take that item lets say ‘joint’ like you mentioned and give it an emote and allow it to grant you armor
Hey
You could try somthing along those lines (I didn’t test it or anything) :
QBCore.Functions.CreateUseableItem('joint', function()
Citizen.CreateThread(function()
local playerPed = PlayerPedId()
local x,y,z = table.unpack(GetEntityCoords(playerPed))
local prop_name = "p_amb_joint_01"
local prop = CreateObject(GetHashKey(prop_name), x, y, z + 0.2, true, true, true)
local boneIndex = GetPedBoneIndex(playerPed, 18905)
AttachEntityToEntity(prop, playerPed, boneIndex, 0.12, 0.028, 0.001, 10.0, 175.0, 0.0, true, true, false, true, 1, true)
ESX.Streaming.RequestAnimDict('amb@world_human_drinking@coffee@female@idle_a', function()
TaskStartScenarioInPlace(playerPed, 'WORLD_HUMAN_AA_COFFEE', 1.0, -1.0, 2000, 0, 1, true, true, true)
Citizen.Wait(2000)
SetPedArmour(playerPed, 100)
IsAnimated = false
ClearPedSecondaryTask(playerPed)
DeleteObject(prop)
end)
end)
hai . can you share link file ?