59 lines
		
	
	
		
			No EOL
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			No EOL
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
local QBCore = exports['qb-core']:GetCoreObject()
 | 
						|
 | 
						|
Config = {}
 | 
						|
Config.lockerProps = {'h4_prop_h4_ld_keypad_01b'} -- Props you can access storage
 | 
						|
Config.Locations = {
 | 
						|
    [1] = { 
 | 
						|
        name = 'SD',
 | 
						|
        location = vector3(1827.6656, 3680.0276, 34.4050),
 | 
						|
        radius = 8.0,
 | 
						|
        maxweight = 30000,
 | 
						|
        slots = 32.0,
 | 
						|
    },
 | 
						|
    [2] = { 
 | 
						|
        name = 'Lagerhaus Sandy',
 | 
						|
        location = vector3(182.5523, 2792.6450, 45.6404),
 | 
						|
        radius = 8.0,
 | 
						|
        maxweight = 400000,
 | 
						|
        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) |