diff --git a/VERSION b/VERSION index ea710ab..a58941b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2 \ No newline at end of file +1.3 \ No newline at end of file diff --git a/client.lua b/client.lua index 9b2e717..67684e3 100644 --- a/client.lua +++ b/client.lua @@ -57,9 +57,12 @@ CreateThread(function() MSK.HelpNotification(Translation[Config.Locale]['open_blackout']) if IsControlJustPressed(0, Config.Hotkey) and (not Config.blacklistedJobs.enable or not MSK.Table_Contains(Config.blacklistedJobs.jobs, playerJob)) then - local OnlineCops = MSK.TriggerCallback('msk_blackout:getCops') + local OnlineCops = 0 + if Config.Cops.enable then + OnlineCops = MSK.TriggerCallback('msk_blackout:getCops') + end - if OnlineCops >= Config.Cops.amount then + if not Config.Cops.enable or (Config.Cops.enable and OnlineCops >= Config.Cops.amount) then if Config.SkillCheck.animation.enable then RequestAnimDict(Config.SkillCheck.animation.dict) while not HasAnimDictLoaded(Config.SkillCheck.animation.dict) do diff --git a/config.lua b/config.lua index aebd7e9..f2f857f 100644 --- a/config.lua +++ b/config.lua @@ -16,7 +16,8 @@ end Config.Framework = 'ESX' -- 'ESX' or 'QBCore' Config.Hotkey = 38 -- deafult: 38 = E ---------------------------------------------------------------- -Config.useDoorsCreator = false -- Set to true if you use Jaksams Doors Creator and want to unlock all Doors while blackout +Config.useDoorlock = false -- Set to true if you want to unlock all Doors while blackout +Config.DoorlockScript = 'doors_creator' -- 'doors_creator' or 'ox_doorlock' ---------------------------------------------------------------- Config.Blackout = { generalLights = true, -- Set to true turns off all artificial light sources in the map @@ -26,9 +27,7 @@ Config.Blackout = { } Config.useWeatherScript = true -- Set false the Blackout does not work and add your Event below -Config.weatherScript = function(state) - -- This is a Server Event - +Config.weatherScript = function(state) -- This is a Server Event TriggerClientEvent('vSync:updateWeather', -1, 'CLEAR', state) -- vSync --exports["qb-weathersync"]:setBlackout(state) -- qb-weathersync end diff --git a/fxmanifest.lua b/fxmanifest.lua index 59e563e..8cc635a 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -4,7 +4,7 @@ games { 'gta5' } author 'Musiker15 - MSK Scripts' name 'msk_blackout' description 'Weather Blackout Miniheist' -version '1.2' +version '1.3' lua54 'yes' @@ -20,11 +20,13 @@ client_scripts { } server_scripts { + '@oxmysql/lib/MySQL.lua', 'server.lua' } dependencies { 'msk_core', -- https://github.com/MSK-Scripts/msk_core + 'oxmysql', 'ox_lib', -- https://github.com/overextended/ox_lib 'datacrack' -- https://github.com/utkuali/datacrack } \ No newline at end of file diff --git a/server.lua b/server.lua index 60f780a..9113be8 100644 --- a/server.lua +++ b/server.lua @@ -46,15 +46,39 @@ AddEventHandler('msk_blackout:syncBlackout', function(state) end TriggerClientEvent('msk_blackout:setBlackout', -1, state) - if Config.useDoorsCreator and state then - local doors = exports["doors_creator"]:getAllDoors() - for k, doorData in pairs(doors) do - exports["doors_creator"]:setDoorState(doorData.id, 0) + if not Config.useDoorlock then return end + + if state then -- If Blackout is enabled + if Config.DoorlockScript:match('doors_creator') then + local doors = exports["doors_creator"]:getAllDoors() + for k, doorData in pairs(doors) do + exports["doors_creator"]:setDoorState(doorData.id, 0) + end + elseif Config.DoorlockScript:match('ox_doorlock') then + MySQL.query('SELECT id FROM ox_doorlock', {}, function(result) + if result then + for i = 1, #result do + local door = exports.ox_doorlock:getDoor(result[i].id) + TriggerEvent('ox_doorlock:setState', door.id, 0) + end + end + end) end - elseif Config.useDoorsCreator and not state then - local doors = exports["doors_creator"]:getAllDoors() - for k, doorData in pairs(doors) do - exports["doors_creator"]:setDoorState(doorData.id, 1) + elseif not state then -- If Blackout is disabled + if Config.DoorlockScript:match('doors_creator') then + local doors = exports["doors_creator"]:getAllDoors() + for k, doorData in pairs(doors) do + exports["doors_creator"]:setDoorState(doorData.id, 1) + end + elseif Config.DoorlockScript:match('ox_doorlock') then + MySQL.query('SELECT id FROM ox_doorlock', {}, function(result) + if result then + for i = 1, #result do + local door = exports.ox_doorlock:getDoor(result[i].id) + TriggerEvent('ox_doorlock:setState', door.id, 1) + end + end + end) end end end)