[QB] Adding core_crafting crafting in Base Building
This snippet will help you setup crafting from core_crafting as events to use on other scripts like hrs_base_building
In core_crafting
core_crafting\client\main.lua
OLD CODE:
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
for _, v in ipairs(Config.Workbenches) do
local dst = #(coords - v.coords)
if dst < 20 then
DrawText3D(v.coords[1], v.coords[2], v.coords[3], Config.Text['workbench_hologram'])
end
if dst < 2 then
if IsControlJustReleased(0, 38) then
local open = false
local gang = QBCore.Functions.GetPlayerData().gang.name
for _, g in ipairs(v.jobs) do
if g == job then
open = true
end
end
for _, g in ipairs(v.gangs) do
if g == gang then
open = true
end
end
if open or (#v.jobs == 0 and #v.gangs == 0) then
openWorkbench(v)
else
QBCore.Functions.Notify(Config.Text['wrong_job'], 'error')
end
end
end
end
end
end)
RegisterNetEvent("open:workbench")
AddEventHandler("open:workbench", function()
for _, v in ipairs(Config.Workbenches) do
local open = false
local gang = QBCore.Functions.GetPlayerData().gang.name
for _, g in ipairs(v.jobs) do
if g == job then
open = true
end
end
for _, g in ipairs(v.gangs) do
if g == gang then
open = true
end
end
if open or (#v.jobs == 0 and #v.gangs == 0) then
openWorkbench(v)
else
QBCore.Functions.Notify(Config.Text['wrong_job'], 'error')
end
end
end)
NEW CODE:
core_crafting\config.lua
In HRS_base_building
hrs_base_building\config.lua
Previous[ESX] Adding core_crafting crafting in Base BuildingNext[ESX] Adding chezza_inventory crafting in Base Building
Last updated