Skip to content

Commit

Permalink
Update v1.6
Browse files Browse the repository at this point in the history
* Fixed serious error
* Added Admin Command
  • Loading branch information
Musiker15 committed Mar 12, 2023
1 parent 172e4dd commit 1fb23df
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 16 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.1
1.6
34 changes: 20 additions & 14 deletions client.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
if Config.Framework:match('ESX') then -- ESX Framework
ESX = exports["es_extended"]:getSharedObject()

RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
ESX.GetPlayerData().job = job
end)
elseif Config.Framework:match('QBCore') then -- QBCore Framework
QBCore = exports['qb-core']:GetCoreObject()
end
Expand Down Expand Up @@ -170,7 +175,7 @@ CreateThread(function()
showHackLaptopHelp = true
exports["datacrack"]:Start(4)
else
teleportOutOfBuilding('return')
teleportOutOfBuilding(true)
sendJobBlipNotify(true)
Config.Notification(nil, Translation[Config.Locale]['no_items']:format(hasItem.label))
end
Expand Down Expand Up @@ -279,7 +284,7 @@ end)

teleportOutOfBuilding = function(stop)
SetEntityCoords(PlayerPedId(), Config.startPoint.coords.x, Config.startPoint.coords.y, Config.startPoint.coords.z, false, false, false, true)
if stop == 'return' then return stopBlackoutTask() end
if stop then return stopBlackoutTask() end

Config.Notification(nil, Translation[Config.Locale]['sabotage_trafostation'])
showSabotageBlips()
Expand Down Expand Up @@ -346,34 +351,29 @@ stopBlackoutTask = function(success)
end
end

stopBlackout = function()
TriggerServerEvent('msk_blackout:syncBlackout', false)
end

RegisterNetEvent('msk_blackout:setBlackout')
AddEventHandler('msk_blackout:setBlackout', function(state)
setBlackout = state

if state then
TriggerEvent('msk_blackout:powerOff')
TriggerServerEvent('msk_blackout:powerOff')

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

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

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

RegisterNetEvent('msk_blackout:sendJobBlipNotify')
AddEventHandler('msk_blackout:sendJobBlipNotify', function()
sendJobBlipNotify()
Expand Down Expand Up @@ -424,4 +424,10 @@ logging = function(code, ...)
local script = "[^2"..GetCurrentResourceName().."^0]"
MSK.logging(script, code, ...)
end
end
end

AddEventHandler('onResourceStop', function(resource)
if GetCurrentResourceName() == resource then
MSK.DelTimeout(addTimeout)
end
end)
6 changes: 6 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Config.Hotkey = 38 -- deafult: 38 = E
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.Command = {
enable = true, -- Set to false if you don't want to use the Commands
groups = {'superadmin', 'admin', 'god'},
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
Expand Down
2 changes: 1 addition & 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.5.1'
version '1.6'

lua54 'yes'

Expand Down
24 changes: 24 additions & 0 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ elseif Config.Framework:match('QBCore') then -- QBCore Framework
QBCore = exports['qb-core']:GetCoreObject()
end

local isBlackout = false

RegisterServerEvent('msk_blackout:notifyJobs')
AddEventHandler('msk_blackout:notifyJobs', function()
if not Config.notifyJobs.enable then return end
Expand Down Expand Up @@ -43,11 +45,18 @@ 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
TriggerEvent('msk_blackout:powerOff')
elseif not state then -- If Blackout is disabled
TriggerEvent('msk_blackout:powerOn')
end

if not Config.useDoorlock then return end
if not Config.DoorlockScript then return end
if not (GetResourceState(Config.DoorlockScript) == "started") then
Expand Down Expand Up @@ -135,6 +144,21 @@ MSK.RegisterCallback('msk_blackout:getCops', function(source, cb)
cb(OnlineCops)
end)

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)

logging = function(code, ...)
if Config.Debug then
local script = "[^2"..GetCurrentResourceName().."^0]"
Expand Down

0 comments on commit 1fb23df

Please sign in to comment.