diff --git a/VERSION b/VERSION index a58941b..840ca8c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3 \ No newline at end of file +1.4 \ No newline at end of file diff --git a/client.lua b/client.lua index 67684e3..fd2ee2f 100644 --- a/client.lua +++ b/client.lua @@ -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']) @@ -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 @@ -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 @@ -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() diff --git a/config.lua b/config.lua index f2f857f..6d65d09 100644 --- a/config.lua +++ b/config.lua @@ -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 @@ -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 } @@ -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}}}, diff --git a/fxmanifest.lua b/fxmanifest.lua index 8cc635a..4a44760 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -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' diff --git a/server.lua b/server.lua index 9113be8..7e14b7d 100644 --- a/server.lua +++ b/server.lua @@ -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 diff --git a/translation.lua b/translation.lua index 19caeef..5d3950c 100644 --- a/translation.lua +++ b/translation.lua @@ -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', @@ -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.', }, } \ No newline at end of file