diff --git a/client/doors.lua b/client/doors.lua index 637703e..708ade7 100644 --- a/client/doors.lua +++ b/client/doors.lua @@ -1,60 +1,59 @@ -local sharedConfig = require 'config.shared' +local bigBanks = require 'config.shared'.bigBanks RegisterNetEvent('qb-bankrobbery:client:ClearTimeoutDoors', function() --Config.DoorlockAction(4, true) - local PaletoObject = GetClosestObjectOfType(sharedConfig.bigBanks["paleto"]["coords"]["x"], sharedConfig.bigBanks["paleto"]["coords"]["y"], sharedConfig.bigBanks["paleto"]["coords"]["z"], 5.0, sharedConfig.bigBanks["paleto"]["object"], false, false, false) - if PaletoObject ~= 0 then - SetEntityHeading(PaletoObject, sharedConfig.bigBanks["paleto"]["heading"].closed) + local paletoObject = GetClosestObjectOfType(bigBanks.paleto.coords.x, bigBanks.paleto.coords.y, bigBanks.paleto.coords.z, 5.0, bigBanks.paleto.object, false, false, false) + if paletoObject ~= 0 then + SetEntityHeading(paletoObject, bigBanks.paleto.heading.closed) end - local object = GetClosestObjectOfType(sharedConfig.bigBanks["pacific"]["coords"][2]["x"], sharedConfig.bigBanks["pacific"]["coords"][2]["y"], sharedConfig.bigBanks["pacific"]["coords"][2]["z"], 20.0, sharedConfig.bigBanks["pacific"]["object"], false, false, false) + local object = GetClosestObjectOfType(bigBanks.pacific.coords[2].x, bigBanks.pacific.coords[2].y, bigBanks.pacific.coords[2].z, 20.0, bigBanks.pacific.object, false, false, false) if object ~= 0 then - SetEntityHeading(object, sharedConfig.bigBanks["pacific"]["heading"].closed) + SetEntityHeading(object, bigBanks.pacific.heading.closed) end - for k in pairs(sharedConfig.bigBanks["pacific"]["lockers"]) do - sharedConfig.bigBanks["pacific"]["lockers"][k]["isBusy"] = false - sharedConfig.bigBanks["pacific"]["lockers"][k]["isOpened"] = false + for k in pairs(bigBanks.pacific.lockers) do + bigBanks.pacific.lockers[k].isBusy = false + bigBanks.pacific.lockers[k].isOpened = false end - for k in pairs(sharedConfig.bigBanks["paleto"]["lockers"]) do - sharedConfig.bigBanks["paleto"]["lockers"][k]["isBusy"] = false - sharedConfig.bigBanks["paleto"]["lockers"][k]["isOpened"] = false + for k in pairs(bigBanks.paleto.lockers) do + bigBanks.paleto.lockers[k].isBusy = false + bigBanks.paleto.lockers[k].isOpened = false end - sharedConfig.bigBanks["paleto"]["isOpened"] = false - sharedConfig.bigBanks["pacific"]["isOpened"] = false + bigBanks.paleto.isOpened = false + bigBanks.pacific.isOpened = false end) CreateThread(function() while true do - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) - local PaletoDist = #(pos - sharedConfig.bigBanks["paleto"]["coords"]) - local PacificDist = #(pos - sharedConfig.bigBanks["pacific"]["coords"][2]) - if PaletoDist < 15 then - if sharedConfig.bigBanks["paleto"]["isOpened"] then + local pos = GetEntityCoords(cache.ped) + local paletoDist = #(pos - bigBanks.paleto.coords) + local pacificDist = #(pos - bigBanks.pacific.coords[2]) + if paletoDist < 15 then + if bigBanks.paleto.isOpened then --Config.DoorlockAction(4, false) - local object = GetClosestObjectOfType(sharedConfig.bigBanks["paleto"]["coords"]["x"], sharedConfig.bigBanks["paleto"]["coords"]["y"], sharedConfig.bigBanks["paleto"]["coords"]["z"], 5.0, sharedConfig.bigBanks["paleto"]["object"], false, false, false) + local object = GetClosestObjectOfType(bigBanks.paleto.coords.x, bigBanks.paleto.coords.y, bigBanks.paleto.coords.z, 5.0, bigBanks.paleto.object, false, false, false) if object ~= 0 then - SetEntityHeading(object, sharedConfig.bigBanks["paleto"]["heading"].open) + SetEntityHeading(object, bigBanks.paleto.heading.open) end else --Config.DoorlockAction(4, true) - local object = GetClosestObjectOfType(sharedConfig.bigBanks["paleto"]["coords"]["x"], sharedConfig.bigBanks["paleto"]["coords"]["y"], sharedConfig.bigBanks["paleto"]["coords"]["z"], 5.0, sharedConfig.bigBanks["paleto"]["object"], false, false, false) + local object = GetClosestObjectOfType(bigBanks.paleto.coords.x, bigBanks.paleto.coords.y, bigBanks.paleto.coords.z, 5.0, bigBanks.paleto.object, false, false, false) if object ~= 0 then - SetEntityHeading(object, sharedConfig.bigBanks["paleto"]["heading"].closed) + SetEntityHeading(object, bigBanks.paleto.heading.closed) end end end -- Pacific Check - if PacificDist < 50 then - if sharedConfig.bigBanks["pacific"]["isOpened"] then - local object = GetClosestObjectOfType(sharedConfig.bigBanks["pacific"]["coords"][2]["x"], sharedConfig.bigBanks["pacific"]["coords"][2]["y"], sharedConfig.bigBanks["pacific"]["coords"][2]["z"], 20.0, sharedConfig.bigBanks["pacific"]["object"], false, false, false) + if pacificDist < 50 then + if bigBanks.pacific.isOpened then + local object = GetClosestObjectOfType(bigBanks.pacific.coords[2].x, bigBanks.pacific.coords[2].y, bigBanks.pacific.coords[2].z, 20.0, bigBanks.pacific.object, false, false, false) if object ~= 0 then - SetEntityHeading(object, sharedConfig.bigBanks["pacific"]["heading"].open) + SetEntityHeading(object, bigBanks.pacific.heading.open) end else - local object = GetClosestObjectOfType(sharedConfig.bigBanks["pacific"]["coords"][2]["x"], sharedConfig.bigBanks["pacific"]["coords"][2]["y"], sharedConfig.bigBanks["pacific"]["coords"][2]["z"], 20.0, sharedConfig.bigBanks["pacific"]["object"], false, false, false) + local object = GetClosestObjectOfType(bigBanks.pacific.coords[2].x, bigBanks.pacific.coords[2].y, bigBanks.pacific.coords[2].z, 20.0, bigBanks.pacific.object, false, false, false) if object ~= 0 then - SetEntityHeading(object, sharedConfig.bigBanks["pacific"]["heading"].closed) + SetEntityHeading(object, bigBanks.pacific.heading.closed) end end end diff --git a/client/fleeca.lua b/client/fleeca.lua index 43b74f8..ab76d36 100644 --- a/client/fleeca.lua +++ b/client/fleeca.lua @@ -3,7 +3,7 @@ local sharedConfig = require 'config.shared' isLoggedIn = LocalPlayer.state['isLoggedIn'] currentThermiteGate = 0 CurrentCops = 0 -IsDrilling = false +isDrilling = false local closestBank = 0 local inElectronickitZone = false local copsCalled = false @@ -14,34 +14,34 @@ local currentLocker = 0 --- This will reset the bank doors to the position that they should be in, so if the bank is still open, it will open the door and vise versa --- @return nil -local function ResetBankDoors() +local function resetBankDoors() for k in pairs(sharedConfig.smallBanks) do - local object = GetClosestObjectOfType(sharedConfig.smallBanks[k]["coords"]["x"], sharedConfig.smallBanks[k]["coords"]["y"], sharedConfig.smallBanks[k]["coords"]["z"], 5.0, sharedConfig.smallBanks[k]["object"], false, false, false) - if not sharedConfig.smallBanks[k]["isOpened"] then - SetEntityHeading(object, sharedConfig.smallBanks[k]["heading"].closed) + local object = GetClosestObjectOfType(sharedConfig.smallBanks[k].coords.x, sharedConfig.smallBanks[k].coords.y, sharedConfig.smallBanks[k].coords.z, 5.0, sharedConfig.smallBanks[k].object, false, false, false) + if not sharedConfig.smallBanks[k].isOpened then + SetEntityHeading(object, sharedConfig.smallBanks[k].heading.closed) else - SetEntityHeading(object, sharedConfig.smallBanks[k]["heading"].open) + SetEntityHeading(object, sharedConfig.smallBanks[k].heading.open) end end - if not sharedConfig.bigBanks["paleto"]["isOpened"] then - local paletoObject = GetClosestObjectOfType(sharedConfig.bigBanks["paleto"]["coords"]["x"], sharedConfig.bigBanks["paleto"]["coords"]["y"], sharedConfig.bigBanks["paleto"]["coords"]["z"], 5.0, sharedConfig.bigBanks["paleto"]["object"], false, false, false) - SetEntityHeading(paletoObject, sharedConfig.bigBanks["paleto"]["heading"].closed) + if not sharedConfig.bigBanks.paleto.isOpened then + local paletoObject = GetClosestObjectOfType(sharedConfig.bigBanks.paleto.coords.x, sharedConfig.bigBanks.paleto.coords.y, sharedConfig.bigBanks.paleto.coords.z, 5.0, sharedConfig.bigBanks.paleto.object, false, false, false) + SetEntityHeading(paletoObject, sharedConfig.bigBanks.paleto.heading.closed) else - local paletoObject = GetClosestObjectOfType(sharedConfig.bigBanks["paleto"]["coords"]["x"], sharedConfig.bigBanks["paleto"]["coords"]["y"], sharedConfig.bigBanks["paleto"]["coords"]["z"], 5.0, sharedConfig.bigBanks["paleto"]["object"], false, false, false) - SetEntityHeading(paletoObject, sharedConfig.bigBanks["paleto"]["heading"].open) + local paletoObject = GetClosestObjectOfType(sharedConfig.bigBanks.paleto.coords.x, sharedConfig.bigBanks.paleto.coords.y, sharedConfig.bigBanks.paleto.coords.z, 5.0, sharedConfig.bigBanks.paleto.object, false, false, false) + SetEntityHeading(paletoObject, sharedConfig.bigBanks.paleto.heading.open) end - if not sharedConfig.bigBanks["pacific"]["isOpened"] then - local pacificObject = GetClosestObjectOfType(sharedConfig.bigBanks["pacific"]["coords"][2]["x"], sharedConfig.bigBanks["pacific"]["coords"][2]["y"], sharedConfig.bigBanks["pacific"]["coords"][2]["z"], 20.0, sharedConfig.bigBanks["pacific"]["object"], false, false, false) - SetEntityHeading(pacificObject, sharedConfig.bigBanks["pacific"]["heading"].closed) + if not sharedConfig.bigBanks.pacific.isOpened then + local pacificObject = GetClosestObjectOfType(sharedConfig.bigBanks.pacific.coords[2].x, sharedConfig.bigBanks.pacific.coords[2].y, sharedConfig.bigBanks.pacific.coords[2].z, 20.0, sharedConfig.bigBanks.pacific.object, false, false, false) + SetEntityHeading(pacificObject, sharedConfig.bigBanks.pacific.heading.closed) else - local pacificObject = GetClosestObjectOfType(sharedConfig.bigBanks["pacific"]["coords"][2]["x"], sharedConfig.bigBanks["pacific"]["coords"][2]["y"], sharedConfig.bigBanks["pacific"]["coords"][2]["z"], 20.0, sharedConfig.bigBanks["pacific"]["object"], false, false, false) - SetEntityHeading(pacificObject, sharedConfig.bigBanks["pacific"]["heading"].open) + local pacificObject = GetClosestObjectOfType(sharedConfig.bigBanks.pacific.coords[2].x, sharedConfig.bigBanks.pacific.coords[2].y, sharedConfig.bigBanks.pacific.coords[2].z, 20.0, sharedConfig.bigBanks.pacific.object, false, false, false) + SetEntityHeading(pacificObject, sharedConfig.bigBanks.pacific.heading.open) end end AddEventHandler('onResourceStop', function(resource) if resource ~= GetCurrentResourceName() then return end - ResetBankDoors() + resetBankDoors() end) RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() @@ -49,7 +49,7 @@ RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() sharedConfig.powerStations = config1 sharedConfig.bigBanks = config2 sharedConfig.smallBanks = config3 - ResetBankDoors() + resetBankDoors() isLoggedIn = true end) @@ -61,22 +61,22 @@ end) --- This will open the bank door of the paleto bank --- @return nil -local function OpenPaletoDoor() +local function openPaletoDoor() --Config.DoorlockAction(4, false) - local object = GetClosestObjectOfType(sharedConfig.bigBanks["paleto"]["coords"]["x"], sharedConfig.bigBanks["paleto"]["coords"]["y"], sharedConfig.bigBanks["paleto"]["coords"]["z"], 5.0, sharedConfig.bigBanks["paleto"]["object"], false, false, false) + local object = GetClosestObjectOfType(sharedConfig.bigBanks.paleto.coords.x, sharedConfig.bigBanks.paleto.coords.y, sharedConfig.bigBanks.paleto.coords.z, 5.0, sharedConfig.bigBanks.paleto.object, false, false, false) if object ~= 0 then - SetEntityHeading(object, sharedConfig.bigBanks["paleto"]["heading"].open) + SetEntityHeading(object, sharedConfig.bigBanks.paleto.heading.open) end end --- This will open the bank door of the pacific bank --- @return nil -local function OpenPacificDoor() - local object = GetClosestObjectOfType(sharedConfig.bigBanks["pacific"]["coords"][2]["x"], sharedConfig.bigBanks["pacific"]["coords"][2]["y"], sharedConfig.bigBanks["pacific"]["coords"][2]["z"], 20.0, sharedConfig.bigBanks["pacific"]["object"], false, false, false) - local entHeading = sharedConfig.bigBanks["pacific"]["heading"].closed +local function openPacificDoor() + local object = GetClosestObjectOfType(sharedConfig.bigBanks.pacific.coords[2].x, sharedConfig.bigBanks.pacific.coords[2].y, sharedConfig.bigBanks.pacific.coords[2].z, 20.0, sharedConfig.bigBanks.pacific.object, false, false, false) + local entHeading = sharedConfig.bigBanks.pacific.heading.closed if object ~= 0 then CreateThread(function() - while entHeading > sharedConfig.bigBanks["pacific"]["heading"].open do + while entHeading > sharedConfig.bigBanks.pacific.heading.open do SetEntityHeading(object, entHeading - 10) entHeading -= 0.5 Wait(10) @@ -88,7 +88,7 @@ end --- This is triggered once the hack at a small bank is done --- @param success boolean --- @return nil -local function OnHackDone(success) +local function onHackDone(success) TriggerEvent('mhacking:hide') if not success then return end TriggerServerEvent('qb-bankrobbery:server:setBankState', closestBank) @@ -97,12 +97,12 @@ end --- This will open the bank door of any small bank --- @param bankId number --- @return nil -local function OpenBankDoor(bankId) - local object = GetClosestObjectOfType(sharedConfig.smallBanks[bankId]["coords"]["x"], sharedConfig.smallBanks[bankId]["coords"]["y"], sharedConfig.smallBanks[bankId]["coords"]["z"], 5.0, sharedConfig.smallBanks[bankId]["object"], false, false, false) - local entHeading = sharedConfig.smallBanks[bankId]["heading"].closed +local function openBankDoor(bankId) + local object = GetClosestObjectOfType(sharedConfig.smallBanks[bankId].coords.x, sharedConfig.smallBanks[bankId].coords.y, sharedConfig.smallBanks[bankId].coords.z, 5.0, sharedConfig.smallBanks[bankId].object, false, false, false) + local entHeading = sharedConfig.smallBanks[bankId].heading.closed if object ~= 0 then CreateThread(function() - while entHeading ~= sharedConfig.smallBanks[bankId]["heading"].open do + while entHeading ~= sharedConfig.smallBanks[bankId].heading.open do SetEntityHeading(object, entHeading - 10) entHeading -= 0.5 Wait(10) @@ -116,22 +116,21 @@ end --- @param lockerId number --- @return nil function openLocker(bankId, lockerId) -- Globally Used - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) + local pos = GetEntityCoords(cache.ped) if math.random(1, 100) > 65 or IsWearingGloves() then return end - TriggerServerEvent("evidence:server:CreateFingerDrop", pos) + TriggerServerEvent('evidence:server:CreateFingerDrop', pos) TriggerServerEvent('qb-bankrobbery:server:setLockerState', bankId, lockerId, 'isBusy', true) - if bankId == "paleto" then - local hasItem = HasItem("drill") + if bankId == 'paleto' then + local hasItem = exports.ox_inventory:Search('count', 'drill') > 0 if hasItem then - -- loadAnimDict("anim@heists@fleeca_bank@drilling") - -- TaskPlayAnim(ped, 'anim@heists@fleeca_bank@drilling', 'drill_straight_idle', 3.0, 3.0, -1, 1, 0, false, false, false) - local DrillObject = CreateObject(`hei_prop_heist_drill`, pos.x, pos.y, pos.z, true, true, true) - AttachEntityToEntity(DrillObject, ped, GetPedBoneIndex(ped, 57005), 0.14, 0, -0.01, 90.0, -90.0, 180.0, true, true, false, true, 1, true) - IsDrilling = true + -- loadAnimDict('anim@heists@fleeca_bank@drilling') + -- TaskPlayAnim(cache.ped, 'anim@heists@fleeca_bank@drilling', 'drill_straight_idle', 3.0, 3.0, -1, 1, 0, false, false, false) + local drillObject = CreateObject(`hei_prop_heist_drill`, pos.x, pos.y, pos.z, true, true, true) + AttachEntityToEntity(drillObject, cache.ped, GetPedBoneIndex(cache.ped, 57005), 0.14, 0, -0.01, 90.0, -90.0, 180.0, true, true, false, true, 1, true) + isDrilling = true if lib.progressBar({ duration = 25000, - label = Lang:t("general.breaking_open_safe"), + label = Lang:t('general.breaking_open_safe'), canCancel = true, useWhileDead = false, disable = { @@ -141,42 +140,42 @@ function openLocker(bankId, lockerId) -- Globally Used combat = true }, anim = { - dict = "anim@heists@fleeca_bank@drilling", - clip = "drill_straight_idle", + dict = 'anim@heists@fleeca_bank@drilling', + clip = 'drill_straight_idle', flag = 1 } }) then - DetachEntity(DrillObject, true, true) - DeleteObject(DrillObject) + DetachEntity(drillObject, true, true) + DeleteObject(drillObject) TriggerServerEvent('qb-bankrobbery:server:setLockerState', bankId, lockerId, 'isOpened', true) TriggerServerEvent('qb-bankrobbery:server:setLockerState', bankId, lockerId, 'isBusy', false) TriggerServerEvent('qb-bankrobbery:server:recieveItem', 'paleto', bankId, lockerId) - exports.qbx_core:Notify(Lang:t("success.success_message"), "success") + exports.qbx_core:Notify(Lang:t('success.success_message'), 'success') SetTimeout(500, function() - IsDrilling = false + isDrilling = false end) else TriggerServerEvent('qb-bankrobbery:server:setLockerState', bankId, lockerId, 'isBusy', false) - DetachEntity(DrillObject, true, true) - DeleteObject(DrillObject) - exports.qbx_core:Notify(Lang:t("error.cancel_message"), "error") + DetachEntity(drillObject, true, true) + DeleteObject(drillObject) + exports.qbx_core:Notify(Lang:t('error.cancel_message'), 'error') SetTimeout(500, function() - IsDrilling = false + isDrilling = false end) end else - exports.qbx_core:Notify(Lang:t("error.safe_too_strong"), "error") + exports.qbx_core:Notify(Lang:t('error.safe_too_strong'), 'error') TriggerServerEvent('qb-bankrobbery:server:setLockerState', bankId, lockerId, 'isBusy', false) end - elseif bankId == "pacific" then - local hasItem = HasItem("drill") + elseif bankId == 'pacific' then + local hasItem = exports.ox_inventory:Search('count', 'drill') > 0 if hasItem then - local DrillObject = CreateObject(`hei_prop_heist_drill`, pos.x, pos.y, pos.z, true, true, true) - AttachEntityToEntity(DrillObject, ped, GetPedBoneIndex(ped, 57005), 0.14, 0, -0.01, 90.0, -90.0, 180.0, true, true, false, true, 1, true) - IsDrilling = true + local drillObject = CreateObject(`hei_prop_heist_drill`, pos.x, pos.y, pos.z, true, true, true) + AttachEntityToEntity(drillObject, cache.ped, GetPedBoneIndex(cache.ped, 57005), 0.14, 0, -0.01, 90.0, -90.0, 180.0, true, true, false, true, 1, true) + isDrilling = true if lib.progressBar({ duration = 25000, - label = Lang:t("general.breaking_open_safe"), + label = Lang:t('general.breaking_open_safe'), canCancel = true, useWhileDead = false, disable = { @@ -186,39 +185,39 @@ function openLocker(bankId, lockerId) -- Globally Used combat = true }, anim = { - dict = "anim@heists@fleeca_bank@drilling", - clip = "drill_straight_idle", + dict = 'anim@heists@fleeca_bank@drilling', + clip = 'drill_straight_idle', flag = 1 } }) then - DetachEntity(DrillObject, true, true) - DeleteObject(DrillObject) + DetachEntity(drillObject, true, true) + DeleteObject(drillObject) TriggerServerEvent('qb-bankrobbery:server:setLockerState', bankId, lockerId, 'isOpened', true) TriggerServerEvent('qb-bankrobbery:server:setLockerState', bankId, lockerId, 'isBusy', false) TriggerServerEvent('qb-bankrobbery:server:recieveItem', 'pacific', bankId, lockerId) - exports.qbx_core:Notify(Lang:t("success.success_message"), "success") + exports.qbx_core:Notify(Lang:t('success.success_message'), 'success') SetTimeout(500, function() - IsDrilling = false + isDrilling = false end) else TriggerServerEvent('qb-bankrobbery:server:setLockerState', bankId, lockerId, 'isBusy', false) - DetachEntity(DrillObject, true, true) - DeleteObject(DrillObject) - exports.qbx_core:Notify(Lang:t("error.cancel_message"), "error") + DetachEntity(drillObject, true, true) + DeleteObject(drillObject) + exports.qbx_core:Notify(Lang:t('error.cancel_message'), 'error') SetTimeout(500, function() - IsDrilling = false + isDrilling = false end) end else - exports.qbx_core:Notify(Lang:t("error.safe_too_strong"), "error") + exports.qbx_core:Notify(Lang:t('error.safe_too_strong'), 'error') TriggerServerEvent('qb-bankrobbery:server:setLockerState', bankId, lockerId, 'isBusy', false) end else - IsDrilling = true + isDrilling = true if lib.progressBar({ duration = 32000, - label = Lang:t("general.breaking_open_safe"), + label = Lang:t('general.breaking_open_safe'), canCancel = true, useWhileDead = false, disable = { @@ -228,28 +227,28 @@ function openLocker(bankId, lockerId) -- Globally Used combat = true }, anim = { - dict = "anim@gangops@facility@servers@", - clip = "hotwire", + dict = 'anim@gangops@facility@servers@', + clip = 'hotwire', flag = 1 } }) then TriggerServerEvent('qb-bankrobbery:server:setLockerState', bankId, lockerId, 'isOpened', true) TriggerServerEvent('qb-bankrobbery:server:setLockerState', bankId, lockerId, 'isBusy', false) TriggerServerEvent('qb-bankrobbery:server:recieveItem', 'small', bankId, lockerId) - exports.qbx_core:Notify(Lang:t("success.success_message"), "success") + exports.qbx_core:Notify(Lang:t('success.success_message'), 'success') SetTimeout(500, function() - IsDrilling = false + isDrilling = false end) else TriggerServerEvent('qb-bankrobbery:server:setLockerState', bankId, lockerId, 'isBusy', false) - exports.qbx_core:Notify(Lang:t("error.cancel_message"), "error") + exports.qbx_core:Notify(Lang:t('error.cancel_message'), 'error') SetTimeout(500, function() - IsDrilling = false + isDrilling = false end) end end CreateThread(function() - while IsDrilling do + while isDrilling do TriggerServerEvent('hud:server:GainStress', math.random(4, 8)) Wait(10000) end @@ -259,16 +258,15 @@ end -- Events RegisterNetEvent('electronickit:UseElectronickit', function() - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) + local pos = GetEntityCoords(cache.ped) if math.random(1, 100) > 85 or IsWearingGloves() then return end - TriggerServerEvent("evidence:server:CreateFingerDrop", pos) + TriggerServerEvent('evidence:server:CreateFingerDrop', pos) if closestBank == 0 or not inElectronickitZone then return end local isBusy = lib.callback.await('qb-bankrobbery:server:isRobberyActive', false) if not isBusy then if CurrentCops >= config.minFleecaPolice then - if not sharedConfig.smallBanks[closestBank]["isOpened"] then - local hasItem = HasItem({"trojan_usb", "electronickit"}) + if not sharedConfig.smallBanks[closestBank].isOpened then + local hasItem = (exports.ox_inventory:Search('count', 'trojan_usb') > 0) and (exports.ox_inventory:Search('count', 'electronickit') > 0) if hasItem then -- Config.ShowRequiredItems({ -- [1] = {name = exports.ox_inventory:Items().electronickit.name, image = exports.ox_inventory:Items().electronickit.image}, @@ -276,7 +274,7 @@ RegisterNetEvent('electronickit:UseElectronickit', function() -- }, false) if lib.progressBar({ duration = 7500, - label = Lang:t("general.connecting_hacking_device"), + label = Lang:t('general.connecting_hacking_device'), canCancel = true, useWhileDead = false, disable = { @@ -286,115 +284,115 @@ RegisterNetEvent('electronickit:UseElectronickit', function() combat = true }, anim = { - dict = "anim@gangops@facility@servers@", - clip = "hotwire", + dict = 'anim@gangops@facility@servers@', + clip = 'hotwire', flag = 1 } }) then TriggerServerEvent('qb-bankrobbery:server:removeElectronicKit') - TriggerEvent("mhacking:show") - TriggerEvent("mhacking:start", math.random(6, 7), math.random(12, 15), OnHackDone) - if copsCalled or not sharedConfig.smallBanks[closestBank]["alarm"] then return end - TriggerServerEvent("qb-bankrobbery:server:callCops", "small", closestBank, pos) + TriggerEvent('mhacking:show') + TriggerEvent('mhacking:start', math.random(6, 7), math.random(12, 15), onHackDone) + if copsCalled or not sharedConfig.smallBanks[closestBank].alarm then return end + TriggerServerEvent('qb-bankrobbery:server:callCops', 'small', closestBank, pos) copsCalled = true SetTimeout(60000 * config.outlawCooldown, function() copsCalled = false end) else - exports.qbx_core:Notify(Lang:t("error.cancel_message"), "error") + exports.qbx_core:Notify(Lang:t('error.cancel_message'), 'error') end else - exports.qbx_core:Notify(Lang:t("error.missing_item"), "error") + exports.qbx_core:Notify(Lang:t('error.missing_item'), 'error') end else - exports.qbx_core:Notify(Lang:t("error.bank_already_open"), "error") + exports.qbx_core:Notify(Lang:t('error.bank_already_open'), 'error') end else - exports.qbx_core:Notify(Lang:t("error.minimum_police_required", {police = config.minFleecaPolice}), "error") + exports.qbx_core:Notify(Lang:t('error.minimum_police_required', {police = config.minFleecaPolice}), 'error') end else - exports.qbx_core:Notify(Lang:t("error.security_lock_active"), "error", 5500) + exports.qbx_core:Notify(Lang:t('error.security_lock_active'), 'error', 5500) end end) RegisterNetEvent('qb-bankrobbery:client:setBankState', function(bankId) - if bankId == "paleto" then - sharedConfig.bigBanks["paleto"]["isOpened"] = true - OpenPaletoDoor() - elseif bankId == "pacific" then - sharedConfig.bigBanks["pacific"]["isOpened"] = true - OpenPacificDoor() + if bankId == 'paleto' then + sharedConfig.bigBanks.paleto.isOpened = true + openPaletoDoor() + elseif bankId == 'pacific' then + sharedConfig.bigBanks.pacific.isOpened = true + openPacificDoor() else - sharedConfig.smallBanks[bankId]["isOpened"] = true - OpenBankDoor(bankId) + sharedConfig.smallBanks[bankId].isOpened = true + openBankDoor(bankId) end end) RegisterNetEvent('qb-bankrobbery:client:enableAllBankSecurity', function() for k in pairs(sharedConfig.smallBanks) do - sharedConfig.smallBanks[k]["alarm"] = true + sharedConfig.smallBanks[k].alarm = true end end) RegisterNetEvent('qb-bankrobbery:client:disableAllBankSecurity', function() for k in pairs(sharedConfig.smallBanks) do - sharedConfig.smallBanks[k]["alarm"] = false + sharedConfig.smallBanks[k].alarm = false end end) RegisterNetEvent('qb-bankrobbery:client:BankSecurity', function(key, status) if type(key) == 'table' and table.type(key) == 'array' then for _, v in pairs(key) do - sharedConfig.smallBanks[v]["alarm"] = status + sharedConfig.smallBanks[v].alarm = status end elseif type(key) == 'number' then - sharedConfig.smallBanks[key]["alarm"] = status + sharedConfig.smallBanks[key].alarm = status else - error(Lang:t("error.wrong_type", {receiver = 'qb-bankrobbery:client:BankSecurity', argument = "key", receivedType = type(key), receivedValue = key, expected = "table/array"})) + error(Lang:t('error.wrong_type', {receiver = 'qb-bankrobbery:client:BankSecurity', argument = 'key', receivedType = type(key), receivedValue = key, expected = 'table/array'})) end end) RegisterNetEvent('qb-bankrobbery:client:setLockerState', function(bankId, lockerId, state, bool) - if bankId == "paleto" then - sharedConfig.bigBanks["paleto"]["lockers"][lockerId][state] = bool - elseif bankId == "pacific" then - sharedConfig.bigBanks["pacific"]["lockers"][lockerId][state] = bool + if bankId == 'paleto' then + sharedConfig.bigBanks.paleto.lockers[lockerId][state] = bool + elseif bankId == 'pacific' then + sharedConfig.bigBanks.pacific.lockers[lockerId][state] = bool else - sharedConfig.smallBanks[bankId]["lockers"][lockerId][state] = bool + sharedConfig.smallBanks[bankId].lockers[lockerId][state] = bool end end) RegisterNetEvent('qb-bankrobbery:client:ResetFleecaLockers', function(BankId) - sharedConfig.smallBanks[BankId]["isOpened"] = false - for k in pairs(sharedConfig.smallBanks[BankId]["lockers"]) do - sharedConfig.smallBanks[BankId]["lockers"][k]["isOpened"] = false - sharedConfig.smallBanks[BankId]["lockers"][k]["isBusy"] = false + sharedConfig.smallBanks[BankId].isOpened = false + for k in pairs(sharedConfig.smallBanks[BankId].lockers) do + sharedConfig.smallBanks[BankId].lockers[k].isOpened = false + sharedConfig.smallBanks[BankId].lockers[k].isBusy = false end end) RegisterNetEvent('qb-bankrobbery:client:robberyCall', function(type, coords) if not isLoggedIn then return end local PlayerJob = exports.qbx_core:GetPlayerData().job - if PlayerJob.name ~= "police" or not PlayerJob.onduty then return end - if type == "small" then - PlaySound(-1, "Lose_1st", "GTAO_FM_Events_Soundset", 0, 0, 1) - TriggerServerEvent("police:server:policeAlert", Lang:t("general.fleeca_robbery_alert")) - elseif type == "paleto" then - PlaySound(-1, "Lose_1st", "GTAO_FM_Events_Soundset", 0, 0, 1) + if PlayerJob.name ~= 'police' or not PlayerJob.onduty then return end + if type == 'small' then + PlaySound(-1, 'Lose_1st', 'GTAO_FM_Events_Soundset', false, 0, true) + TriggerServerEvent('police:server:policeAlert', Lang:t('general.fleeca_robbery_alert')) + elseif type == 'paleto' then + PlaySound(-1, 'Lose_1st', 'GTAO_FM_Events_Soundset', false, 0, true) Wait(100) - PlaySoundFrontend( -1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", 1 ) + PlaySoundFrontend( -1, 'Beep_Red', 'DLC_HEIST_HACKING_SNAKE_SOUNDS', true) Wait(100) - PlaySound(-1, "Lose_1st", "GTAO_FM_Events_Soundset", 0, 0, 1) + PlaySound(-1, 'Lose_1st', 'GTAO_FM_Events_Soundset', false, 0, true) Wait(100) - PlaySoundFrontend( -1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", 1 ) - TriggerServerEvent("police:server:policeAlert", Lang:t("general.paleto_robbery_alert")) - elseif type == "pacific" then - PlaySound(-1, "Lose_1st", "GTAO_FM_Events_Soundset", 0, 0, 1) + PlaySoundFrontend( -1, 'Beep_Red', 'DLC_HEIST_HACKING_SNAKE_SOUNDS', true) + TriggerServerEvent('police:server:policeAlert', Lang:t('general.paleto_robbery_alert')) + elseif type == 'pacific' then + PlaySound(-1, 'Lose_1st', 'GTAO_FM_Events_Soundset', false, 0, true) Wait(100) - PlaySoundFrontend( -1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", 1 ) + PlaySoundFrontend( -1, 'Beep_Red', 'DLC_HEIST_HACKING_SNAKE_SOUNDS', true) Wait(100) - PlaySound(-1, "Lose_1st", "GTAO_FM_Events_Soundset", 0, 0, 1) + PlaySound(-1, 'Lose_1st', 'GTAO_FM_Events_Soundset', false, 0, true) Wait(100) - PlaySoundFrontend( -1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", 1 ) - TriggerServerEvent("police:server:policeAlert", Lang:t("general.pacific_robbery_alert")) + PlaySoundFrontend( -1, 'Beep_Red', 'DLC_HEIST_HACKING_SNAKE_SOUNDS', true) + TriggerServerEvent('police:server:policeAlert', Lang:t('general.pacific_robbery_alert')) end local transG = 250 local blip = AddBlipForCoord(coords.x, coords.y, coords.z) @@ -405,7 +403,7 @@ RegisterNetEvent('qb-bankrobbery:client:robberyCall', function(type, coords) SetBlipScale(blip, 1.2) SetBlipFlashes(blip, true) BeginTextCommandSetBlipName('STRING') - AddTextComponentString(Lang:t("general.bank_robbery_police_call")) + AddTextComponentString(Lang:t('general.bank_robbery_police_call')) EndTextCommandSetBlipName(blip) while transG ~= 0 do Wait(180 * 4) @@ -419,13 +417,11 @@ RegisterNetEvent('qb-bankrobbery:client:robberyCall', function(type, coords) end end) --- Threads - CreateThread(function() while true do if closestBank ~= 0 then if not refreshed then - ResetBankDoors() + resetBankDoors() refreshed = true end else @@ -436,13 +432,12 @@ CreateThread(function() end) CreateThread(function() - while true do -- This is kept for the ResetBankDoors function to be executed outside of the polyzone - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) + while true do -- This is kept for the resetBankDoors function to be executed outside of the polyzone + local pos = GetEntityCoords(cache.ped) local inRange = false if isLoggedIn then for k, v in pairs(sharedConfig.smallBanks) do - local dist = #(pos - v["coords"]) + local dist = #(pos - v.coords) if dist < 15 then closestBank = k inRange = true @@ -456,20 +451,20 @@ end) CreateThread(function() for i = 1, #sharedConfig.smallBanks do - local bankZone = BoxZone:Create(sharedConfig.smallBanks[i]["coords"], 1.0, 1.0, { + local bankZone = BoxZone:Create(sharedConfig.smallBanks[i].coords, 1.0, 1.0, { 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, + heading = sharedConfig.smallBanks[i].coords.closed, + minZ = sharedConfig.smallBanks[i].coords.z - 1, + maxZ = sharedConfig.smallBanks[i].coords.z + 1, debugPoly = false }) - for k in pairs(sharedConfig.smallBanks[i]["lockers"]) do + 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, { + 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, + 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 }, { options = { @@ -478,30 +473,30 @@ CreateThread(function() openLocker(closestBank, k) end, 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"] + 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"), + label = Lang:t('general.break_safe_open_option_target'), }, }, distance = 1.5 }) else - local lockerZone = BoxZone:Create(sharedConfig.smallBanks[i]["lockers"][k]["coords"], 1.0, 1.0, { + local lockerZone = BoxZone:Create(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, + 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 - exports['qbx-core']:DrawText(Lang:t("general.break_safe_open_option_drawtext"), 'right') + 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 if currentLocker == k then currentLocker = 0 - exports['qbx-core']:HideText() + lib.hideTextUI() end end end) @@ -513,16 +508,15 @@ CreateThread(function() local sleep = 1000 if isLoggedIn then for i = 1, #sharedConfig.smallBanks do - if currentLocker ~= 0 and not IsDrilling and sharedConfig.smallBanks[i]["isOpened"] and not sharedConfig.smallBanks[i]["lockers"][currentLocker]["isOpened"] and not sharedConfig.smallBanks[i]["lockers"][currentLocker]["isBusy"] then + if currentLocker ~= 0 and not isDrilling and sharedConfig.smallBanks[i].isOpened and not sharedConfig.smallBanks[i].lockers[currentLocker].isOpened and not sharedConfig.smallBanks[i].lockers[currentLocker].isBusy then sleep = 0 if IsControlJustPressed(0, 38) then - exports['qbx-core']:KeyPressed() + lib.hideTextUI() Wait(500) - exports['qbx-core']:HideText() if CurrentCops >= config.minFleecaPolice then openLocker(closestBank, currentLocker) else - exports.qbx_core:Notify(Lang:t("error.minimum_police_required", {police = config.minFleecaPolice}), "error") + exports.qbx_core:Notify(Lang:t('error.minimum_police_required', {police = config.minFleecaPolice}), 'error') end sleep = 1000 end diff --git a/client/pacific.lua b/client/pacific.lua index 5904000..4d89b52 100644 --- a/client/pacific.lua +++ b/client/pacific.lua @@ -1,51 +1,36 @@ local config = require 'config.client' -local sharedConfig = require 'config.shared' +local pacificConfig = require 'config.shared'.bigBanks.pacific local inBankCardBZone = false local inElectronickitZone = false local currentLocker = 0 local copsCalled = false --- Functions - --- This will be triggered once the hack in the pacific bank is done --- @param success boolean --- @return nil -local function OnHackPacificDone(success) +local function onHackPacificDone(success) TriggerEvent('mhacking:hide') if not success then return end TriggerServerEvent('qb-bankrobbery:server:setBankState', 'pacific') end ---- This will load an animation dictionary so you can play an animation in that dictionary ---- @param dict string ---- @return nil -local function loadAnimDict(dict) - RequestAnimDict(dict) - while not HasAnimDictLoaded(dict) do - Wait(0) - end -end - --- Events - RegisterNetEvent('qb-bankrobbery:UseBankcardB', function() - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) + local pos = GetEntityCoords(cache.ped) if math.random(1, 100) > 85 or IsWearingGloves() then return end - TriggerServerEvent("evidence:server:CreateFingerDrop", pos) + TriggerServerEvent('evidence:server:CreateFingerDrop', pos) if not inBankCardBZone then return end local isBusy = lib.callback.await('qb-bankrobbery:server:isRobberyActive', false) if not isBusy then if CurrentCops >= config.minPacificPolice then - if not sharedConfig.bigBanks["pacific"]["isOpened"] then + 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} -- }, false) - loadAnimDict("anim@gangops@facility@servers@") - TaskPlayAnim(ped, 'anim@gangops@facility@servers@', 'hotwire', 3.0, 3.0, -1, 1, 0, false, false, false) + lib.requestAnimDict('anim@gangops@facility@servers@') + TaskPlayAnim(cache.ped, 'anim@gangops@facility@servers@', 'hotwire', 3.0, 3.0, -1, 1, 0, false, false, false) if lib.progressBar({ duration = 75000, - label = Lang:t("general.validating_bankcard"), + label = Lang:t('general.validating_bankcard'), canCancel = true, useWhileDead = false, disable = { @@ -55,46 +40,45 @@ RegisterNetEvent('qb-bankrobbery:UseBankcardB', function() combat = true }, anim = { - dict = "anim@gangops@facility@servers@", - clip = "hotwire", + dict = 'anim@gangops@facility@servers@', + clip = 'hotwire', flag = 1 } }) then --Config.DoorlockAction(1, false) TriggerServerEvent('qb-bankrobbery:server:removeBankCard', '02') - if copsCalled or not sharedConfig.bigBanks["pacific"]["alarm"] then return end - TriggerServerEvent("qb-bankrobbery:server:callCops", "pacific", 0, pos) + if copsCalled or not pacificConfig.alarm then return end + TriggerServerEvent('qb-bankrobbery:server:callCops', 'pacific', 0, pos) copsCalled = true else - exports.qbx_core:Notify(Lang:t("error.cancel_message"), "error") + exports.qbx_core:Notify(Lang:t('error.cancel_message'), 'error') end else - exports.qbx_core:Notify(Lang:t("error.bank_already_open"), "error") + exports.qbx_core:Notify(Lang:t('error.bank_already_open'), 'error') end else - exports.qbx_core:Notify(Lang:t("error.minimum_police_required", {police = config.minPacificPolice}), "error") + exports.qbx_core:Notify(Lang:t('error.minimum_police_required', {police = config.minPacificPolice}), 'error') end else - exports.qbx_core:Notify(Lang:t("error.security_lock_active"), "error", 5500) + exports.qbx_core:Notify(Lang:t('error.security_lock_active'), 'error', 5500) end end) RegisterNetEvent('electronickit:UseElectronickit', function() - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) + local pos = GetEntityCoords(cache.ped) if not inElectronickitZone then return end local isBusy = lib.callback.await('qb-bankrobbery:server:isRobberyActive', false) if not isBusy then if CurrentCops >= config.minPacificPolice then - if not sharedConfig.bigBanks["pacific"]["isOpened"] then - local hasItem = HasItem({"trojan_usb", "electronickit"}) + if not pacificConfig.isOpened then + local hasItem = HasItem({'trojan_usb', 'electronickit'}) if hasItem then -- Config.ShowRequiredItems(nil, false) - -- loadAnimDict("anim@gangops@facility@servers@") + -- lib.requestAnimDict('anim@gangops@facility@servers@') -- TaskPlayAnim(ped, 'anim@gangops@facility@servers@', 'hotwire', 3.0, 3.0, -1, 1, 0, false, false, false) if lib.progressBar({ duration = 7500, - label = Lang:t("general.breaking_open_safe"), + label = Lang:t('general.breaking_open_safe'), canCancel = true, useWhileDead = false, disable = { @@ -104,47 +88,47 @@ RegisterNetEvent('electronickit:UseElectronickit', function() combat = true }, anim = { - dict = "anim@gangops@facility@servers@", - clip = "hotwire", + dict = 'anim@gangops@facility@servers@', + clip = 'hotwire', flag = 1 } }) then - StopAnimTask(ped, "anim@gangops@facility@servers@", "hotwire", 1.0) - TriggerEvent("mhacking:show") - TriggerEvent("mhacking:start", math.random(5, 9), math.random(10, 15), OnHackPacificDone) - if copsCalled or not sharedConfig.bigBanks["pacific"]["alarm"] then return end - TriggerServerEvent("qb-bankrobbery:server:callCops", "pacific", 0, pos) + StopAnimTask(cache.ped, 'anim@gangops@facility@servers@', 'hotwire', 1.0) + TriggerEvent('mhacking:show') + TriggerEvent('mhacking:start', math.random(5, 9), math.random(10, 15), onHackPacificDone) + if copsCalled or not pacificConfig.alarm then return end + TriggerServerEvent('qb-bankrobbery:server:callCops', 'pacific', 0, pos) copsCalled = true else - exports.qbx_core:Notify(Lang:t("error.cancel_message"), "error") + exports.qbx_core:Notify(Lang:t('error.cancel_message'), 'error') end else - exports.qbx_core:Notify(Lang:t("error.missing_item"), "error") + exports.qbx_core:Notify(Lang:t('error.missing_item'), 'error') end else - exports.qbx_core:Notify(Lang:t("error.bank_already_open"), "error") + exports.qbx_core:Notify(Lang:t('error.bank_already_open'), 'error') end else - exports.qbx_core:Notify(Lang:t("error.minimum_police_required", {police = config.minPacificPolice}), "error") + exports.qbx_core:Notify(Lang:t('error.minimum_police_required', {police = config.minPacificPolice}), 'error') end else - exports.qbx_core:Notify(Lang:t("error.security_lock_active"), "error", 5500) + exports.qbx_core:Notify(Lang:t('error.security_lock_active'), 'error', 5500) end end) -- Threads CreateThread(function() - local bankCardBZone = BoxZone:Create(sharedConfig.bigBanks["pacific"]["coords"][1], 1.0, 1.0, { + local bankCardBZone = BoxZone:Create(pacificConfig.coords[1], 1.0, 1.0, { name = 'pacific_coords_bankcardb', - heading = sharedConfig.bigBanks["pacific"]["heading"].closed, - minZ = sharedConfig.bigBanks["pacific"]["coords"][1].z - 1, - maxZ = sharedConfig.bigBanks["pacific"]["coords"][1].z + 1, + 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 sharedConfig.bigBanks["pacific"]["isOpened"] then + 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) @@ -154,16 +138,16 @@ CreateThread(function() -- }, false) end end) - local electronickitZone = BoxZone:Create(sharedConfig.bigBanks["pacific"]["coords"][2], 1.0, 1.0, { + local electronickitZone = BoxZone:Create(pacificConfig.coords[2], 1.0, 1.0, { name = 'pacific_coords_electronickit', - heading = sharedConfig.bigBanks["pacific"]["heading"].closed, - minZ = sharedConfig.bigBanks["pacific"]["coords"][2].z - 1, - maxZ = sharedConfig.bigBanks["pacific"]["coords"][2].z + 1, + heading = pacificConfig.heading.closed, + minZ = pacificConfig.coords[2].z - 1, + maxZ = pacificConfig.coords[2].z + 1, debugPoly = false }) electronickitZone:onPlayerInOut(function(inside) inElectronickitZone = inside - if inside and not sharedConfig.bigBanks["pacific"]["isOpened"] then + 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} @@ -175,21 +159,21 @@ CreateThread(function() -- }, false) end end) - local thermite1Zone = BoxZone:Create(sharedConfig.bigBanks["pacific"]["thermite"][1]["coords"], 1.0, 1.0, { + local thermite1Zone = BoxZone:Create(pacificConfig.thermite[1].coords, 1.0, 1.0, { name = 'pacific_coords_thermite_1', - heading = sharedConfig.bigBanks["pacific"]["heading"].closed, - minZ = sharedConfig.bigBanks["pacific"]["thermite"][1]["coords"].z - 1, - maxZ = sharedConfig.bigBanks["pacific"]["thermite"][1]["coords"].z + 1, + heading = pacificConfig.heading.closed, + minZ = pacificConfig.thermite[1].coords.z - 1, + maxZ = pacificConfig.thermite[1].coords.z + 1, debugPoly = false }) thermite1Zone:onPlayerInOut(function(inside) - if inside and not sharedConfig.bigBanks["pacific"]["thermite"][1]["isOpened"] then - currentThermiteGate = sharedConfig.bigBanks["pacific"]["thermite"][1]["doorId"] + 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 - if currentThermiteGate == sharedConfig.bigBanks["pacific"]["thermite"][1]["doorId"] then + 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}, @@ -197,21 +181,21 @@ CreateThread(function() end end end) - local thermite2Zone = BoxZone:Create(sharedConfig.bigBanks["pacific"]["thermite"][2]["coords"], 1.0, 1.0, { + local thermite2Zone = BoxZone:Create(pacificConfig.thermite[2].coords, 1.0, 1.0, { name = 'pacific_coords_thermite_2', - heading = sharedConfig.bigBanks["pacific"]["heading"].closed, - minZ = sharedConfig.bigBanks["pacific"]["thermite"][2]["coords"].z - 1, - maxZ = sharedConfig.bigBanks["pacific"]["thermite"][2]["coords"].z + 1, + heading = pacificConfig.heading.closed, + minZ = pacificConfig.thermite[2].coords.z - 1, + maxZ = pacificConfig.thermite[2].coords.z + 1, debugPoly = false }) thermite2Zone:onPlayerInOut(function(inside) - if inside and not sharedConfig.bigBanks["pacific"]["thermite"][2]["isOpened"] then - currentThermiteGate = sharedConfig.bigBanks["pacific"]["thermite"][2]["doorId"] + 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 - if currentThermiteGate == sharedConfig.bigBanks["pacific"]["thermite"][2]["doorId"] then + 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}, @@ -219,40 +203,40 @@ CreateThread(function() end end end) - for k in pairs(sharedConfig.bigBanks["pacific"]["lockers"]) do + for k in pairs(pacificConfig.lockers) do if config.useTarget then - exports['qb-target']:AddBoxZone('pacific_coords_locker_'..k, sharedConfig.bigBanks["pacific"]["lockers"][k]["coords"], 1.0, 1.0, { + exports['qb-target']:AddBoxZone('pacific_coords_locker_'..k, pacificConfig.lockers[k].coords, 1.0, 1.0, { name = 'pacific_coords_locker_'..k, - heading = sharedConfig.bigBanks["pacific"]["heading"].closed, - minZ = sharedConfig.bigBanks["pacific"]["lockers"][k]["coords"].z - 1, - maxZ = sharedConfig.bigBanks["pacific"]["lockers"][k]["coords"].z + 1, + heading = pacificConfig.heading.closed, + minZ = pacificConfig.lockers[k].coords.z - 1, + maxZ = pacificConfig.lockers[k].coords.z + 1, debugPoly = false }, { options = { { action = function() - openLocker("pacific", k) + openLocker('pacific', k) end, canInteract = function() - return not IsDrilling and sharedConfig.bigBanks["pacific"]["isOpened"] and not sharedConfig.bigBanks["pacific"]["lockers"][k]["isBusy"] and not sharedConfig.bigBanks["pacific"]["lockers"][k]["isOpened"] + 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"), + label = Lang:t('general.break_safe_open_option_target'), }, }, distance = 1.5 }) else - local lockerZone = BoxZone:Create(sharedConfig.bigBanks["pacific"]["lockers"][k]["coords"], 1.0, 1.0, { + local lockerZone = BoxZone:Create(pacificConfig.lockers[k].coords, 1.0, 1.0, { name = 'pacific_coords_locker_'..k, - heading = sharedConfig.bigBanks["pacific"]["heading"].closed, - minZ = sharedConfig.bigBanks["pacific"]["lockers"][k]["coords"].z - 1, - maxZ = sharedConfig.bigBanks["pacific"]["lockers"][k]["coords"].z + 1, + 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 sharedConfig.bigBanks["pacific"]["isOpened"] and not sharedConfig.bigBanks["pacific"]["lockers"][k]["isBusy"] and not sharedConfig.bigBanks["pacific"]["lockers"][k]["isOpened"] then - exports['qbx-core']:DrawText(Lang:t("general.break_safe_open_option_drawtext"), 'right') + 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 if currentLocker == k then @@ -267,16 +251,16 @@ CreateThread(function() while true do local sleep = 1000 if isLoggedIn then - if currentLocker ~= 0 and not IsDrilling and sharedConfig.bigBanks["pacific"]["isOpened"] and not sharedConfig.bigBanks["pacific"]["lockers"][currentLocker]["isBusy"] and not sharedConfig.bigBanks["pacific"]["lockers"][currentLocker]["isOpened"] then + 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() Wait(500) exports['qbx-core']:HideText() if CurrentCops >= config.minPacificPolice then - openLocker("pacific", currentLocker) + openLocker('pacific', currentLocker) else - exports.qbx_core:Notify(Lang:t("error.minimum_police_required", {police = config.minPacificPolice}), "error") + exports.qbx_core:Notify(Lang:t('error.minimum_police_required', {police = config.minPacificPolice}), 'error') end sleep = 1000 end diff --git a/client/paleto.lua b/client/paleto.lua index 0f579e0..baf30bc 100644 --- a/client/paleto.lua +++ b/client/paleto.lua @@ -1,37 +1,22 @@ local config = require 'config.client' -local sharedConfig = require 'config.shared' +local paletoConfig = require 'config.shared'.bigBanks.paleto local inBankCardAZone = false local currentLocker = 0 local copsCalled = false --- Functions - ---- This will load an animation dictionary so you can play an animation in that dictionary ---- @param dict string ---- @return nil -local function loadAnimDict(dict) - RequestAnimDict(dict) - while not HasAnimDictLoaded(dict) do - Wait(0) - end -end - --- Events - RegisterNetEvent('qb-bankrobbery:UseBankcardA', function() - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) + local pos = GetEntityCoords(cache.ped) if math.random(1, 100) > 85 or IsWearingGloves() then return end - TriggerServerEvent("evidence:server:CreateFingerDrop", pos) + TriggerServerEvent('evidence:server:CreateFingerDrop', pos) if not inBankCardAZone then return end local isBusy = lib.callback.await('qb-bankrobbery:server:isRobberyActive', false) if not isBusy then if CurrentCops >= config.minPaletoPolice then - if not sharedConfig.bigBanks["paleto"]["isOpened"] then + if not paletoConfig.isOpened then -- Config.ShowRequiredItems(nil, false) if lib.progressBar({ duration = 7500, - label = Lang:t("general.validating_bankcard"), + label = Lang:t('general.validating_bankcard'), canCancel = true, useWhileDead = false, disable = { @@ -41,44 +26,44 @@ RegisterNetEvent('qb-bankrobbery:UseBankcardA', function() combat = true }, anim = { - dict = "anim@gangops@facility@servers@", - clip = "hotwire", + dict = 'anim@gangops@facility@servers@', + clip = 'hotwire', flag = 1 } }) then TriggerServerEvent('qb-bankrobbery:server:setBankState', 'paleto') TriggerServerEvent('qb-bankrobbery:server:removeBankCard', '01') --Config.DoorlockAction(4, false) - if copsCalled or not sharedConfig.bigBanks["paleto"]["alarm"] then return end - TriggerServerEvent("qb-bankrobbery:server:callCops", "paleto", 0, pos) + if copsCalled or not paletoConfig.alarm then return end + TriggerServerEvent('qb-bankrobbery:server:callCops', 'paleto', 0, pos) copsCalled = true else - exports.qbx_core:Notify(Lang:t("error.cancel_message"), "error") + exports.qbx_core:Notify(Lang:t('error.cancel_message'), 'error') end else - exports.qbx_core:Notify(Lang:t("error.bank_already_open"), "error") + exports.qbx_core:Notify(Lang:t('error.bank_already_open'), 'error') end else - exports.qbx_core:Notify(Lang:t("error.minimum_police_required", {police = config.minPaletoPolice}), "error") + exports.qbx_core:Notify(Lang:t('error.minimum_police_required', {police = config.minPaletoPolice}), 'error') end else - exports.qbx_core:Notify(Lang:t("error.security_lock_active"), "error", 5500) + exports.qbx_core:Notify(Lang:t('error.security_lock_active'), 'error', 5500) end end) -- Threads CreateThread(function() - local bankCardAZone = BoxZone:Create(sharedConfig.bigBanks["paleto"]["coords"], 1.0, 1.0, { + local bankCardAZone = BoxZone:Create(paletoConfig.coords, 1.0, 1.0, { name = 'paleto_coords_bankcarda', - heading = sharedConfig.bigBanks["paleto"]["coords"].closed, - minZ = sharedConfig.bigBanks["paleto"]["coords"].z - 1, - maxZ = sharedConfig.bigBanks["paleto"]["coords"].z + 1, + heading = paletoConfig.heading.closed, + minZ = paletoConfig.coords.z - 1, + maxZ = paletoConfig.coords.z + 1, debugPoly = false }) bankCardAZone:onPlayerInOut(function(inside) inBankCardAZone = inside - if inside and not sharedConfig.bigBanks["paleto"]["isOpened"] then + if inside and not paletoConfig.isOpened then -- Config.ShowRequiredItems({ -- [1] = {name = exports.ox_inventory:Items().security_card_01.name, image = exports.ox_inventory:Items().security_card_01.image} -- }, true) @@ -88,21 +73,21 @@ CreateThread(function() -- }, false) end end) - local thermite1Zone = BoxZone:Create(sharedConfig.bigBanks["paleto"]["thermite"][1]["coords"], 1.0, 1.0, { + local thermite1Zone = BoxZone:Create(paletoConfig.thermite[1].coords, 1.0, 1.0, { name = 'paleto_coords_thermite_1', - heading = sharedConfig.bigBanks["paleto"]["heading"].closed, - minZ = sharedConfig.bigBanks["paleto"]["thermite"][1]["coords"].z - 1, - maxZ = sharedConfig.bigBanks["paleto"]["thermite"][1]["coords"].z + 1, + heading = paletoConfig.heading.closed, + minZ = paletoConfig.thermite[1].coords.z - 1, + maxZ = paletoConfig.thermite[1].coords.z + 1, debugPoly = false }) thermite1Zone:onPlayerInOut(function(inside) - if inside and not sharedConfig.bigBanks["paleto"]["thermite"][1]["isOpened"] then - currentThermiteGate = sharedConfig.bigBanks["paleto"]["thermite"][1]["doorId"] + if inside and not paletoConfig.thermite[1].isOpened then + currentThermiteGate = paletoConfig.thermite[1].doorId -- Config.ShowRequiredItems({ -- [1] = {name = exports.ox_inventory:Items().thermite.name, image = exports.ox_inventory:Items().thermite.image}, -- }, true) else - if currentThermiteGate == sharedConfig.bigBanks["paleto"]["thermite"][1]["doorId"] then + if currentThermiteGate == paletoConfig.thermite[1].doorId then currentThermiteGate = 0 -- Config.ShowRequiredItems({ -- [1] = {name = exports.ox_inventory:Items().thermite.name, image = exports.ox_inventory:Items().thermite.image}, @@ -110,40 +95,40 @@ CreateThread(function() end end end) - for k in pairs(sharedConfig.bigBanks["paleto"]["lockers"]) do + for k in pairs(paletoConfig.lockers) do if config.useTarget then - exports['qb-target']:AddBoxZone('paleto_coords_locker_'..k, sharedConfig.bigBanks["paleto"]["lockers"][k]["coords"], 1.0, 1.0, { + exports['qb-target']:AddBoxZone('paleto_coords_locker_'..k, paletoConfig.lockers[k].coords, 1.0, 1.0, { name = 'paleto_coords_locker_'..k, - heading = sharedConfig.bigBanks["paleto"]["heading"].closed, - minZ = sharedConfig.bigBanks["paleto"]["lockers"][k]["coords"].z - 1, - maxZ = sharedConfig.bigBanks["paleto"]["lockers"][k]["coords"].z + 1, + heading = paletoConfig.heading.closed, + minZ = paletoConfig.lockers[k].coords.z - 1, + maxZ = paletoConfig.lockers[k].coords.z + 1, debugPoly = false }, { options = { { action = function() - openLocker("paleto", k) + openLocker('paleto', k) end, canInteract = function() - return not IsDrilling and sharedConfig.bigBanks["paleto"]["isOpened"] and not sharedConfig.bigBanks["paleto"]["lockers"][k]["isBusy"] and not sharedConfig.bigBanks["paleto"]["lockers"][k]["isOpened"] + return not isDrilling and paletoConfig.isOpened and not paletoConfig.lockers[k].isBusy and not paletoConfig.lockers[k].isopened end, icon = 'fa-solid fa-vault', - label = Lang:t("general.break_safe_open_option_target"), + label = Lang:t('general.break_safe_open_option_target'), }, }, distance = 1.5 }) else - local lockerZone = BoxZone:Create(sharedConfig.bigBanks["paleto"]["lockers"][k]["coords"], 1.0, 1.0, { + local lockerZone = BoxZone:Create(paletoConfig.lockers[k].coords, 1.0, 1.0, { name = 'paleto_coords_locker_'..k, - heading = sharedConfig.bigBanks["paleto"]["heading"].closed, - minZ = sharedConfig.bigBanks["paleto"]["lockers"][k]["coords"].z - 1, - maxZ = sharedConfig.bigBanks["paleto"]["lockers"][k]["coords"].z + 1, + heading = paletoConfig.heading.closed, + minZ = paletoConfig.lockers[k].coords.z - 1, + maxZ = paletoConfig.lockers[k].coords.z + 1, debugPoly = false }) lockerZone:onPlayerInOut(function(inside) - if inside and not IsDrilling and sharedConfig.bigBanks["paleto"]["isOpened"] and not sharedConfig.bigBanks["paleto"]["lockers"][k]["isBusy"] and not sharedConfig.bigBanks["paleto"]["lockers"][k]["isOpened"] then - exports['qbx-core']:DrawText(Lang:t("general.break_safe_open_option_drawtext"), 'right') + if inside and not isDrilling and paletoConfig.isOpened and not paletoConfig.lockers[k].isBusy and not paletoConfig.lockers[k].isopened then + exports['qbx-core']:DrawText(Lang:t('general.break_safe_open_option_drawtext'), 'right') currentLocker = k else if currentLocker == k then @@ -158,16 +143,16 @@ CreateThread(function() while true do local sleep = 1000 if isLoggedIn then - if currentLocker ~= 0 and not IsDrilling and sharedConfig.bigBanks["paleto"]["isOpened"] and not sharedConfig.bigBanks["paleto"]["lockers"][currentLocker]["isBusy"] and not sharedConfig.bigBanks["paleto"]["lockers"][currentLocker]["isOpened"] then + if currentLocker ~= 0 and not isDrilling and paletoConfig.isOpened and not paletoConfig.lockers[currentLocker].isBusy and not paletoConfig.lockers[currentLocker].isOpened then sleep = 0 if IsControlJustPressed(0, 38) then exports['qbx-core']:KeyPressed() Wait(500) exports['qbx-core']:HideText() if CurrentCops >= config.minPaletoPolice then - openLocker("paleto", currentLocker) + openLocker('paleto', currentLocker) else - exports.qbx_core:Notify(Lang:t("error.minimum_police_required", {police = config.minPaletoPolice}), "error") + exports.qbx_core:Notify(Lang:t('error.minimum_police_required', {police = config.minPaletoPolice}), 'error') end sleep = 1000 end diff --git a/client/powerstation.lua b/client/powerstation.lua index 35dd035..a63619e 100644 --- a/client/powerstation.lua +++ b/client/powerstation.lua @@ -1,38 +1,24 @@ local config = require 'config.client' -local sharedConfig = require 'config.shared' +local powerStationConfig = require 'config.shared'.powerStations local closestStation = 0 local currentStation = 0 local currentFires = {} local currentGate = 0 --- Functions - --- This will create a fire at the given coords and for the given time --- @param coords vector3 --- @param time number --- @return nil -local function CreateFire(coords, time) +local function createFire(coords, time) for _ = 1, math.random(1, 7), 1 do - TriggerServerEvent("thermite:StartServerFire", coords, 24, false) + TriggerServerEvent('thermite:StartServerFire', coords, 24, false) end Wait(time) - TriggerServerEvent("thermite:StopFires") -end - ---- This will load an animation dictionary so you can play an animation in that dictionary ---- @param dict string ---- @return nil -local function loadAnimDict(dict) - RequestAnimDict(dict) - while not HasAnimDictLoaded(dict) do - Wait(0) - end + TriggerServerEvent('thermite:StopFires') end --- Events - RegisterNetEvent('thermite:StartFire', function(coords, maxChildren, isGasFire) - if #(vector3(coords.x, coords.y, coords.z) - GetEntityCoords(PlayerPedId())) < 100 then + if #(vec3(coords.x, coords.y, coords.z) - GetEntityCoords(cache.ped)) < 100 then local pos = { x = coords.x, y = coords.y, @@ -51,69 +37,66 @@ RegisterNetEvent('thermite:StopFires', function() end) RegisterNetEvent('thermite:UseThermite', function() - local ped = PlayerPedId() - local pos = GetEntityCoords(ped) + local pos = GetEntityCoords(cache.ped) if closestStation ~= 0 then if math.random(1, 100) > 85 or IsWearingGloves() then return end - TriggerServerEvent("evidence:server:CreateFingerDrop", pos) - local dist = #(pos - sharedConfig.powerStations[closestStation].coords) + TriggerServerEvent('evidence:server:CreateFingerDrop', pos) + local dist = #(pos - powerStationConfig[closestStation].coords) if dist < 1.5 then if CurrentCops >= config.minThermitePolice then - if not sharedConfig.powerStations[closestStation].hit then - loadAnimDict("weapon@w_sp_jerrycan") - TaskPlayAnim(PlayerPedId(), "weapon@w_sp_jerrycan", "fire", 3.0, 3.9, 180, 49, 0, 0, 0, 0) + if not powerStationConfig[closestStation].hit then + lib.requestAnimDict('weapon@w_sp_jerrycan') + TaskPlayAnim(cache.ped, 'weapon@w_sp_jerrycan', 'fire', 3.0, 3.9, 180, 49, 0, false, false, false) -- Config.ShowRequiredItems(requiredItems, false) SetNuiFocus(true, true) SendNUIMessage({ - action = "openThermite", + action = 'openThermite', amount = math.random(5, 10), }) currentStation = closestStation else - exports.qbx_core:Notify(Lang:t("error.fuses_already_blown"), "error") + exports.qbx_core:Notify(Lang:t('error.fuses_already_blown'), 'error') end else - exports.qbx_core:Notify(Lang:t("error.minium_police_required", {police = config.minThermitePolice}), "error") + exports.qbx_core:Notify(Lang:t('error.minium_police_required', {police = config.minThermitePolice}), 'error') end end elseif currentThermiteGate ~= 0 then if math.random(1, 100) > 85 or IsWearingGloves() then return end - TriggerServerEvent("evidence:server:CreateFingerDrop", pos) + TriggerServerEvent('evidence:server:CreateFingerDrop', pos) if CurrentCops >= config.minThermitePolice then currentGate = currentThermiteGate - loadAnimDict("weapon@w_sp_jerrycan") - TaskPlayAnim(PlayerPedId(), "weapon@w_sp_jerrycan", "fire", 3.0, 3.9, -1, 49, 0, 0, 0, 0) + lib.requestAnimDict('weapon@w_sp_jerrycan') + TaskPlayAnim(cache.ped, 'weapon@w_sp_jerrycan', 'fire', 3.0, 3.9, -1, 49, 0, false, false, false) -- Config.ShowRequiredItems(requiredItems, false) SetNuiFocus(true, true) SendNUIMessage({ - action = "openThermite", + action = 'openThermite', amount = math.random(5, 10), }) else - exports.qbx_core:Notify(Lang:t("error.minium_police_required", {police = config.minThermitePolice}), "error") + exports.qbx_core:Notify(Lang:t('error.minium_police_required', {police = config.minThermitePolice}), 'error') end end end) RegisterNetEvent('qb-bankrobbery:client:SetStationStatus', function(key, isHit) - sharedConfig.powerStations[key].hit = isHit + powerStationConfig[key].hit = isHit end) --- NUI Callbacks - RegisterNUICallback('thermiteclick', function(_, cb) - PlaySound(-1, "CLICK_BACK", "WEB_NAVIGATION_SOUNDS_PHONE", 0, 0, 1) + PlaySound(-1, 'CLICK_BACK', 'WEB_NAVIGATION_SOUNDS_PHONE', false, 0, true) cb('ok') end) RegisterNUICallback('thermitefailed', function(_, cb) local success = lib.callback.await('thermite:server:check', false) if success then - PlaySound(-1, "Place_Prop_Fail", "DLC_Dmod_Prop_Editor_Sounds", 0, 0, 1) - ClearPedTasks(PlayerPedId()) - local coords = GetEntityCoords(PlayerPedId()) + PlaySound(-1, 'Place_Prop_Fail', 'DLC_Dmod_Prop_Editor_Sounds', false, 0, true) + ClearPedTasks(cache.ped) + local coords = GetEntityCoords(cache.ped) local randTime = math.random(10000, 15000) - CreateFire(coords, randTime) + createFire(coords, randTime) end cb('ok') end) @@ -121,21 +104,21 @@ end) RegisterNUICallback('thermitesuccess', function(_, cb) local success = lib.callback.await('thermite:server:check', false) if success then - ClearPedTasks(PlayerPedId()) + ClearPedTasks(cache.ped) local time = 3 - local coords = GetEntityCoords(PlayerPedId()) + local coords = GetEntityCoords(cache.ped) while time > 0 do - exports.qbx_core:Notify(Lang:t("general.thermite_detonating_in_seconds", {time = time})) + exports.qbx_core:Notify(Lang:t('general.thermite_detonating_in_seconds', {time = time})) Wait(1000) time -= 1 end local randTime = math.random(10000, 15000) - CreateFire(coords, randTime) + createFire(coords, randTime) if currentStation ~= 0 then - exports.qbx_core:Notify(Lang:t("success.fuses_are_blown"), "success") - TriggerServerEvent("qb-bankrobbery:server:SetStationStatus", currentStation, true) + exports.qbx_core:Notify(Lang:t('success.fuses_are_blown'), 'success') + TriggerServerEvent('qb-bankrobbery:server:SetStationStatus', currentStation, true) elseif currentGate ~= 0 then - exports.qbx_core:Notify(Lang:t("success.door_has_opened"), "success") + exports.qbx_core:Notify(Lang:t('success.door_has_opened'), 'success') --Config.DoorlockAction(currentGate, false) currentGate = 0 end @@ -148,19 +131,17 @@ RegisterNUICallback('closethermite', function(_, cb) cb('ok') end) --- Threads - CreateThread(function() - for k = 1, #sharedConfig.powerStations do - local stationZone = BoxZone:Create(sharedConfig.powerStations[k].coords, 1.0, 1.0, { + for k = 1, #powerStationConfig do + local stationZone = BoxZone:Create(powerStationConfig[k].coords, 1.0, 1.0, { name = 'powerstation_coords_'..k, heading = 90.0, - minZ = sharedConfig.powerStations[k].coords.z - 1, - maxZ = sharedConfig.powerStations[k].coords.z + 1, + minZ = powerStationConfig[k].coords.z - 1, + maxZ = powerStationConfig[k].coords.z + 1, debugPoly = false }) stationZone:onPlayerInOut(function(inside) - if inside and not sharedConfig.powerStations[k].hit then + if inside and not powerStationConfig[k].hit then closestStation = k -- Config.ShowRequiredItems(requiredItems, true) else diff --git a/config/shared.lua b/config/shared.lua index 29ff257..95748be 100644 --- a/config/shared.lua +++ b/config/shared.lua @@ -17,470 +17,196 @@ return { smallBanks = { [1] = { - ["label"] = "Lol", - ["coords"] = vec3(311.15, -284.49, 54.16), - ["alarm"] = true, - ["object"] = `v_ilev_gb_vauldr`, - ["heading"] = { + label = 'Lol', + coords = vec3(311.15, -284.49, 54.16), + alarm = true, + object = `v_ilev_gb_vauldr`, + heading = { closed = 250.0, open = 160.0 }, - ["camId"] = 21, - ["isOpened"] = false, - ["lockers"] = { - [1] = { - ["coords"] = vec3(311.16, -287.71, 54.14), - ["isBusy"] = false, - ["isOpened"] = false - }, - [2] = { - ["coords"] = vec3(311.86, -286.21, 54.14), - ["isBusy"] = false, - ["isOpened"] = false - }, - [3] = { - ["coords"] = vec3(313.39, -289.15, 54.14), - ["isBusy"] = false, - ["isOpened"] = false - }, - [4] = { - ["coords"] = vec3(311.7, -288.45, 54.14), - ["isBusy"] = false, - ["isOpened"] = false - }, - [5] = { - ["coords"] = vec3(314.23, -288.77, 54.14), - ["isBusy"] = false, - ["isOpened"] = false - }, - [6] = { - ["coords"] = vec3(314.83, -287.33, 54.14), - ["isBusy"] = false, - ["isOpened"] = false - }, - [7] = { - ["coords"] = vec3(315.24, -284.85, 54.14), - ["isBusy"] = false, - ["isOpened"] = false - }, - [8] = { - ["coords"] = vec3(314.08, -283.38, 54.14), - ["isBusy"] = false, - ["isOpened"] = false - } + camId = 21, + isOpened = false, + lockers = { + [1] = {coords = vec3(311.16, -287.71, 54.14), isBusy = false, isOpened = false}, + [2] = {coords = vec3(311.86, -286.21, 54.14), isBusy = false, isOpened = false}, + [3] = {coords = vec3(313.39, -289.15, 54.14), isBusy = false, isOpened = false}, + [4] = {coords = vec3(311.7, -288.45, 54.14), isBusy = false, isOpened = false}, + [5] = {coords = vec3(314.23, -288.77, 54.14), isBusy = false, isOpened = false}, + [6] = {coords = vec3(314.83, -287.33, 54.14), isBusy = false, isOpened = false}, + [7] = {coords = vec3(315.24, -284.85, 54.14), isBusy = false, isOpened = false}, + [8] = {coords = vec3(314.08, -283.38, 54.14), isBusy = false, isOpened = false}, } }, [2] = { - ["label"] = "Legion Square", - ["coords"] = vec3(146.92, -1046.11, 29.36), - ["alarm"] = true, - ["object"] = `v_ilev_gb_vauldr`, - ["heading"] = { + label = 'Legion Square', + coords = vec3(146.92, -1046.11, 29.36), + alarm = true, + object = `v_ilev_gb_vauldr`, + heading = { closed = 250.0, open = 160.0 }, - ["camId"] = 22, - ["isOpened"] = false, - ["lockers"] = { - [1] = { - ["coords"] = vec3(149.84, -1044.9, 29.34), - ["isBusy"] = false, - ["isOpened"] = false - }, - [2] = { - ["coords"] = vec3(151.16, -1046.64, 29.34), - ["isBusy"] = false, - ["isOpened"] = false - }, - [3] = { - ["coords"] = vec3(147.16, -1047.72, 29.34), - ["isBusy"] = false, - ["isOpened"] = false - }, - [4] = { - ["coords"] = vec3(146.54, -1049.28, 29.34), - ["isBusy"] = false, - ["isOpened"] = false - }, - [5] = { - ["coords"] = vec3(146.88, -1050.33, 29.34), - ["isBusy"] = false, - ["isOpened"] = false - }, - [6] = { - ["coords"] = vec3(150.0, -1050.67, 29.34), - ["isBusy"] = false, - ["isOpened"] = false - }, - [7] = { - ["coords"] = vec3(149.47, -1051.28, 29.34), - ["isBusy"] = false, - ["isOpened"] = false - }, - [8] = { - ["coords"] = vec3(150.58, -1049.09, 29.34), - ["isBusy"] = false, - ["isOpened"] = false - } + camId = 22, + isOpened = false, + lockers = { + [1] = {coords = vec3(149.84, -1044.9, 29.34), isBusy = false, isOpened = false}, + [2] = {coords = vec3(151.16, -1046.64, 29.34), isBusy = false, isOpened = false}, + [3] = {coords = vec3(147.16, -1047.72, 29.34), isBusy = false, isOpened = false}, + [4] = {coords = vec3(146.54, -1049.28, 29.34), isBusy = false, isOpened = false}, + [5] = {coords = vec3(146.88, -1050.33, 29.34), isBusy = false, isOpened = false}, + [6] = {coords = vec3(150.0, -1050.67, 29.34), isBusy = false, isOpened = false}, + [7] = {coords = vec3(149.47, -1051.28, 29.34), isBusy = false, isOpened = false}, + [8] = {coords = vec3(150.58, -1049.09, 29.34), isBusy = false, isOpened = false}, } }, [3] = { - ["label"] = "Hawick Ave", - ["coords"] = vec3(-353.82, -55.37, 49.03), - ["alarm"] = true, - ["object"] = `v_ilev_gb_vauldr`, - ["heading"] = { + label = 'Hawick Ave', + coords = vec3(-353.82, -55.37, 49.03), + alarm = true, + object = `v_ilev_gb_vauldr`, + heading = { closed = 250.0, open = 160.0 }, - ["camId"] = 23, - ["isOpened"] = false, - ["lockers"] = { - [1] = { - ["coords"] = vec3(-350.99, -54.13, 49.01), - ["isBusy"] = false, - ["isOpened"] = false - }, - [2] = { - ["coords"] = vec3(-349.53, -55.77, 49.01), - ["isBusy"] = false, - ["isOpened"] = false - }, - [3] = { - ["coords"] = vec3(-353.54, -56.94, 49.01), - ["isBusy"] = false, - ["isOpened"] = false - }, - [4] = { - ["coords"] = vec3(-354.09, -58.55, 49.01), - ["isBusy"] = false, - ["isOpened"] = false - }, - [5] = { - ["coords"] = vec3(-353.81, -59.48, 49.01), - ["isBusy"] = false, - ["isOpened"] = false - }, - [6] = { - ["coords"] = vec3(-349.8, -58.3, 49.01), - ["isBusy"] = false, - ["isOpened"] = false - }, - [7] = { - ["coords"] = vec3(-351.14, -60.37, 49.01), - ["isBusy"] = false, - ["isOpened"] = false - }, - [8] = { - ["coords"] = vec3(-350.4, -59.92, 49.01), - ["isBusy"] = false, - ["isOpened"] = false - } + camId = 23, + isOpened = false, + lockers = { + [1] = {coords = vec3(-350.99, -54.13, 49.01), isBusy = false, isOpened = false}, + [2] = {coords = vec3(-349.53, -55.77, 49.01), isBusy = false, isOpened = false}, + [3] = {coords = vec3(-353.54, -56.94, 49.01), isBusy = false, isOpened = false}, + [4] = {coords = vec3(-354.09, -58.55, 49.01), isBusy = false, isOpened = false}, + [5] = {coords = vec3(-353.81, -59.48, 49.01), isBusy = false, isOpened = false}, + [6] = {coords = vec3(-349.8, -58.3, 49.01), isBusy = false, isOpened = false}, + [7] = {coords = vec3(-351.14, -60.37, 49.01), isBusy = false, isOpened = false}, + [8] = {coords = vec3(-350.4, -59.92, 49.01), isBusy = false, isOpened = false}, } }, [4] = { - ["label"] = "Del Perro Blvd", - ["coords"] = vec3(-1210.77, -336.57, 37.78), - ["alarm"] = true, - ["object"] = `v_ilev_gb_vauldr`, - ["heading"] = { + label = 'Del Perro Blvd', + coords = vec3(-1210.77, -336.57, 37.78), + alarm = true, + object = `v_ilev_gb_vauldr`, + heading = { closed = 296.863, open = 206.863 }, - ["camId"] = 24, - ["isOpened"] = false, - ["lockers"] = { - [1] = { - ["coords"] = vec3(-1209.68, -333.65, 37.75), - ["isBusy"] = false, - ["isOpened"] = false - }, - [2] = { - ["coords"] = vec3(-1207.46, -333.77, 37.75), - ["isBusy"] = false, - ["isOpened"] = false - }, - [3] = { - ["coords"] = vec3(-1209.45, -337.47, 37.75), - ["isBusy"] = false, - ["isOpened"] = false - }, - [4] = { - ["coords"] = vec3(-1208.65, -339.06, 37.75), - ["isBusy"] = false, - ["isOpened"] = false - }, - [5] = { - ["coords"] = vec3(-1207.75, -339.42, 37.75), - ["isBusy"] = false, - ["isOpened"] = false - }, - [6] = { - ["coords"] = vec3(-1205.28, -338.14, 37.75), - ["isBusy"] = false, - ["isOpened"] = false - }, - [7] = { - ["coords"] = vec3(-1205.08, -337.28, 37.75), - ["isBusy"] = false, - ["isOpened"] = false - }, - [8] = { - ["coords"] = vec3(-1205.92, -335.75, 37.75), - ["isBusy"] = false, - ["isOpened"] = false - } + camId = 24, + isOpened = false, + lockers = { + [1] = {coords = vec3(-1209.68, -333.65, 37.75), isBusy = false, isOpened = false}, + [2] = {coords = vec3(-1207.46, -333.77, 37.75), isBusy = false, isOpened = false}, + [3] = {coords = vec3(-1209.45, -337.47, 37.75), isBusy = false, isOpened = false}, + [4] = {coords = vec3(-1208.65, -339.06, 37.75), isBusy = false, isOpened = false}, + [5] = {coords = vec3(-1207.75, -339.42, 37.75), isBusy = false, isOpened = false}, + [6] = {coords = vec3(-1205.28, -338.14, 37.75), isBusy = false, isOpened = false}, + [7] = {coords = vec3(-1205.08, -337.28, 37.75), isBusy = false, isOpened = false}, + [8] = {coords = vec3(-1205.92, -335.75, 37.75), isBusy = false, isOpened = false}, } }, [5] = { - ["label"] = "Great Ocean Hwy", - ["coords"] = vec3(-2956.55, 481.74, 15.69), - ["alarm"] = true, - ["object"] = `hei_prop_heist_sec_door`, - ["heading"] = { + label = 'Great Ocean Hwy', + coords = vec3(-2956.55, 481.74, 15.69), + alarm = true, + object = `hei_prop_heist_sec_door`, + heading = { closed = 357.542, open = 267.542 }, - ["camId"] = 25, - ["isOpened"] = false, - ["lockers"] = { - [1] = { - ["coords"] = vec3(-2958.54, 484.1, 15.67), - ["isBusy"] = false, - ["isOpened"] = false - }, - [2] = { - ["coords"] = vec3(-2957.3, 485.95, 15.67), - ["isBusy"] = false, - ["isOpened"] = false - }, - [3] = { - ["coords"] = vec3(-2955.09, 482.43, 15.67), - ["isBusy"] = false, - ["isOpened"] = false - }, - [4] = { - ["coords"] = vec3(-2953.26, 482.42, 15.67), - ["isBusy"] = false, - ["isOpened"] = false - }, - [5] = { - ["coords"] = vec3(-2952.63, 483.09, 15.67), - ["isBusy"] = false, - ["isOpened"] = false - }, - [6] = { - ["coords"] = vec3(-2952.45, 485.66, 15.67), - ["isBusy"] = false, - ["isOpened"] = false - }, - [7] = { - ["coords"] = vec3(-2953.13, 486.26, 15.67), - ["isBusy"] = false, - ["isOpened"] = false - }, - [8] = { - ["coords"] = vec3(-2954.98, 486.37, 15.67), - ["isBusy"] = false, - ["isOpened"] = false - } + camId = 25, + isOpened = false, + lockers = { + [1] = {coords = vec3(-2958.54, 484.1, 15.67), isBusy = false, isOpened = false}, + [2] = {coords = vec3(-2957.3, 485.95, 15.67), isBusy = false, isOpened = false}, + [3] = {coords = vec3(-2955.09, 482.43, 15.67), isBusy = false, isOpened = false}, + [4] = {coords = vec3(-2953.26, 482.42, 15.67), isBusy = false, isOpened = false}, + [5] = {coords = vec3(-2952.63, 483.09, 15.67), isBusy = false, isOpened = false}, + [6] = {coords = vec3(-2952.45, 485.66, 15.67), isBusy = false, isOpened = false}, + [7] = {coords = vec3(-2953.13, 486.26, 15.67), isBusy = false, isOpened = false}, + [8] = {coords = vec3(-2954.98, 486.37, 15.67), isBusy = false, isOpened = false}, } }, [6] = { - ["label"] = "East", - ["coords"] = vec3(1175.96, 2712.87, 38.09), - ["alarm"] = true, - ["object"] = `v_ilev_gb_vauldr`, - ["heading"] = { + label = 'East', + coords = vec3(1175.96, 2712.87, 38.09), + alarm = true, + object = `v_ilev_gb_vauldr`, + heading = { closed = -270.542, open = -370.542 }, - ["camId"] = 25, - ["isOpened"] = false, - ["lockers"] = { - [1] = { - ["coords"] = vec3(1173.69, 2710.76, 38.07), - ["isBusy"] = false, - ["isOpened"] = false - }, - [2] = { - ["coords"] = vec3(1171.78, 2711.94, 38.07), - ["isBusy"] = false, - ["isOpened"] = false - }, - [3] = { - ["coords"] = vec3(1175.25, 2714.51, 38.07), - ["isBusy"] = false, - ["isOpened"] = false - }, - [4] = { - ["coords"] = vec3(1175.26, 2715.97, 38.07), - ["isBusy"] = false, - ["isOpened"] = false - }, - [5] = { - ["coords"] = vec3(1174.27, 2716.83, 38.07), - ["isBusy"] = false, - ["isOpened"] = false - }, - [6] = { - ["coords"] = vec3(1172.32, 2716.82, 38.07), - ["isBusy"] = false, - ["isOpened"] = false - }, - [7] = { - ["coords"] = vec3(1171.25, 2716.08, 38.07), - ["isBusy"] = false, - ["isOpened"] = false - }, - [8] = { - ["coords"] = vec3(1171.23, 2714.44, 38.07), - ["isBusy"] = false, - ["isOpened"] = false - }, + camId = 25, + isOpened = false, + lockers = { + [1] = {coords = vec3(1173.69, 2710.76, 38.07), isBusy = false, isOpened = false}, + [2] = {coords = vec3(1171.78, 2711.94, 38.07), isBusy = false, isOpened = false}, + [3] = {coords = vec3(1175.25, 2714.51, 38.07), isBusy = false, isOpened = false}, + [4] = {coords = vec3(1175.26, 2715.97, 38.07), isBusy = false, isOpened = false}, + [5] = {coords = vec3(1174.27, 2716.83, 38.07), isBusy = false, isOpened = false}, + [6] = {coords = vec3(1172.32, 2716.82, 38.07), isBusy = false, isOpened = false}, + [7] = {coords = vec3(1171.25, 2716.08, 38.07), isBusy = false, isOpened = false}, + [8] = {coords = vec3(1171.23, 2714.44, 38.07), isBusy = false, isOpened = false}, }, }, }, bigBanks = { - ["paleto"] = { - ["label"] = "Blaine County Savings Bank", - ["coords"] = vec3(-105.61, 6472.03, 31.62), - ["alarm"] = true, - ["object"] = -1185205679, - ["heading"] = { + paleto = { + label = 'Blaine County Savings Bank', + coords = vec3(-105.61, 6472.03, 31.62), + alarm = true, + object = -1185205679, + heading = { closed = 45.45, open = 130.45 }, - ["thermite"] = { - [1] = { - ["coords"] = vec3(-106.11, 6475.36, 31.62), - ["isOpened"] = false, - ["doorId"] = 5 - } + thermite = { + [1] = {coords = vec3(-106.11, 6475.36, 31.62), + isOpened = false, + doorId = 5}, }, - ["camId"] = 26, - ["isOpened"] = false, - ["lockers"] = { - [1] = { - ["coords"] = vec3(-107.4, 6473.87, 31.62), - ["isBusy"] = false, - ["isOpened"] = false - }, - [2] = { - ["coords"] = vec3(-107.66, 6475.61, 31.62), - ["isBusy"] = false, - ["isOpened"] = false - }, - [3] = { - ["coords"] = vec3(-103.52, 6475.03, 31.62), - ["isBusy"] = false, - ["isOpened"] = false - }, - [4] = { - ["coords"] = vec3(-102.3, 6476.13, 31.66), - ["isBusy"] = false, - ["isOpened"] = false - }, - [5] = { - ["coords"] = vec3(-102.43, 6477.45, 31.67), - ["isBusy"] = false, - ["isOpened"] = false - }, - [6] = { - ["coords"] = vec3(-103.97, 6478.97, 31.62), - ["isBusy"] = false, - ["isOpened"] = false - }, - [7] = { - ["coords"] = vec3(-105.39, 6479.19, 31.67), - ["isBusy"] = false, - ["isOpened"] = false - }, - [8] = { - ["coords"] = vec3(-106.57, 6478.01, 31.62), - ["isBusy"] = false, - ["isOpened"] = false - } + camId = 26, + isOpened = false, + lockers = { + [1] = {coords = vec3(-107.4, 6473.87, 31.62), isBusy = false, isOpened = false}, + [2] = {coords = vec3(-107.66, 6475.61, 31.62), isBusy = false, isOpened = false}, + [3] = {coords = vec3(-103.52, 6475.03, 31.62), isBusy = false, isOpened = false}, + [4] = {coords = vec3(-102.3, 6476.13, 31.66), isBusy = false, isOpened = false}, + [5] = {coords = vec3(-102.43, 6477.45, 31.67), isBusy = false, isOpened = false}, + [6] = {coords = vec3(-103.97, 6478.97, 31.62), isBusy = false, isOpened = false}, + [7] = {coords = vec3(-105.39, 6479.19, 31.67), isBusy = false, isOpened = false}, + [8] = { coords = vec3(-106.57, 6478.01, 31.62), isBusy = false, isOpened = false}, } }, - ["pacific"] = { - ["label"] = "Pacific Standard", - ["coords"] = { + pacific = { + label = 'Pacific Standard', + coords = { [1] = vec3(261.95, 223.11, 106.28), [2] = vec3(253.25, 228.44, 101.68) }, - ["alarm"] = true, - ["object"] = 961976194, - ["heading"] = { + alarm = true, + object = 961976194, + heading = { closed = 160.00001, open = 70.00001 }, - ["thermite"] = { - [1] = { - ["coords"] = vec3(252.55, 221.15, 101.68), - ["isOpened"] = false, - ["doorId"] = 2 - }, - [2] = { - ["coords"] = vec3(261.15, 215.21, 101.68), - ["isOpened"] = false, - ["doorId"] = 3 - } + thermite = { + [1] = {coords = vec3(252.55, 221.15, 101.68), isOpened = false, doorId = 2}, + [2] = {coords = vec3(261.15, 215.21, 101.68), isOpened = false, doorId = 3}, }, - ["camId"] = 26, - ["isOpened"] = false, - ["lockers"] = { - [1] = { - ["coords"] = vec3(258.57, 218.36, 101.68), - ["isBusy"] = false, - ["isOpened"] = false - }, - [2] = { - ["coords"] = vec3(260.82, 217.62, 101.68), - ["isBusy"] = false, - ["isOpened"] = false - }, - [3] = { - ["coords"] = vec3(259.33, 213.76, 101.68), - ["isBusy"] = false, - ["isOpened"] = false - }, - [4] = { - ["coords"] = vec3(257.09, 214.55, 101.68), - ["isBusy"] = false, - ["isOpened"] = false - }, - [5] = { - ["coords"] = vec3(263.7, 216.48, 101.68), - ["isBusy"] = false, - ["isOpened"] = false - }, - [6] = { - ["coords"] = vec3(265.81, 215.81, 101.68), - ["isBusy"] = false, - ["isOpened"] = false - }, - [7] = { - ["coords"] = vec3(266.43, 214.37, 101.68), - ["isBusy"] = false, - ["isOpened"] = false - }, - [8] = { - ["coords"] = vec3(265.71, 212.49, 101.68), - ["isBusy"] = false, - ["isOpened"] = false - }, - [9] = { - ["coords"] = vec3(264.24, 211.92, 101.68), - ["isBusy"] = false, - ["isOpened"] = false - }, - [10] = { - ["coords"] = vec3(262.21, 212.67, 101.68), - ["isBusy"] = false, - ["isOpened"] = false - }, + camId = 26, + isOpened = false, + lockers = { + [1] = {coords = vec3(258.57, 218.36, 101.68), isBusy = false, isOpened = false}, + [2] = {coords = vec3(260.82, 217.62, 101.68), isBusy = false, isOpened = false}, + [3] = {coords = vec3(259.33, 213.76, 101.68), isBusy = false, isOpened = false}, + [4] = {coords = vec3(257.09, 214.55, 101.68), isBusy = false, isOpened = false}, + [5] = {coords = vec3(263.7, 216.48, 101.68), isBusy = false, isOpened = false}, + [6] = {coords = vec3(265.81, 215.81, 101.68), isBusy = false, isOpened = false}, + [7] = {coords = vec3(266.43, 214.37, 101.68), isBusy = false, isOpened = false}, + [8] = {coords = vec3(265.71, 212.49, 101.68), isBusy = false, isOpened = false}, + [9] = {coords = vec3(264.24, 211.92, 101.68), isBusy = false, isOpened = false}, + [10] = {coords = vec3(262.21, 212.67, 101.68), isBusy = false, isOpened = false}, }, }, }, diff --git a/server/main.lua b/server/main.lua index 5d80ef5..0fd74b5 100644 --- a/server/main.lua +++ b/server/main.lua @@ -2,13 +2,12 @@ local config = require 'config.server' local sharedConfig = require 'config.shared' local robberyBusy = false local timeOut = false - --- Functions +local ITEMS = exports.ox_inventory:Items() --- This will convert a table's keys into an array --- @param tbl table --- @return array -local function TableKeysToArray(tbl) +local function tableKeysToArray(tbl) local array = {} for k in pairs(tbl) do array[#array+1] = k @@ -19,7 +18,7 @@ end --- This will loop over the given table to check if the power stations in the table have been hit --- @param toLoop table --- @return boolean -local function TableLoopStations(toLoop) +local function tableLoopStations(toLoop) local hits = 0 for _, station in pairs(toLoop) do if type(station) == 'table' then @@ -38,7 +37,7 @@ end --- This will check what stations have been hit and update them accordingly --- @return nil -local function CheckStationHits() +local function checkStationHits() local policeHits = {} local bankHits = {} @@ -49,13 +48,13 @@ local function CheckStationHits() for _, cameraType in pairs(v.type) do if cameraType == 'police' then if type(v.stationsToHitPolice) == 'table' then - allStationsHitPolice = TableLoopStations(v.stationsToHitPolice) + allStationsHitPolice = tableLoopStations(v.stationsToHitPolice) else allStationsHitPolice = sharedConfig.powerStations[v.stationsToHitPolice].hit end elseif cameraType == 'bank' then if type(v.stationsToHitBank) == 'table' then - allStationsHitBank = TableLoopStations(v.stationsToHitBank) + allStationsHitBank = tableLoopStations(v.stationsToHitBank) else allStationsHitBank = sharedConfig.powerStations[v.stationsToHitBank].hit end @@ -64,13 +63,13 @@ local function CheckStationHits() else if v.type == 'police' then if type(v.stationsToHitPolice) == 'table' then - allStationsHitPolice = TableLoopStations(v.stationsToHitPolice) + allStationsHitPolice = tableLoopStations(v.stationsToHitPolice) else allStationsHitPolice = sharedConfig.powerStations[v.stationsToHitPolice].hit end elseif v.type == 'bank' then if type(v.stationsToHitBank) == 'table' then - allStationsHitBank = TableLoopStations(v.stationsToHitBank) + allStationsHitBank = tableLoopStations(v.stationsToHitBank) else allStationsHitBank = sharedConfig.powerStations[v.stationsToHitBank].hit end @@ -86,18 +85,18 @@ local function CheckStationHits() end end - policeHits = TableKeysToArray(policeHits) - bankHits = TableKeysToArray(bankHits) + policeHits = tableKeysToArray(policeHits) + bankHits = tableKeysToArray(bankHits) -- table.type checks if it's empty as well, if it's empty it will return the type 'empty' instead of 'array' - if table.type(policeHits) == 'array' then TriggerClientEvent("police:client:SetCamera", -1, policeHits, false) end - if table.type(bankHits) == 'array' then TriggerClientEvent("qb-bankrobbery:client:BankSecurity", -1, bankHits, false) end + if table.type(policeHits) == 'array' then TriggerClientEvent('police:client:SetCamera', -1, policeHits, false) end + if table.type(bankHits) == 'array' then TriggerClientEvent('qb-bankrobbery:client:BankSecurity', -1, bankHits, false) end end --- This will do a quick check to see if all stations have been hit --- @return boolean -local function AllStationsHit() +local function allStationsHit() local hit = 0 for k in pairs(sharedConfig.powerStations) do if sharedConfig.powerStations[k].hit then @@ -111,7 +110,7 @@ end --- @param coords vector3 --- @param dist number --- @return boolean -local function IsNearPowerStation(coords, dist) +local function isNearPowerStation(coords, dist) for _, v in pairs(sharedConfig.powerStations) do if #(coords - v.coords) < dist then return true @@ -124,9 +123,9 @@ end ---@param bankId string | number ---@param state boolean local function changeBankState(bankId, state) - local bankName = type(bankId) == "number" and "bankrobbery" or bankId + local bankName = type(bankId) == 'number' and 'bankrobbery' or bankId TriggerEvent('qb-scoreboard:server:SetActivityBusy', bankName, state) - if bankName ~= "bankrobbery" then return end + if bankName ~= 'bankrobbery' then return end TriggerEvent('qb-banking:server:SetBankClosed', bankId, state) end @@ -135,170 +134,168 @@ local function changeBlackoutState(state) TriggerClientEvent(eventName, -1) end --- Events - RegisterNetEvent('qb-bankrobbery:server:setBankState', function(bankId) if robberyBusy then return end - if bankId == "paleto" then - if sharedConfig.bigBanks["paleto"]["isOpened"] or #(GetEntityCoords(GetPlayerPed(source)) - sharedConfig.bigBanks["paleto"]["coords"]) > 2.5 then - return error(Lang:t("error.event_trigger_wrong", {event = "qb-bankrobbery:server:setBankState", extraInfo = " (paleto) ", source = source})) + if bankId == 'paleto' then + if sharedConfig.bigBanks.paleto.isOpened or #(GetEntityCoords(GetPlayerPed(source)) - sharedConfig.bigBanks.paleto.coords) > 2.5 then + return error(Lang:t('error.event_trigger_wrong', {event = 'qb-bankrobbery:server:setBankState', extraInfo = ' (paleto) ', source = source})) end - sharedConfig.bigBanks["paleto"]["isOpened"] = true + sharedConfig.bigBanks.paleto.isOpened = true TriggerEvent('qb-bankrobbery:server:setTimeout') - elseif bankId == "pacific" then - if sharedConfig.bigBanks["pacific"]["isOpened"] or #(GetEntityCoords(GetPlayerPed(source)) - sharedConfig.bigBanks["pacific"]["coords"][2]) > 2.5 then - return error(Lang:t("error.event_trigger_wrong", {event = "qb-bankrobbery:server:setBankState", extraInfo = " (pacific) ", source = source})) + elseif bankId == 'pacific' then + if sharedConfig.bigBanks.pacific.isOpened or #(GetEntityCoords(GetPlayerPed(source)) - sharedConfig.bigBanks.pacific.coords[2]) > 2.5 then + return error(Lang:t('error.event_trigger_wrong', {event = 'qb-bankrobbery:server:setBankState', extraInfo = ' (pacific) ', source = source})) end - sharedConfig.bigBanks["pacific"]["isOpened"] = true + sharedConfig.bigBanks.pacific.isOpened = true TriggerEvent('qb-bankrobbery:server:setTimeout') else - if sharedConfig.smallBanks[bankId]["isOpened"] or #(GetEntityCoords(GetPlayerPed(source)) - sharedConfig.smallBanks[bankId]["coords"]) > 2.5 then - return error(Lang:t("error.event_trigger_wrong", {event = "qb-bankrobbery:server:setBankState", extraInfo = " (smallbank "..bankId..") ", source = source})) + if sharedConfig.smallBanks[bankId].isOpened or #(GetEntityCoords(GetPlayerPed(source)) - sharedConfig.smallBanks[bankId].coords) > 2.5 then + return error(Lang:t('error.event_trigger_wrong', {event = 'qb-bankrobbery:server:setBankState', extraInfo = ' (smallbank '..bankId..') ', source = source})) end - sharedConfig.smallBanks[bankId]["isOpened"] = true + sharedConfig.smallBanks[bankId].isOpened = true TriggerEvent('qb-bankrobbery:server:SetSmallBankTimeout', bankId) end TriggerClientEvent('qb-bankrobbery:client:setBankState', -1, bankId) robberyBusy = true - local bankName = type(bankId) == "number" and "bankrobbery" or bankId + local bankName = type(bankId) == 'number' and 'bankrobbery' or bankId TriggerEvent('qb-scoreboard:server:SetActivityBusy', bankName, true) - if bankName ~= "bankrobbery" then return end + if bankName ~= 'bankrobbery' then return end TriggerEvent('qb-banking:server:SetBankClosed', bankId, true) changeBankState(bankId, true) end) RegisterNetEvent('qb-bankrobbery:server:setLockerState', function(bankId, lockerId, state, bool) - if bankId == "paleto" or bankId == "pacific" then - if #(GetEntityCoords(GetPlayerPed(source)) - sharedConfig.bigBanks[bankId]["lockers"][lockerId]["coords"]) > 2.5 then - return error(Lang:t("error.event_trigger_wrong", {event = "qb-bankrobbery:server:setLockerState", extraInfo = " ("..bankId..") ", source = source})) + if bankId == 'paleto' or bankId == 'pacific' then + if #(GetEntityCoords(GetPlayerPed(source)) - sharedConfig.bigBanks[bankId].lockers[lockerId].coords) > 2.5 then + return error(Lang:t('error.event_trigger_wrong', {event = 'qb-bankrobbery:server:setLockerState', extraInfo = ' ('..bankId..') ', source = source})) end - sharedConfig.bigBanks[bankId]["lockers"][lockerId][state] = bool + sharedConfig.bigBanks[bankId].lockers[lockerId][state] = bool else - if #(GetEntityCoords(GetPlayerPed(source)) - sharedConfig.smallBanks[bankId]["lockers"][lockerId]["coords"]) > 2.5 then - return error(Lang:t("error.event_trigger_wrong", {event = "qb-bankrobbery:server:setLockerState", extraInfo = " (smallbank "..bankId..") ", source = source})) + if #(GetEntityCoords(GetPlayerPed(source)) - sharedConfig.smallBanks[bankId].lockers[lockerId].coords) > 2.5 then + return error(Lang:t('error.event_trigger_wrong', {event = 'qb-bankrobbery:server:setLockerState', extraInfo = ' (smallbank '..bankId..') ', source = source})) end - sharedConfig.smallBanks[bankId]["lockers"][lockerId][state] = bool + sharedConfig.smallBanks[bankId].lockers[lockerId][state] = bool end TriggerClientEvent('qb-bankrobbery:client:setLockerState', -1, bankId, lockerId, state, bool) end) RegisterNetEvent('qb-bankrobbery:server:recieveItem', function(type, bankId, lockerId) local src = source - local ply = exports.qbx_core:GetPlayer(src) - if not ply then return end - if type == "small" then - if #(GetEntityCoords(GetPlayerPed(src)) - sharedConfig.smallBanks[bankId]["lockers"][lockerId]["coords"]) > 2.5 then - return error(Lang:t("error.event_trigger_wrong", {event = "qb-bankrobbery:server:receiveItem", extraInfo = " (smallbank "..bankId..") ", source = source})) + local player = exports.qbx_core:GetPlayer(src) + if not player then return end + if type == 'small' then + if #(GetEntityCoords(GetPlayerPed(src)) - sharedConfig.smallBanks[bankId].lockers[lockerId].coords) > 2.5 then + return error(Lang:t('error.event_trigger_wrong', {event = 'qb-bankrobbery:server:receiveItem', extraInfo = ' (smallbank '..bankId..') ', source = source})) end local itemType = math.random(#config.rewardTypes) - local WeaponChance = math.random(1, 50) + local weaponChance = math.random(1, 50) local odd1 = math.random(1, 50) local tierChance = math.random(1, 100) local tier if tierChance < 50 then tier = 1 elseif tierChance >= 50 and tierChance < 80 then tier = 2 elseif tierChance >= 80 and tierChance < 95 then tier = 3 else tier = 4 end - if WeaponChance ~= odd1 then + if weaponChance ~= odd1 then if tier ~= 4 then - if config.rewardTypes[itemType].type == "item" then - local item = config.lockerRewards["tier"..tier][math.random(#config.lockerRewards["tier"..tier])] + if config.rewardTypes[itemType].type == 'item' then + local item = config.lockerRewards['tier'..tier][math.random(#config.lockerRewards['tier'..tier])] local itemAmount = math.random(item.minAmount, item.maxAmount) - ply.Functions.AddItem(item.item, itemAmount) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()[item.item], "add") - elseif config.rewardTypes[itemType].type == "money" then + player.Functions.AddItem(item.item, itemAmount) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS[item.item], 'add') + elseif config.rewardTypes[itemType].type == 'money' then local info = { worth = math.random(2300, 3200) } - ply.Functions.AddItem('markedbills', math.random(2,3), false, info) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()['markedbills'], "add") + player.Functions.AddItem('markedbills', math.random(2,3), false, info) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS['markedbills'], 'add') end else - ply.Functions.AddItem('security_card_01', 1) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()['security_card_01'], "add") + player.Functions.AddItem('security_card_01', 1) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS['security_card_01'], 'add') end else - ply.Functions.AddItem('weapon_stungun', 1) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()['weapon_stungun'], "add") + player.Functions.AddItem('weapon_stungun', 1) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS['weapon_stungun'], 'add') end - elseif type == "paleto" then - if #(GetEntityCoords(GetPlayerPed(source)) - sharedConfig.bigBanks["paleto"]["lockers"][lockerId]["coords"]) > 2.5 then - return error(Lang:t("error.event_trigger_wrong", {event = "qb-bankrobbery:server:receiveItem", extraInfo = " (paleto) ", source = source})) + elseif type == 'paleto' then + if #(GetEntityCoords(GetPlayerPed(source)) - sharedConfig.bigBanks.paleto.lockers[lockerId].coords) > 2.5 then + return error(Lang:t('error.event_trigger_wrong', {event = 'qb-bankrobbery:server:receiveItem', extraInfo = ' (paleto) ', source = source})) end local itemType = math.random(#config.rewardTypes) local tierChance = math.random(1, 100) - local WeaponChance = math.random(1, 10) + local weaponChance = math.random(1, 10) local odd1 = math.random(1, 10) local tier if tierChance < 25 then tier = 1 elseif tierChance >= 25 and tierChance < 70 then tier = 2 elseif tierChance >= 70 and tierChance < 95 then tier = 3 else tier = 4 end - if WeaponChance ~= odd1 then + if weaponChance ~= odd1 then if tier ~= 4 then - if config.rewardTypes[itemType].type == "item" then - local item = config.lockerRewardsPaleto["tier"..tier][math.random(#config.lockerRewardsPaleto["tier"..tier])] + if config.rewardTypes[itemType].type == 'item' then + local item = config.lockerRewardsPaleto['tier'..tier][math.random(#config.lockerRewardsPaleto['tier'..tier])] local itemAmount = math.random(item.minAmount, item.maxAmount) - ply.Functions.AddItem(item.item, itemAmount) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()[item.item], "add") - elseif config.rewardTypes[itemType].type == "money" then + player.Functions.AddItem(item.item, itemAmount) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS[item.item], 'add') + elseif config.rewardTypes[itemType].type == 'money' then local info = { worth = math.random(4000, 6000) } - ply.Functions.AddItem('markedbills', math.random(1,4), false, info) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()['markedbills'], "add") + player.Functions.AddItem('markedbills', math.random(1,4), false, info) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS['markedbills'], 'add') end else - ply.Functions.AddItem('security_card_02', 1) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()['security_card_02'], "add") + player.Functions.AddItem('security_card_02', 1) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS['security_card_02'], 'add') end else - ply.Functions.AddItem('weapon_vintagepistol', 1) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()['weapon_vintagepistol'], "add") + player.Functions.AddItem('weapon_vintagepistol', 1) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS['weapon_vintagepistol'], 'add') end - elseif type == "pacific" then - if #(GetEntityCoords(GetPlayerPed(source)) - sharedConfig.bigBanks["pacific"]["lockers"][lockerId]["coords"]) > 2.5 then - return error(Lang:t("error.event_trigger_wrong", {event = "qb-bankrobbery:server:receiveItem", extraInfo = " (pacific) ", source = source})) + elseif type == 'pacific' then + if #(GetEntityCoords(GetPlayerPed(source)) - sharedConfig.bigBanks.pacific.lockers[lockerId].coords) > 2.5 then + return error(Lang:t('error.event_trigger_wrong', {event = 'qb-bankrobbery:server:receiveItem', extraInfo = ' (pacific) ', source = source})) end local itemType = math.random(#config.rewardTypes) - local WeaponChance = math.random(1, 100) + local weaponChance = math.random(1, 100) local odd1 = math.random(1, 100) local odd2 = math.random(1, 100) local tierChance = math.random(1, 100) local tier if tierChance < 10 then tier = 1 elseif tierChance >= 25 and tierChance < 50 then tier = 2 elseif tierChance >= 50 and tierChance < 95 then tier = 3 else tier = 4 end - if WeaponChance ~= odd1 or WeaponChance ~= odd2 then + if weaponChance ~= odd1 or weaponChance ~= odd2 then if tier ~= 4 then - if config.rewardTypes[itemType].type == "item" then - local item = config.lockerRewardsPacific["tier"..tier][math.random(#config.lockerRewardsPacific["tier"..tier])] + if config.rewardTypes[itemType].type == 'item' then + local item = config.lockerRewardsPacific['tier'..tier][math.random(#config.lockerRewardsPacific['tier'..tier])] local maxAmount if tier == 3 then maxAmount = 7 elseif tier == 2 then maxAmount = 18 else maxAmount = 25 end local itemAmount = math.random(maxAmount) - ply.Functions.AddItem(item.item, itemAmount) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()[item.item], "add") - elseif config.rewardTypes[itemType].type == "money" then + player.Functions.AddItem(item.item, itemAmount) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS[item.item], 'add') + elseif config.rewardTypes[itemType].type == 'money' then local info = { worth = math.random(19000, 21000) } - ply.Functions.AddItem('markedbills', math.random(1,4), false, info) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()['markedbills'], "add") + player.Functions.AddItem('markedbills', math.random(1,4), false, info) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS['markedbills'], 'add') end else local info = { worth = math.random(19000, 21000) } - ply.Functions.AddItem('markedbills', math.random(1,4), false, info) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()['markedbills'], "add") + player.Functions.AddItem('markedbills', math.random(1,4), false, info) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS['markedbills'], 'add') info = { crypto = math.random(1, 3) } - ply.Functions.AddItem("cryptostick", 1, false, info) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()['cryptostick'], "add") + player.Functions.AddItem('cryptostick', 1, false, info) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS['cryptostick'], 'add') end else local chance = math.random(1, 2) local odd = math.random(1, 2) if chance == odd then - ply.Functions.AddItem('weapon_microsmg', 1) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()['weapon_microsmg'], "add") + player.Functions.AddItem('weapon_microsmg', 1) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS['weapon_microsmg'], 'add') else - ply.Functions.AddItem('weapon_minismg', 1) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()['weapon_minismg'], "add") + player.Functions.AddItem('weapon_minismg', 1) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS['weapon_minismg'], 'add') end end end @@ -309,17 +306,17 @@ AddEventHandler('qb-bankrobbery:server:setTimeout', function() timeOut = true CreateThread(function() SetTimeout(60000 * 90, function() - for k in pairs(sharedConfig.bigBanks["pacific"]["lockers"]) do - sharedConfig.bigBanks["pacific"]["lockers"][k]["isBusy"] = false - sharedConfig.bigBanks["pacific"]["lockers"][k]["isOpened"] = false + for k in pairs(sharedConfig.bigBanks.pacific.lockers) do + sharedConfig.bigBanks.pacific.lockers[k].isBusy = false + sharedConfig.bigBanks.pacific.lockers[k].isOpened = false end - for k in pairs(sharedConfig.bigBanks["paleto"]["lockers"]) do - sharedConfig.bigBanks["paleto"]["lockers"][k]["isBusy"] = false - sharedConfig.bigBanks["paleto"]["lockers"][k]["isOpened"] = false + for k in pairs(sharedConfig.bigBanks.paleto.lockers) do + sharedConfig.bigBanks.paleto.lockers[k].isBusy = false + sharedConfig.bigBanks.paleto.lockers[k].isOpened = false end TriggerClientEvent('qb-bankrobbery:client:ClearTimeoutDoors', -1) - sharedConfig.bigBanks["paleto"]["isOpened"] = false - sharedConfig.bigBanks["pacific"]["isOpened"] = false + sharedConfig.bigBanks.paleto.isOpened = false + sharedConfig.bigBanks.pacific.isOpened = false timeOut = false robberyBusy = false changeBankState('paleto', false) @@ -333,9 +330,9 @@ AddEventHandler('qb-bankrobbery:server:SetSmallBankTimeout', function(bankId) timeOut = true CreateThread(function() SetTimeout(60000 * 30, function() - for k in pairs(sharedConfig.smallBanks[bankId]["lockers"]) do - sharedConfig.smallBanks[bankId]["lockers"][k]["isOpened"] = false - sharedConfig.smallBanks[bankId]["lockers"][k]["isBusy"] = false + for k in pairs(sharedConfig.smallBanks[bankId].lockers) do + sharedConfig.smallBanks[bankId].lockers[k].isOpened = false + sharedConfig.smallBanks[bankId].lockers[k].isBusy = false end TriggerClientEvent('qb-bankrobbery:client:ResetFleecaLockers', -1, bankId) timeOut = false @@ -346,73 +343,73 @@ AddEventHandler('qb-bankrobbery:server:SetSmallBankTimeout', function(bankId) end) RegisterNetEvent('qb-bankrobbery:server:callCops', function(type, bank, coords) - if type == "small" then - if not sharedConfig.smallBanks[bank]["alarm"] then - return error(Lang:t("error.event_trigger_wrong", {event = "qb-bankrobbery:server:callCops", extraInfo = " (smallbank "..bank..") ", source = source})) + if type == 'small' then + if not sharedConfig.smallBanks[bank].alarm then + return error(Lang:t('error.event_trigger_wrong', {event = 'qb-bankrobbery:server:callCops', extraInfo = ' (smallbank '..bank..') ', source = source})) end - elseif type == "paleto" then - if not sharedConfig.bigBanks["paleto"]["alarm"] then - return error(Lang:t("error.event_trigger_wrong", {event = "qb-bankrobbery:server:callCops", extraInfo = " (paleto) ", source = source})) + elseif type == 'paleto' then + if not sharedConfig.bigBanks.paleto.alarm then + return error(Lang:t('error.event_trigger_wrong', {event = 'qb-bankrobbery:server:callCops', extraInfo = ' (paleto) ', source = source})) end - elseif type == "pacific" then - if not sharedConfig.bigBanks["pacific"]["alarm"] then - return error(Lang:t("error.event_trigger_wrong", {event = "qb-bankrobbery:server:callCops", extraInfo = " (pacific) ", source = source})) + elseif type == 'pacific' then + if not sharedConfig.bigBanks.pacific.alarm then + return error(Lang:t('error.event_trigger_wrong', {event = 'qb-bankrobbery:server:callCops', extraInfo = ' (pacific) ', source = source})) end end - TriggerClientEvent("qb-bankrobbery:client:robberyCall", -1, type, coords) + TriggerClientEvent('qb-bankrobbery:client:robberyCall', -1, type, coords) end) RegisterNetEvent('qb-bankrobbery:server:SetStationStatus', function(key, isHit) sharedConfig.powerStations[key].hit = isHit - TriggerClientEvent("qb-bankrobbery:client:SetStationStatus", -1, key, isHit) - if AllStationsHit() then - exports["qb-weathersync"]:setBlackout(true) - TriggerClientEvent("qb-bankrobbery:client:disableAllBankSecurity", -1) + TriggerClientEvent('qb-bankrobbery:client:SetStationStatus', -1, key, isHit) + if allStationsHit() then + exports['qb-weathersync']:setBlackout(true) + TriggerClientEvent('qb-bankrobbery:client:disableAllBankSecurity', -1) changeBlackoutState(true) CreateThread(function() SetTimeout(60000 * config.blackoutTimer, function() - exports["qb-weathersync"]:setBlackout(false) - TriggerClientEvent("qb-bankrobbery:client:enableAllBankSecurity", -1) + exports['qb-weathersync']:setBlackout(false) + TriggerClientEvent('qb-bankrobbery:client:enableAllBankSecurity', -1) changeBlackoutState(false) end) end) else - CheckStationHits() + checkStationHits() end end) RegisterNetEvent('qb-bankrobbery:server:removeElectronicKit', function() local src = source - local Player = exports.qbx_core:GetPlayer(src) - if not Player then return end - Player.Functions.RemoveItem('electronickit', 1) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()["electronickit"], "remove") - Player.Functions.RemoveItem('trojan_usb', 1) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()["trojan_usb"], "remove") + local player = exports.qbx_core:GetPlayer(src) + if not player then return end + player.Functions.RemoveItem('electronickit', 1) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS['electronickit'], 'remove') + player.Functions.RemoveItem('trojan_usb', 1) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS['trojan_usb'], 'remove') end) RegisterNetEvent('qb-bankrobbery:server:removeBankCard', function(number) local src = source - local Player = exports.qbx_core:GetPlayer(src) - if not Player then return end - Player.Functions.RemoveItem('security_card_'..number, 1) - TriggerClientEvent('inventory:client:ItemBox', src, exports.ox_inventory:Items()['security_card_'..number], "remove") + local player = exports.qbx_core:GetPlayer(src) + if not player then return end + player.Functions.RemoveItem('security_card_'..number, 1) + TriggerClientEvent('inventory:client:ItemBox', src,ITEMS['security_card_'..number], 'remove') end) RegisterNetEvent('thermite:StartServerFire', function(coords, maxChildren, isGasFire) local src = source local ped = GetPlayerPed(src) local coords2 = GetEntityCoords(ped) - local thermiteCoords = sharedConfig.bigBanks['pacific'].thermite[1].coords - local thermite2Coords = sharedConfig.bigBanks['pacific'].thermite[2].coords - local thermite3Coords = sharedConfig.bigBanks['paleto'].thermite[1].coords - if #(coords2 - thermiteCoords) < 10 or #(coords2 - thermite2Coords) < 10 or #(coords2 - thermite3Coords) < 10 or IsNearPowerStation(coords2, 10) then - TriggerClientEvent("thermite:StartFire", -1, coords, maxChildren, isGasFire) + local thermiteCoords = sharedConfig.bigBanks.pacific.thermite[1].coords + local thermite2Coords = sharedConfig.bigBanks.pacific.thermite[2].coords + local thermite3Coords = sharedConfig.bigBanks.paleto.thermite[1].coords + if #(coords2 - thermiteCoords) < 10 or #(coords2 - thermite2Coords) < 10 or #(coords2 - thermite3Coords) < 10 or isNearPowerStation(coords2, 10) then + TriggerClientEvent('thermite:StartFire', -1, coords, maxChildren, isGasFire) end end) RegisterNetEvent('thermite:StopFires', function() - TriggerClientEvent("thermite:StopFires", -1) + TriggerClientEvent('thermite:StopFires', -1) end) -- Callbacks @@ -425,10 +422,10 @@ lib.callback.register('qb-bankrobbery:server:GetConfig', function() end) lib.callback.register('thermite:server:check', function(source) - local Player = exports.qbx_core:GetPlayer(source) - if not Player then return false end - if Player.Functions.RemoveItem("thermite", 1) then - TriggerClientEvent('inventory:client:ItemBox', source, exports.ox_inventory:Items()["thermite"], "remove") + local player = exports.qbx_core:GetPlayer(source) + if not player then return false end + if player.Functions.RemoveItem('thermite', 1) then + TriggerClientEvent('inventory:client:ItemBox', source,ITEMS['thermite'], 'remove') return true else return false @@ -437,30 +434,30 @@ end) -- Items -exports.qbx_core:CreateUseableItem("thermite", function(source) - local Player = exports.qbx_core:GetPlayer(source) - if not Player or not Player.Functions.GetItemByName('thermite') then return end - if Player.Functions.GetItemByName('lighter') then - TriggerClientEvent("thermite:UseThermite", source) +exports.qbx_core:CreateUseableItem('thermite', function(source) + local player = exports.qbx_core:GetPlayer(source) + if not player or not player.Functions.GetItemByName('thermite') then return end + if player.Functions.GetItemByName('lighter') then + TriggerClientEvent('thermite:UseThermite', source) else - TriggerClientEvent('QBCore:Notify', source, Lang:t("error.missing_ignition_source"), "error") + TriggerClientEvent('QBCore:Notify', source, Lang:t('error.missing_ignition_source'), 'error') end end) -exports.qbx_core:CreateUseableItem("security_card_01", function(source) - local Player = exports.qbx_core:GetPlayer(source) - if not Player or not Player.Functions.GetItemByName('security_card_01') then return end - TriggerClientEvent("qb-bankrobbery:UseBankcardA", source) +exports.qbx_core:CreateUseableItem('security_card_01', function(source) + local player = exports.qbx_core:GetPlayer(source) + if not player or not player.Functions.GetItemByName('security_card_01') then return end + TriggerClientEvent('qb-bankrobbery:UseBankcardA', source) end) -exports.qbx_core:CreateUseableItem("security_card_02", function(source) - local Player = exports.qbx_core:GetPlayer(source) - if not Player or not Player.Functions.GetItemByName('security_card_02') then return end - TriggerClientEvent("qb-bankrobbery:UseBankcardB", source) +exports.qbx_core:CreateUseableItem('security_card_02', function(source) + local player = exports.qbx_core:GetPlayer(source) + if not player or not player.Functions.GetItemByName('security_card_02') then return end + TriggerClientEvent('qb-bankrobbery:UseBankcardB', source) end) -exports.qbx_core:CreateUseableItem("electronickit", function(source) - local Player = exports.qbx_core:GetPlayer(source) - if not Player or not Player.Functions.GetItemByName('electronickit') then return end - TriggerClientEvent("electronickit:UseElectronickit", source) +exports.qbx_core:CreateUseableItem('electronickit', function(source) + local player = exports.qbx_core:GetPlayer(source) + if not player or not player.Functions.GetItemByName('electronickit') then return end + TriggerClientEvent('electronickit:UseElectronickit', source) end)