Skip to content

Commit

Permalink
Update v1.7.4
Browse files Browse the repository at this point in the history
* Several Bugfixes
  • Loading branch information
Musiker15 committed Apr 13, 2024
1 parent 11a7306 commit 8509ce0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 40 deletions.
27 changes: 9 additions & 18 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ end

local startedBlackout, startBlackoutTeleport, hackedLaptop = false, false, false
local showHackLaptopHelp, teleportedOutOfBuilding, startedSabotage = false, false, false
local addTimeout, setBlackout = false, false
local setBlackout = false
local Blips, JobBlips, SabotageLocations = {}, {}, {}

CreateThread(function()
Expand Down Expand Up @@ -56,7 +56,7 @@ CreateThread(function()
if dist <= 2.5 and not IsPlayerDead(PlayerId()) and not startedBlackout then
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
if IsControlJustPressed(0, Config.Hotkey) and (not Config.blacklistedJobs.enable or not MSK.TableContains(Config.blacklistedJobs.jobs, playerJob)) then
local blackoutInProgress = MSK.Trigger('msk_blackout:isBlackoutInProgress')

if not blackoutInProgress then
Expand Down Expand Up @@ -314,8 +314,8 @@ showSabotageBlips = function()
CreateThread(function()
for k, v in pairs(Blips) do
RemoveBlip(v.blip)
Blips = {}
end
Blips = {}

for k, v in pairs(Config.SabotageTrafo.settings) do
if v.blip.enable then
Expand All @@ -342,9 +342,9 @@ stopBlackoutTask = function(success)
SabotageLocations = {}

for k, v in pairs(Blips) do
RemoveBlip(v)
Blips = {}
RemoveBlip(v.blip)
end
Blips = {}

if success then
TriggerServerEvent('msk_blackout:syncBlackout', true)
Expand All @@ -358,21 +358,18 @@ AddEventHandler('msk_blackout:setBlackout', function(state)

if state then
TriggerEvent('msk_blackout:powerOff')
addTimeout = MSK.AddTimeout(Config.Blackout.duration * 60000, function()
TriggerServerEvent('msk_blackout:syncBlackout', false)
end)
else
TriggerEvent('msk_blackout:powerOn')
MSK.DelTimeout(addTimeout)
end
end)

AddEventHandler('msk_blackout:powerOff', function()
logging('debug', 'Blackout powerOff')
sendJobBlipNotify(true)
end)

AddEventHandler('msk_blackout:powerOn', function()
logging('debug', 'powerOn')
logging('debug', 'Blackout powerOn')
end)

RegisterNetEvent('msk_blackout:sendJobBlipNotify')
Expand All @@ -384,8 +381,8 @@ sendJobBlipNotify = function(notify)
CreateThread(function()
for k, v in pairs(JobBlips) do
RemoveBlip(v)
JobBlips = {}
end
JobBlips = {}

if notify then return end

Expand Down Expand Up @@ -423,10 +420,4 @@ end
logging = function(code, ...)
if not Config.Debug then return end
MSK.Logging(code, ...)
end

AddEventHandler('onResourceStop', function(resource)
if GetCurrentResourceName() == resource then
MSK.DelTimeout(addTimeout)
end
end)
end
25 changes: 15 additions & 10 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,44 @@ Config.Hotkey = 38 -- deafult: 38 = E

Config.Timeout = 10 -- in minutes // Timeout before the next blackout can be started
----------------------------------------------------------------
Config.useDoorlock = false -- Set to true if you want to unlock all Doors while blackout
Config.useDoorlock = true -- Set to true if you want to unlock all Doors while blackout
Config.DoorlockScript = 'doors_creator' -- 'doors_creator' or 'ox_doorlock'
----------------------------------------------------------------
Config.Command = {
enable = true, -- Set to false if you don't want to use the Commands
groups = {'superadmin', 'admin', 'god'},
groups = {'superadmin', 'admin'},
command = 'toggleblackout' -- Toggles blackout on or off
}
----------------------------------------------------------------
Config.removeItem = true -- Remove the Item after use

Config.Items = { -- Add those items to your database or inventory
Config.Items = { -- Add those items to your database or inventory or insert your own items
['startDoor'] = 'lockpick',
['hackLaptop'] = 'usb_stick',
['trafos'] = 'hammerwirecutter'
['trafos'] = 'boltcutter'
}
----------------------------------------------------------------
Config.Blackout = {
generalLights = true, -- Set to true turns off all artificial light sources in the map
vehicleLights = true, -- Set to false ignores Vehicles
duration = 1 -- in minutes // Blackout Time
vehicleLights = false, -- Set to false ignores Vehicles
duration = 10 -- in minutes // Blackout Time
}

Config.useWeatherScript = true -- Set false the Blackout does not work and add your Event below
Config.weatherScript = function(state) -- This is a Server Event
TriggerClientEvent('vSync:updateWeather', -1, 'CLEAR', state) -- vSync
--exports["qb-weathersync"]:setBlackout(state) -- qb-weathersync
-- qb-weathersync
-- exports["qb-weathersync"]:setBlackout(state)

-- cd_easytime
local weather = exports['cd_easytime']:GetWeather()
weather.blackout = state
TriggerEvent('cd_easytime:ForceUpdate', weather)
end
----------------------------------------------------------------
Config.Cops = {
enable = true,
enable = false,
jobs = {'police', 'fib', 'sheriff'},
amount = 1, -- Minimum amount of Online Players with Police Job
amount = 2, -- Minimum amount of Online Players with Police Job
blip = {enable = true, color = 1},
}

Expand Down
4 changes: 2 additions & 2 deletions 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.7.2'
version '1.7.4'

lua54 'yes'

Expand Down Expand Up @@ -32,5 +32,5 @@ 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
'datacrack', -- https://github.com/utkuali/datacrack
}
34 changes: 24 additions & 10 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if Config.Framework:match('QBCore') then -- QBCore Framework
QBCore = exports['qb-core']:GetCoreObject()
end

local isBlackout, blackoutInProgress = false, false
local isBlackout, blackoutInProgress, setBlackoutTimeout = false, false, false

RegisterServerEvent('msk_blackout:notifyJobs')
AddEventHandler('msk_blackout:notifyJobs', function()
Expand Down Expand Up @@ -32,9 +32,11 @@ end)
RegisterServerEvent('msk_blackout:syncBlackout')
AddEventHandler('msk_blackout:syncBlackout', function(state)
logging('debug', 'syncBlackout', state)

if Config.useWeatherScript then
Config.weatherScript(state)
end

TriggerClientEvent('msk_blackout:setBlackout', -1, state)

if state then -- If Blackout is enabled
Expand All @@ -44,7 +46,7 @@ AddEventHandler('msk_blackout:syncBlackout', function(state)
local blackoutTimeout = MSK.AddTimeout(Config.Timeout * 60000, function()
blackoutInProgress = false
end)
elseif not state then -- If Blackout is disabled
else -- If Blackout is disabled
TriggerEvent('msk_blackout:powerOn')
end

Expand Down Expand Up @@ -72,7 +74,7 @@ AddEventHandler('msk_blackout:syncBlackout', function(state)
else
logging('error', ('Unsupported doorlock script: ^3%s^0'):format(Config.DoorlockScript))
end
elseif not state then -- If Blackout is disabled
else -- If Blackout is disabled
if Config.DoorlockScript:match('doors_creator') then
local doors = exports["doors_creator"]:getAllDoors()
for k, doorData in pairs(doors) do
Expand Down Expand Up @@ -114,15 +116,15 @@ MSK.Register('msk_blackout:getCops', function(source)
local xPlayers = ESX.GetExtendedPlayers()

for k, xPlayer in pairs(xPlayers) do
if MSK.Table_Contains(Config.Cops.jobs, xPlayer.job.name) then
if MSK.TableContains(Config.Cops.jobs, xPlayer.job.name) then
OnlineCops = OnlineCops + 1
end
end
elseif Config.Framework:match('QBCore') then
local Players = QBCore.Functions.GetQBPlayers()

for k, Player in pairs(Players) do
if MSK.Table_Contains(Config.Cops.jobs, Player.PlayerData.job.name) then
if MSK.TableContains(Config.Cops.jobs, Player.PlayerData.job.name) then
OnlineCops = OnlineCops + 1
end
end
Expand All @@ -139,16 +141,28 @@ if Config.Command.enable then
MSK.RegisterCommand(Config.Command.command, Config.Command.groups, function(source, args, raw)
if isBlackout then
TriggerEvent('msk_blackout:syncBlackout', false)
isBlackout = false
else
TriggerEvent('msk_blackout:syncBlackout', true)
isBlackout = true
end
end, true, false, {help = 'Toggle Blackout'})
end

AddEventHandler('msk_blackout:powerOn', function() isBlackout = false logging('debug', 'Toggled Blackout off') end)
AddEventHandler('msk_blackout:powerOff', function() isBlackout = true logging('debug', 'Toggled Blackout on') end)
AddEventHandler('msk_blackout:powerOn', function()
logging('debug', 'Toggled Blackout off')
isBlackout = false

MSK.DelTimeout(setBlackoutTimeout)
end)

AddEventHandler('msk_blackout:powerOff', function()
logging('debug', 'Toggled Blackout on')
isBlackout = true

setBlackoutTimeout = MSK.AddTimeout(Config.Blackout.duration * 60000, function()
isBlackout = false
TriggerEvent('msk_blackout:syncBlackout', false)
end)
end)

logging = function(code, ...)
if not Config.Debug then return end
Expand All @@ -161,7 +175,7 @@ GithubUpdater = function()
end

local CurrentVersion = GetCurrentVersion()
local resourceName = "[^2"..GetCurrentResourceName().."^0]"
local resourceName = "^0[^2"..GetCurrentResourceName().."^0]"

if Config.VersionChecker then
PerformHttpRequest('https://raw.githubusercontent.com/MSK-Scripts/msk_blackout/main/VERSION', function(Error, NewestVersion, Header)
Expand Down

0 comments on commit 8509ce0

Please sign in to comment.