diff --git a/resources/[inventory]/rj-lockers/client.lua b/resources/[inventory]/rj-lockers/client.lua new file mode 100644 index 000000000..f3f773303 --- /dev/null +++ b/resources/[inventory]/rj-lockers/client.lua @@ -0,0 +1,59 @@ +local QBCore = exports['qb-core']:GetCoreObject() + +Config = {} +Config.lockerProps = {'p_cs_locker_01_s'} -- Props you can access storage +Config.Locations = { + [1] = { + name = 'MezeBank', + location = vector3(-203.46, -2046.54, 27.62), + radius = 8.0, + maxweight = 30000, + slots = 32.0, + }, + [2] = { + name = 'Observ', + location = vector3(-226.12, -2030.87, 27.76), + radius = 10.0, + maxweight = 30000, + slots = 32.0, + }, +} + +Citizen.CreateThread(function() + + exports['qb-target']:AddTargetModel(Config.lockerProps, { + options = { + { + id = 1, + icon = "fa-solid fa-lock", + label = "Open personal locker", + action = function(entity) + TriggerEvent('rj-lockers:openLocker', entity) + end, + }, + }, + distance = 1.5 + }) + +end) + +RegisterNetEvent('rj-lockers:openLocker', function(entity) + + local PlayerData = QBCore.Functions.GetPlayerData() + local lockerLoc = GetEntityCoords(entity) + local accessGranted = false + + for x, v in pairs(Config.Locations) do + if GetDistanceBetweenCoords(lockerLoc, v.location) < v.radius then + TriggerServerEvent("inventory:server:OpenInventory", "stash", v.name .. "_" .. PlayerData.citizenid, {maxweight = v.maxweight, slots = v.slots}) + TriggerEvent("inventory:client:SetCurrentStash", v.name .. "_" .. PlayerData.citizenid) + accessGranted = true + break + end + end + + if not accessGranted then + QBCore.Functions.Notify('You cannot access this locker', 'error', 5000) + end + +end) \ No newline at end of file diff --git a/resources/[inventory]/rj-lockers/fxmanifest.lua b/resources/[inventory]/rj-lockers/fxmanifest.lua new file mode 100644 index 000000000..a3cb29408 --- /dev/null +++ b/resources/[inventory]/rj-lockers/fxmanifest.lua @@ -0,0 +1,10 @@ +fx_version 'cerulean' +game 'gta5' + +author 'RJ-Scripts' +description 'rj-lockers for QBCore' +version '1.0.0' + +client_script { + 'client.lua', +} \ No newline at end of file