Skip to content

Commit

Permalink
Update v1.3
Browse files Browse the repository at this point in the history
* Fixed Config.Cops function
* Added Support for ox_doorlock
  • Loading branch information
Musiker15 committed Mar 9, 2023
1 parent 18bf838 commit d4b74bc
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 16 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2
1.3
7 changes: 5 additions & 2 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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
}
40 changes: 32 additions & 8 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d4b74bc

Please sign in to comment.