Skip to content

Commit

Permalink
Update v1.4
Browse files Browse the repository at this point in the history
* Added needed Items
* Added Skillbar for Trafostations
  • Loading branch information
Musiker15 committed Mar 9, 2023
1 parent d4b74bc commit 9981539
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 46 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3
1.4
129 changes: 87 additions & 42 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,43 +58,51 @@ CreateThread(function()

if IsControlJustPressed(0, Config.Hotkey) and (not Config.blacklistedJobs.enable or not MSK.Table_Contains(Config.blacklistedJobs.jobs, playerJob)) then
local OnlineCops = 0

if Config.Cops.enable then
OnlineCops = MSK.TriggerCallback('msk_blackout:getCops')
end

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
Wait(0)
local hasItem = MSK.HasItem(Config.Items['startDoor'])

if hasItem and hasItem.count > 0 then
if Config.SkillCheck.animation.enable then
RequestAnimDict(Config.SkillCheck.animation.dict)
while not HasAnimDictLoaded(Config.SkillCheck.animation.dict) do
Wait(0)
end
TaskPlayAnim(playerPed, Config.SkillCheck.animation.dict, Config.SkillCheck.animation.anim, 8.0, 1.0, -1, 49, 0, false, false, false)
end
TaskPlayAnim(playerPed, Config.SkillCheck.animation.dict, Config.SkillCheck.animation.anim, 8.0, 1.0, -1, 49, 0, false, false, false)
end

local success = false
if Config.Skillbar:match('oxlib') then
success = lib.skillCheck({Config.SkillCheck.difficulty['1'], Config.SkillCheck.difficulty['2'], {areaSize = 60, speedMultiplier = 2}, Config.SkillCheck.difficulty['3']}, Config.SkillCheck.inputs)
elseif Config.Skillbar:match('qbcore') then
local Skillbar = exports['qb-skillbar']:GetSkillbarObject()
Skillbar.Start({
duration = math.random(1000, 5000), -- how long the skillbar runs for
pos = math.random(10, 30), -- how far to the right the static box is
width = math.random(10, 20), -- how wide the static box is
}, function()
success = true
end, function()
success = false
end)
end
local success = false
if Config.Skillbar:match('oxlib') then
success = lib.skillCheck({Config.SkillCheck.difficulty['1'], Config.SkillCheck.difficulty['2'], {areaSize = 60, speedMultiplier = 2}, Config.SkillCheck.difficulty['3']}, Config.SkillCheck.inputs)
elseif Config.Skillbar:match('qbcore') then
local Skillbar = exports['qb-skillbar']:GetSkillbarObject()
Skillbar.Start({
duration = math.random(1000, 5000), -- how long the skillbar runs for
pos = math.random(10, 30), -- how far to the right the static box is
width = math.random(10, 20), -- how wide the static box is
}, function()
success = true
end, function()
success = false
end)
end

if Config.SkillCheck.animation.enable then
RemoveAnimDict(Config.SkillCheck.animation.dict)
ClearPedTasks(playerPed)
end
if Config.SkillCheck.animation.enable then
RemoveAnimDict(Config.SkillCheck.animation.dict)
ClearPedTasks(playerPed)
end

if success then
startedBlackout = true
blackoutTeleport()
if success then
TriggerServerEvent('msk_blackout:removeItem', hasItem.name)
startedBlackout = true
blackoutTeleport()
end
else
Config.Notification(nil, Translation[Config.Locale]['no_items']:format(hasItem.label))
end
else
Config.Notification(nil, Translation[Config.Locale]['no_online_cops'])
Expand Down Expand Up @@ -156,8 +164,15 @@ CreateThread(function()

if dist <= 1.5 then
if IsControlJustPressed(0, Config.Hotkey) then
showHackLaptopHelp = true
exports["datacrack"]:Start(4)
local hasItem = MSK.HasItem(Config.Items['hackLaptop'])

if hasItem and hasItem.count > 0 then
showHackLaptopHelp = true
exports["datacrack"]:Start(4)
else
teleportOutOfBuilding('return')
Config.Notification(nil, Translation[Config.Locale]['no_items']:format(hasItem.label))
end
end
end
end
Expand Down Expand Up @@ -192,20 +207,47 @@ CreateThread(function()
MSK.HelpNotification(Translation[Config.Locale]['sabotage_trafo_loc'])

if IsControlJustPressed(0, Config.Hotkey) then
startedSabotage = true
local hasItem = MSK.HasItem(Config.Items['trafos'])

if Config.SabotageTrafo.animation.enable then
RequestAnimDict(Config.SabotageTrafo.animation.dict)
while not HasAnimDictLoaded(Config.SabotageTrafo.animation.dict) do
Wait(0)
if hasItem and hasItem.count > 0 then
startedSabotage = true

if Config.SabotageTrafo.animation.enable then
RequestAnimDict(Config.SabotageTrafo.animation.dict)
while not HasAnimDictLoaded(Config.SabotageTrafo.animation.dict) do
Wait(0)
end
TaskPlayAnim(playerPed, Config.SabotageTrafo.animation.dict, Config.SabotageTrafo.animation.anim, 8.0, 1.0, -1, 49, 0, false, false, false)
end

local success = false
if Config.Skillbar:match('oxlib') then
success = lib.skillCheck({Config.SkillCheck.difficulty['1'], Config.SkillCheck.difficulty['2'], {areaSize = 60, speedMultiplier = 2}, Config.SkillCheck.difficulty['3']}, Config.SkillCheck.inputs)
elseif Config.Skillbar:match('qbcore') then
local Skillbar = exports['qb-skillbar']:GetSkillbarObject()
Skillbar.Start({
duration = math.random(1000, 5000), -- how long the skillbar runs for
pos = math.random(10, 30), -- how far to the right the static box is
width = math.random(10, 20), -- how wide the static box is
}, function()
success = true
end, function()
success = false
end)
end

if Config.SabotageTrafo.animation.enable then
RemoveAnimDict(Config.SabotageTrafo.animation.dict)
ClearPedTasks(playerPed)
end
TaskPlayAnim(playerPed, Config.SabotageTrafo.animation.dict, Config.SabotageTrafo.animation.anim, 8.0, 1.0, -1, 49, 0, false, false, false)
Wait(Config.SabotageTrafo.animation.duration * 1000)
RemoveAnimDict(Config.SabotageTrafo.animation.dict)
ClearPedTasks(playerPed)

removeBlip(v.coords)
table.remove(SabotageLocations, k)
if success then
TriggerServerEvent('msk_blackout:removeItem', hasItem.name)
removeBlip(v.coords)
table.remove(SabotageLocations, k)
end
else
Config.Notification(nil, Translation[Config.Locale]['no_items']:format(hasItem.label))
end
end
end
Expand All @@ -227,14 +269,17 @@ AddEventHandler("datacrack", function(success)
hackedLaptop = success

if success then
TriggerServerEvent('msk_blackout:removeItem', Config.Items['hackLaptop'])
Config.Notification(nil, Translation[Config.Locale]['success_hack_Laptop'])
else
showHackLaptopHelp = false
end
end)

teleportOutOfBuilding = function()
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

Config.Notification(nil, Translation[Config.Locale]['sabotage_trafostation'])
showSabotageBlips()
addSabotagePoints()
Expand Down
11 changes: 9 additions & 2 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ 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.removeItem = true -- Remove the Item after use

Config.Items = { -- Add those items to your database or inventory
['startDoor'] = 'lockpick',
['hackLaptop'] = 'usb_stick',
['trafos'] = 'hammerwirecutter'
}
----------------------------------------------------------------
Config.Blackout = {
generalLights = true, -- Set to true turns off all artificial light sources in the map
vehicleLights = true, -- Set to false ignores Vehicles
Expand All @@ -33,7 +41,7 @@ Config.weatherScript = function(state) -- This is a Server Event
end
----------------------------------------------------------------
Config.Cops = {
enable = true,
enable = false,
jobs = {'police', 'fib', 'sheriff'},
amount = 2 -- Minimum amount of Online Players with Police Job
}
Expand Down Expand Up @@ -83,7 +91,6 @@ Config.SabotageTrafo = {
enable = true, -- Set false to disable animation while sabotage trafostation
dict = 'mp_arresting',
anim = 'a_uncuff',
duration = 10 -- in seconds // How long the sabotage will take
},
settings = {
{coords = vec3(2831.52, 1496.69, 24.73), distance = 10.0, blip = {enable = true, label = 'Sabotage', id = 270, color = 1, scale = 0.5}, marker = {enable = true, type = 0, size = {a = 1.0, b = 1.0, c = 1.0}, color = {a = 255, b = 0, c = 0}}},
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.3'
version '1.4'

lua54 'yes'

Expand Down
14 changes: 14 additions & 0 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ AddEventHandler('msk_blackout:syncBlackout', function(state)
end
end)

RegisterServerEvent('msk_blackout:removeItem')
AddEventHandler('msk_blackout:removeItem', function(item)
if not Config.removeItem then return end
local src = source

if Config.Framework:match('ESX') then
local xPlayer = ESX.GetPlayerFromId(src)
xPlayer.removeInventoryItem(item, 1)
elseif Config.Framework:match('QBCore') then
local Player = QBCore.Functions.GetPlayer(src)
Player.Functions.RemoveItem(item, 1)
end
end)

MSK.RegisterCallback('msk_blackout:getCops', function(source, cb)
local OnlineCops = 0

Expand Down
4 changes: 4 additions & 0 deletions translation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Translation = {
['sabotage_trafostation'] = 'Sabotiere die Trafostationen die auf der Karte markiert sind.',
['sabotage_trafo_loc'] = 'Drücke ~g~E~s~ um den Trafo zu sabotieren.',
['successfully_done'] = 'Du hast den Staatsweiten Blackout ausgelöst.',

['no_items'] = 'Du hast nicht das passende Item dabei. Du benötigst einen %s.',
},
['en'] = {
['open_blackout'] = 'Press ~g~E~s~ to start the Blackout',
Expand All @@ -24,5 +26,7 @@ Translation = {
['sabotage_trafostation'] = 'Sabotage the transformer stations marked on the map.',
['sabotage_trafo_loc'] = 'Press ~g~E~s~ to sabotage the transformer.',
['successfully_done'] = 'You caused the statewide blackout.',

['no_items'] = 'You don\'t have the right item with you. You need a %s.',
},
}

0 comments on commit 9981539

Please sign in to comment.