From 0bcfd7ba664a0cc49d0f44095cebdbe979de6b6f Mon Sep 17 00:00:00 2001 From: Kakarot <57848836+GhzGarage@users.noreply.github.com> Date: Mon, 20 May 2024 05:30:05 -0500 Subject: [PATCH] Inventory Update --- client/main.lua | 38 +--------------- config/config.lua | 110 ---------------------------------------------- server/main.lua | 23 +++++++++- 3 files changed, 23 insertions(+), 148 deletions(-) diff --git a/client/main.lua b/client/main.lua index a087ad7..68596eb 100644 --- a/client/main.lua +++ b/client/main.lua @@ -149,42 +149,8 @@ CreateThread(function() label = Lang:t('target.stash'), icon = 'fas fa-box-open', job = v.managed and k or nil, - action = function() - TriggerServerEvent('inventory:server:OpenInventory', 'stash', k .. '_stash', { - maxweight = 4000000, - slots = 100, - }) - TriggerEvent('inventory:client:SetCurrentStash', k .. '_stash') - end - } }, - distance = 2.0 - }) - - exports['qb-target']:AddCircleZone(k .. '_shop', v.shop, 0.5, { - name = k .. '_shop', - debugPoly = false, - useZ = true - }, { - options = { { - label = Lang:t('target.shop'), - icon = 'fas fa-cart-shopping', - job = v.managed and k or nil, - action = function() - local ShopItems = {} - ShopItems.items = {} - ShopItems.label = k .. '_shop' - for i = 1, #v.shopItems do - ShopItems.items[#ShopItems.items + 1] = { - name = v.shopItems[i].name, - item = v.shopItems[i].name, - price = v.shopItems[i].price, - amount = v.shopItems[i].amount, - type = 'item', - slot = i, - } - end - TriggerServerEvent('inventory:server:OpenInventory', 'shop', k .. '_shop', ShopItems) - end + type = 'server', + event = 'qb-mechanicjob:server:stash', } }, distance = 2.0 }) diff --git a/config/config.lua b/config/config.lua index a5c9f97..a12656d 100644 --- a/config/config.lua +++ b/config/config.lua @@ -38,7 +38,6 @@ Config.Shops = { blipSprite = 72, blipColor = 46, blipCoords = vector3(-346.02, -130.68, 39.02), - shop = vector3(-343.66, -140.78, 39.02), duty = vector3(-348.18, -134.55, 39.59), stash = vector3(-346.02, -130.68, 39.02), paint = vector3(-324.11, -147.11, 39.10), @@ -47,27 +46,6 @@ Config.Shops = { spawn = vector4(-369.65, -107.8, 38.65, 70.52), list = { 'flatbed', 'towtruck', 'minivan', 'blista' } }, - shopItems = { - { name = 'veh_toolbox', price = 5000, amount = 50 }, - { name = 'veh_armor', price = 5000, amount = 50 }, - { name = 'veh_brakes', price = 5000, amount = 50 }, - { name = 'veh_engine', price = 5000, amount = 50 }, - { name = 'veh_suspension', price = 5000, amount = 50 }, - { name = 'veh_transmission', price = 5000, amount = 50 }, - { name = 'veh_turbo', price = 5000, amount = 50 }, - { name = 'veh_interior', price = 5000, amount = 50 }, - { name = 'veh_exterior', price = 5000, amount = 50 }, - { name = 'veh_wheels', price = 5000, amount = 50 }, - { name = 'veh_neons', price = 5000, amount = 50 }, - { name = 'veh_xenons', price = 5000, amount = 50 }, - { name = 'veh_tint', price = 5000, amount = 50 }, - { name = 'veh_plates', price = 5000, amount = 50 }, - { name = 'nitrous', price = 5000, amount = 50 }, - { name = 'tunerlaptop', price = 5000, amount = 50 }, - { name = 'repairkit', price = 5000, amount = 50 }, - { name = 'advancedrepairkit', price = 5000, amount = 50 }, - { name = 'tirerepairkit', price = 5000, amount = 50 }, - } }, mechanic2 = { -- Harmony Location managed = true, @@ -76,7 +54,6 @@ Config.Shops = { blipSprite = 72, blipColor = 46, blipCoords = vector3(1174.93, 2639.45, 37.75), - shop = vector3(1189.36, 2641.00, 38.44), duty = vector3(1185.86, 2638.70, 38.93), stash = vector3(1175.11, 2635.375, 37.78), paint = vector3(1181.29, 2634.69, 37.80), @@ -85,27 +62,6 @@ Config.Shops = { spawn = vector4(1188.18, 2657.56, 37.79, 316.74), list = { 'flatbed', 'towtruck', 'minivan', 'blista' } }, - shopItems = { - { name = 'veh_toolbox', price = 5000, amount = 50 }, - { name = 'veh_armor', price = 5000, amount = 50 }, - { name = 'veh_brakes', price = 5000, amount = 50 }, - { name = 'veh_engine', price = 5000, amount = 50 }, - { name = 'veh_suspension', price = 5000, amount = 50 }, - { name = 'veh_transmission', price = 5000, amount = 50 }, - { name = 'veh_turbo', price = 5000, amount = 50 }, - { name = 'veh_interior', price = 5000, amount = 50 }, - { name = 'veh_exterior', price = 5000, amount = 50 }, - { name = 'veh_wheels', price = 5000, amount = 50 }, - { name = 'veh_neons', price = 5000, amount = 50 }, - { name = 'veh_xenons', price = 5000, amount = 50 }, - { name = 'veh_tint', price = 5000, amount = 50 }, - { name = 'veh_plates', price = 5000, amount = 50 }, - { name = 'nitrous', price = 5000, amount = 50 }, - { name = 'tunerlaptop', price = 5000, amount = 50 }, - { name = 'repairkit', price = 5000, amount = 50 }, - { name = 'advancedrepairkit', price = 5000, amount = 50 }, - { name = 'tirerepairkit', price = 5000, amount = 50 }, - } }, mechanic3 = { -- Airport Location managed = true, @@ -114,7 +70,6 @@ Config.Shops = { blipSprite = 72, blipColor = 46, blipCoords = vector3(-1154.92, -2006.41, 13.18), - shop = vector3(-1156.56, -1999.85, 13.19), duty = vector3(-1149.17, -1998.27, 13.91), stash = vector3(-1146.40, -2002.05, 13.19), paint = vector3(-1170.60, -2014.90, 13.23), @@ -123,27 +78,6 @@ Config.Shops = { spawn = vector4(-1137.42, -1993.26, 13.14, 226.07), list = { 'flatbed', 'towtruck', 'minivan', 'blista' } }, - shopItems = { - { name = 'veh_toolbox', price = 5000, amount = 50 }, - { name = 'veh_armor', price = 5000, amount = 50 }, - { name = 'veh_brakes', price = 5000, amount = 50 }, - { name = 'veh_engine', price = 5000, amount = 50 }, - { name = 'veh_suspension', price = 5000, amount = 50 }, - { name = 'veh_transmission', price = 5000, amount = 50 }, - { name = 'veh_turbo', price = 5000, amount = 50 }, - { name = 'veh_interior', price = 5000, amount = 50 }, - { name = 'veh_exterior', price = 5000, amount = 50 }, - { name = 'veh_wheels', price = 5000, amount = 50 }, - { name = 'veh_neons', price = 5000, amount = 50 }, - { name = 'veh_xenons', price = 5000, amount = 50 }, - { name = 'veh_tint', price = 5000, amount = 50 }, - { name = 'veh_plates', price = 5000, amount = 50 }, - { name = 'nitrous', price = 5000, amount = 50 }, - { name = 'tunerlaptop', price = 5000, amount = 50 }, - { name = 'repairkit', price = 5000, amount = 50 }, - { name = 'advancedrepairkit', price = 5000, amount = 50 }, - { name = 'tirerepairkit', price = 5000, amount = 50 }, - } }, bennys = { -- Default Bennys Location managed = true, @@ -152,7 +86,6 @@ Config.Shops = { blipSprite = 72, blipColor = 46, blipCoords = vector3(-211.73, -1325.28, 30.89), - shop = vector3(-195.80, -1318.24, 31.08), duty = vector3(-202.92, -1313.74, 31.70), stash = vector3(-199.58, -1314.65, 31.08), paint = vector3(-202.42, -1322.16, 31.29), @@ -161,27 +94,6 @@ Config.Shops = { spawn = vector4(-370.51, -107.88, 38.35, 72.56), list = { 'flatbed', 'towtruck', 'minivan', 'blista' } }, - shopItems = { - { name = 'veh_toolbox', price = 5000, amount = 50 }, - { name = 'veh_armor', price = 5000, amount = 50 }, - { name = 'veh_brakes', price = 5000, amount = 50 }, - { name = 'veh_engine', price = 5000, amount = 50 }, - { name = 'veh_suspension', price = 5000, amount = 50 }, - { name = 'veh_transmission', price = 5000, amount = 50 }, - { name = 'veh_turbo', price = 5000, amount = 50 }, - { name = 'veh_interior', price = 5000, amount = 50 }, - { name = 'veh_exterior', price = 5000, amount = 50 }, - { name = 'veh_wheels', price = 5000, amount = 50 }, - { name = 'veh_neons', price = 5000, amount = 50 }, - { name = 'veh_xenons', price = 5000, amount = 50 }, - { name = 'veh_tint', price = 5000, amount = 50 }, - { name = 'veh_plates', price = 5000, amount = 50 }, - { name = 'nitrous', price = 5000, amount = 50 }, - { name = 'tunerlaptop', price = 5000, amount = 50 }, - { name = 'repairkit', price = 5000, amount = 50 }, - { name = 'advancedrepairkit', price = 5000, amount = 50 }, - { name = 'tirerepairkit', price = 5000, amount = 50 }, - } }, beeker = { -- Paleto Location managed = true, @@ -190,7 +102,6 @@ Config.Shops = { blipSprite = 72, blipColor = 46, blipCoords = vector3(109.95, 6627.34, 31.79), - shop = vector3(100.92, 6616.00, 32.47), duty = vector3(101.74, 6620.04, 32.95), stash = vector3(107.00, 6629.88, 31.81), paint = vector3(102.17, 6626.08, 31.79), @@ -199,26 +110,5 @@ Config.Shops = { spawn = vector4(110.91, 6609.32, 31.81, 315.11), list = { 'flatbed', 'towtruck', 'minivan', 'blista' } }, - shopItems = { - { name = 'veh_toolbox', price = 5000, amount = 50 }, - { name = 'veh_armor', price = 5000, amount = 50 }, - { name = 'veh_brakes', price = 5000, amount = 50 }, - { name = 'veh_engine', price = 5000, amount = 50 }, - { name = 'veh_suspension', price = 5000, amount = 50 }, - { name = 'veh_transmission', price = 5000, amount = 50 }, - { name = 'veh_turbo', price = 5000, amount = 50 }, - { name = 'veh_interior', price = 5000, amount = 50 }, - { name = 'veh_exterior', price = 5000, amount = 50 }, - { name = 'veh_wheels', price = 5000, amount = 50 }, - { name = 'veh_neons', price = 5000, amount = 50 }, - { name = 'veh_xenons', price = 5000, amount = 50 }, - { name = 'veh_tint', price = 5000, amount = 50 }, - { name = 'veh_plates', price = 5000, amount = 50 }, - { name = 'nitrous', price = 5000, amount = 50 }, - { name = 'tunerlaptop', price = 5000, amount = 50 }, - { name = 'repairkit', price = 5000, amount = 50 }, - { name = 'advancedrepairkit', price = 5000, amount = 50 }, - { name = 'tirerepairkit', price = 5000, amount = 50 }, - } }, } diff --git a/server/main.lua b/server/main.lua index 3cf4686..2b9aa83 100644 --- a/server/main.lua +++ b/server/main.lua @@ -94,6 +94,25 @@ end) -- Events +RegisterNetEvent('qb-mechanicjob:server:stash', function(data) + local src = source + local shopName = data.job + if not Config.Shops[shopName] then return end + local Player = QBCore.Functions.GetPlayer(src) + if not Player then return end + if Config.Shops[shopName].managed and Player.PlayerData.job.name ~= shopName then return end + local playerPed = GetPlayerPed(src) + local playerCoords = GetEntityCoords(playerPed) + local stashCoords = Config.Shops[shopName].stash + if #(playerCoords - stashCoords) < 2.5 then + local stashName = shopName .. '_stash' + exports['qb-inventory']:OpenInventory(src, stashName, { + maxweight = 4000000, + slots = 100, + }) + end +end) + RegisterNetEvent('qb-mechanicjob:server:sprayVehicleCustom', function(netId, section, type, color) local vehicle = NetworkGetEntityFromNetworkId(netId) local vehicleCoords = GetEntityCoords(vehicle) @@ -225,8 +244,8 @@ RegisterNetEvent('qb-mechanicjob:server:removeItem', function(part, amount) local Player = QBCore.Functions.GetPlayer(src) if not Player then return end if not amount then amount = 1 end - if not Player.Functions.RemoveItem(part, amount) then DropPlayer(src, 'Tried to remove item') end - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[part], 'remove') + if not exports['qb-inventory']:RemoveItem(src, part, amount, false, 'qb-mechanicjob:server:removeItem') then DropPlayer(src, 'qb-mechanicjob:server:removeItem') end + TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items[part], 'remove') end) -- Items