Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions client/weather.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ AddStateBagChangeHandler('blackOut', 'global', function(_, _, value)
SetArtificialLightsStateAffectsVehicles(false)
end)

AddStateBagChangeHandler('playerBlackOut', ('player:%s'):format(cache.serverId), function(_, _, value)
if type(value) == 'boolean' then
SetArtificialLightsState(value)
end

SetArtificialLightsStateAffectsVehicles(false)
end)

CreateThread(function ()
while not NetworkIsSessionStarted() do -- Possible fix for slow clients
Wait(100)
Expand All @@ -94,6 +102,7 @@ CreateThread(function ()
setWeather(true)

playerState.syncWeather = true
playerState.playerBlackOut = false
playerState.playerWeather = 'EXTRASUNNY'

-- set blackout to the same state as server has
Expand Down
17 changes: 13 additions & 4 deletions server/weather.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,19 @@ lib.addCommand('weather', {
end)

lib.addCommand('blackout', {
help = 'Enable or disable the power blackout',
restricted = 'group.admin',
}, function()
GlobalState.blackOut = not GlobalState.blackOut
help = 'Toggle server wide or player only blackout',
restricted = 'group.admin',
params = {
{ name = 'target', type = 'playerId', help = 'Target player\'s server id', optional = true },
}
}, function(source, args)
if not args.target then
GlobalState.blackOut = not GlobalState.blackOut
else
local playerState = Player(args.target)
if not playerState then return end
playerState.state:set('playerBlackOut', not playerState.state?.playerBlackOut, true)
end
end)

-- Scheduled restart --
Expand Down
Loading