Skip to content

Commit

Permalink
convert zones to ox_lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Molicheu authored and Molicheu committed Dec 21, 2023
1 parent 4c3b4a2 commit 88592d1
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 197 deletions.
63 changes: 32 additions & 31 deletions client/fleeca.lua
Original file line number Diff line number Diff line change
Expand Up @@ -451,55 +451,56 @@ end)

CreateThread(function()
for i = 1, #sharedConfig.smallBanks do
local bankZone = BoxZone:Create(sharedConfig.smallBanks[i].coords, 1.0, 1.0, {
local bankZone = lib.zones.box({
name = 'fleeca_'..i..'_coords_electronickit',
heading = sharedConfig.smallBanks[i].coords.closed,
minZ = sharedConfig.smallBanks[i].coords.z - 1,
maxZ = sharedConfig.smallBanks[i].coords.z + 1,
debugPoly = false
coords = sharedConfig.smallBanks[i].coords,
size = vec3(1, 1, 2),
rotation = sharedConfig.smallBanks[i].coords.closed,
debug = false
})
for k in pairs(sharedConfig.smallBanks[i].lockers) do
if config.useTarget then
exports['qb-target']:AddBoxZone('fleeca_'..i..'_coords_locker_'..k, sharedConfig.smallBanks[i].lockers[k].coords, 1.0, 1.0, {
name = 'fleeca_'..i..'_coords_locker_'..k,
heading = sharedConfig.smallBanks[i].heading.closed,
minZ = sharedConfig.smallBanks[i].lockers[k].coords.z - 1,
maxZ = sharedConfig.smallBanks[i].lockers[k].coords.z + 1,
debugPoly = false
}, {
exports.ox_target:addBoxZone({
coords = sharedConfig.smallBanks[i].lockers[k].coords,
size = vec3(1, 1, 2),
rotation = sharedConfig.smallBanks[i].heading.closed,
debug = false,
drawSprite = true,
options = {
{
action = function()
openLocker(closestBank, k)
end,
label = Lang:t('general.break_safe_open_option_target'),
name = 'fleeca_'..i..'_coords_locker_'..k,
icon = 'fa-solid fa-vault',
distance = 1.5,
canInteract = function()
return closestBank ~= 0 and not isDrilling and sharedConfig.smallBanks[i].isOpened and not sharedConfig.smallBanks[i].lockers[k].isOpened and not sharedConfig.smallBanks[i].lockers[k].isBusy
end,
icon = 'fa-solid fa-vault',
label = Lang:t('general.break_safe_open_option_target'),
onSelect = function()
openLocker(closestBank, k)
end,
},
},
distance = 1.5
})
else
local lockerZone = BoxZone:Create(sharedConfig.smallBanks[i].lockers[k].coords, 1.0, 1.0, {
local lockerZone = lib.zones.box({
name = 'fleeca_'..i..'_coords_locker_'..k,
heading = sharedConfig.smallBanks[i].heading.closed,
minZ = sharedConfig.smallBanks[i].lockers[k].coords.z - 1,
maxZ = sharedConfig.smallBanks[i].lockers[k].coords.z + 1,
debugPoly = false
})
lockerZone:onPlayerInOut(function(inside)
if inside and closestBank ~= 0 and not isDrilling and sharedConfig.smallBanks[i].isOpened and not sharedConfig.smallBanks[i].lockers[k].isOpened and not sharedConfig.smallBanks[i].lockers[k].isBusy then
lib.showTextUI(Lang:t('general.break_safe_open_option_drawtext'), {position = 'left-center'})
currentLocker = k
else
coords = sharedConfig.smallBanks[i].lockers[k].coords,
size = vec3(1, 1, 2),
rotation = sharedConfig.smallBanks[i].heading.closed,
debug = false,
onEnter = function()
if closestBank ~= 0 and not isDrilling and sharedConfig.smallBanks[i].isOpened and not sharedConfig.smallBanks[i].lockers[k].isOpened and not sharedConfig.smallBanks[i].lockers[k].isBusy then
lib.showTextUI(Lang:t('general.break_safe_open_option_drawtext'), {position = 'right-center'})
currentLocker = k
end
end,
onExit = function()
if currentLocker == k then
currentLocker = 0
lib.hideTextUI()
end
end
end)
end,
})
end
end
end
Expand Down
183 changes: 93 additions & 90 deletions client/pacific.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,132 +119,135 @@ end)
-- Threads

CreateThread(function()
local bankCardBZone = BoxZone:Create(pacificConfig.coords[1], 1.0, 1.0, {
local bankCardBZone = lib.zones.box({
name = 'pacific_coords_bankcardb',
heading = pacificConfig.heading.closed,
minZ = pacificConfig.coords[1].z - 1,
maxZ = pacificConfig.coords[1].z + 1,
debugPoly = false
})
bankCardBZone:onPlayerInOut(function(inside)
inBankCardBZone = inside
if inside and not pacificConfig.isOpened then
-- Config.ShowRequiredItems({
-- [1] = {name = exports.ox_inventory:Items().security_card_02.name, image = exports.ox_inventory:Items().security_card_02.image}
-- }, true)
else
coords = pacificConfig.coords[1],
size = vec3(1, 1, 2),
rotation = pacificConfig.heading.closed,
debug = false,
onEnter = function()
if not pacificConfig.isOpened then
-- Config.ShowRequiredItems({
-- [1] = {name = exports.ox_inventory:Items().security_card_02.name, image = exports.ox_inventory:Items().security_card_02.image}
-- }, true)
end
end,
onExit = function()
-- Config.ShowRequiredItems({
-- [1] = {name = exports.ox_inventory:Items().security_card_02.name, image = exports.ox_inventory:Items().security_card_02.image}
-- }, false)
end
end)
local electronickitZone = BoxZone:Create(pacificConfig.coords[2], 1.0, 1.0, {
name = 'pacific_coords_electronickit',
heading = pacificConfig.heading.closed,
minZ = pacificConfig.coords[2].z - 1,
maxZ = pacificConfig.coords[2].z + 1,
debugPoly = false
end,
})
electronickitZone:onPlayerInOut(function(inside)
inElectronickitZone = inside
if inside and not pacificConfig.isOpened then
-- Config.ShowRequiredItems({
-- [1] = {name = exports.ox_inventory:Items().electronickit.name, image = exports.ox_inventory:Items().electronickit.image},
-- [2] = {name = exports.ox_inventory:Items().trojan_usb.name, image = exports.ox_inventory:Items().trojan_usb.image}
-- }, true)
else
local electronickitZone = lib.zones.box({
name = 'pacific_coords_electronickit',
coords = pacificConfig.coords[2],
size = vec3(1, 1, 2),
rotation = pacificConfig.heading.closed,
debug = false,
onEnter = function()
if not pacificConfig.isOpened then
-- Config.ShowRequiredItems({
-- [1] = {name = exports.ox_inventory:Items().electronickit.name, image = exports.ox_inventory:Items().electronickit.image},
-- [2] = {name = exports.ox_inventory:Items().trojan_usb.name, image = exports.ox_inventory:Items().trojan_usb.image}
-- }, true)
end
end,
onExit = function()
-- Config.ShowRequiredItems({
-- [1] = {name = exports.ox_inventory:Items().electronickit.name, image = exports.ox_inventory:Items().electronickit.image},
-- [2] = {name = exports.ox_inventory:Items().trojan_usb.name, image = exports.ox_inventory:Items().trojan_usb.image}
-- }, false)
end
end)
local thermite1Zone = BoxZone:Create(pacificConfig.thermite[1].coords, 1.0, 1.0, {
name = 'pacific_coords_thermite_1',
heading = pacificConfig.heading.closed,
minZ = pacificConfig.thermite[1].coords.z - 1,
maxZ = pacificConfig.thermite[1].coords.z + 1,
debugPoly = false
end,
})
thermite1Zone:onPlayerInOut(function(inside)
if inside and not pacificConfig.thermite[1].isOpened then
currentThermiteGate = pacificConfig.thermite[1].doorId
-- Config.ShowRequiredItems({
-- [1] = {name = exports.ox_inventory:Items().thermite.name, image = exports.ox_inventory:Items().thermite.image},
-- }, true)
else
local thermite1Zone = lib.zones.box({
name = 'pacific_coords_thermite_1',
coords = pacificConfig.thermite[1].coords,
size = vec3(1, 1, 2),
rotation = pacificConfig.heading.closed,
debug = false,
onEnter = function()
if not pacificConfig.thermite[1].isOpened then
currentThermiteGate = pacificConfig.thermite[1].doorId
-- Config.ShowRequiredItems({
-- [1] = {name = exports.ox_inventory:Items().thermite.name, image = exports.ox_inventory:Items().thermite.image},
-- }, true)
end
end,
onExit = function()
if currentThermiteGate == pacificConfig.thermite[1].doorId then
currentThermiteGate = 0
-- Config.ShowRequiredItems({
-- [1] = {name = exports.ox_inventory:Items().thermite.name, image = exports.ox_inventory:Items().thermite.image},
-- }, false)
end
end
end)
local thermite2Zone = BoxZone:Create(pacificConfig.thermite[2].coords, 1.0, 1.0, {
name = 'pacific_coords_thermite_2',
heading = pacificConfig.heading.closed,
minZ = pacificConfig.thermite[2].coords.z - 1,
maxZ = pacificConfig.thermite[2].coords.z + 1,
debugPoly = false
end,
})
thermite2Zone:onPlayerInOut(function(inside)
if inside and not pacificConfig.thermite[2].isOpened then
currentThermiteGate = pacificConfig.thermite[2].doorId
-- Config.ShowRequiredItems({
-- [1] = {name = exports.ox_inventory:Items().thermite.name, image = exports.ox_inventory:Items().thermite.image},
-- }, true)
else
local thermite2Zone = lib.zones.box({
name = 'pacific_coords_thermite_2',
coords = pacificConfig.thermite[2].coords,
size = vec3(1, 1, 2),
rotation = pacificConfig.heading.closed,
debug = false,
onEnter = function()
if not pacificConfig.thermite[2].isOpened then
currentThermiteGate = pacificConfig.thermite[2].doorId
-- Config.ShowRequiredItems({
-- [1] = {name = exports.ox_inventory:Items().thermite.name, image = exports.ox_inventory:Items().thermite.image},
-- }, true)
end
end,
onExit = function()
if currentThermiteGate == pacificConfig.thermite[2].doorId then
currentThermiteGate = 0
-- Config.ShowRequiredItems({
-- [1] = {name = exports.ox_inventory:Items().thermite.name, image = exports.ox_inventory:Items().thermite.image},
-- }, false)
end
end
end)
end,
})
for k in pairs(pacificConfig.lockers) do
if config.useTarget then
exports['qb-target']:AddBoxZone('pacific_coords_locker_'..k, pacificConfig.lockers[k].coords, 1.0, 1.0, {
name = 'pacific_coords_locker_'..k,
heading = pacificConfig.heading.closed,
minZ = pacificConfig.lockers[k].coords.z - 1,
maxZ = pacificConfig.lockers[k].coords.z + 1,
debugPoly = false
}, {
exports.ox_target:addBoxZone({
coords = pacificConfig.lockers[k].coords,
size = vec3(1, 1, 2),
rotation = pacificConfig.heading.closed,
debug = false,
drawSprite = true,
options = {
{
action = function()
openLocker('pacific', k)
end,
label = Lang:t('general.break_safe_open_option_target'),
name = 'pacific_coords_locker_'..k,
icon = 'fa-solid fa-vault',
distance = 1.5,
canInteract = function()
return not isDrilling and pacificConfig.isOpened and not pacificConfig.lockers[k].isBusy and not pacificConfig.lockers[k].isOpened
end,
icon = 'fa-solid fa-vault',
label = Lang:t('general.break_safe_open_option_target'),
onSelect = function()
openLocker('pacific', k)
end,
},
},
distance = 1.5
})
else
local lockerZone = BoxZone:Create(pacificConfig.lockers[k].coords, 1.0, 1.0, {
local lockerZone = lib.zones.box({
name = 'pacific_coords_locker_'..k,
heading = pacificConfig.heading.closed,
minZ = pacificConfig.lockers[k].coords.z - 1,
maxZ = pacificConfig.lockers[k].coords.z + 1,
debugPoly = false
})
lockerZone:onPlayerInOut(function(inside)
if inside and not isDrilling and pacificConfig.isOpened and not pacificConfig.lockers[k].isBusy and not pacificConfig.lockers[k].isOpened then
exports['qbx-core']:DrawText(Lang:t('general.break_safe_open_option_drawtext'), 'right')
currentLocker = k
else
coords = pacificConfig.lockers[k].coords,
size = vec3(1, 1, 2),
rotation = pacificConfig.heading.closed,
debug = false,
onEnter = function()
if not isDrilling and pacificConfig.isOpened and not pacificConfig.lockers[k].isBusy and not pacificConfig.lockers[k].isOpened then
lib.showTextUI(Lang:t('general.break_safe_open_option_drawtext'), {position = 'right-center'})
currentLocker = k
end
end,
onExit = function()
if currentLocker == k then
currentLocker = 0
exports['qbx-core']:HideText()
lib.hideTextUI()
end
end
end)
end,
})
end
end
if not config.useTarget then
Expand All @@ -254,9 +257,9 @@ CreateThread(function()
if currentLocker ~= 0 and not isDrilling and pacificConfig.isOpened and not pacificConfig.lockers[currentLocker].isBusy and not pacificConfig.lockers[currentLocker].isOpened then
sleep = 0
if IsControlJustPressed(0, 38) then
exports['qbx-core']:KeyPressed()
exports.qbx_core:KeyPressed()
Wait(500)
exports['qbx-core']:HideText()
lib.hideTextUI()
if CurrentCops >= config.minPacificPolice then
openLocker('pacific', currentLocker)
else
Expand Down
Loading

0 comments on commit 88592d1

Please sign in to comment.