local Keys = { ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 } local PlayerData = {} local GUI = {} local HasAlreadyEnteredMarker = false local LastPart = nil local LastPartNum = nil local CurrentAction = nil local CurrentActionMsg = '' local CurrentActionData = {} ESX = nil GUI.Time = 0 Citizen.CreateThread(function() while ESX == nil do TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) Citizen.Wait(0) end end) RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(xPlayer) PlayerData = xPlayer end) RegisterNetEvent('esx:setJob') AddEventHandler('esx:setJob', function(job) PlayerData.job = job end) AddEventHandler('esx_hacking:hasEnteredMarker', function(part, partNum) if part == 'Hacking' then CurrentAction = 'hack' CurrentActionMsg = _U('open_cloackroom') CurrentActionData = {} end end) AddEventHandler('esx_hacking:hasExitedMarker', function(part, partNum) ESX.UI.Menu.CloseAll() CurrentAction = nil end) AddEventHandler('esx_hacking:hasExitedMarker', function(part, partNum) ESX.UI.Menu.CloseAll() CurrentAction = nil end) -- Create blips Citizen.CreateThread(function() for k,v in pairs(Config.Hacks) do local blip = AddBlipForCoord(v.Blip.Pos.x, v.Blip.Pos.y, v.Blip.Pos.z) SetBlipSprite (blip, v.Blip.Sprite) SetBlipDisplay(blip, v.Blip.Display) SetBlipScale (blip, v.Blip.Scale) SetBlipColour (blip, v.Blip.Colour) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName("STRING") AddTextComponentString(_U('map_blip')) EndTextCommandSetBlipName(blip) end end) -- Display markers Citizen.CreateThread(function() while true do Wait(0) if PlayerData.job ~= nil and PlayerData.job.name == 'hacker' then local playerPed = GetPlayerPed(-1) local coords = GetEntityCoords(playerPed) for k,v in pairs(Config.Hacks) do for i=1, #v.Hacking, 1 do if GetDistanceBetweenCoords(coords, v.Hacking[i].x, v.Hacking[i].y, v.Hacking[i].z, true) < Config.DrawDistance then DrawMarker(Config.MarkerType, v.Hacking[i].x, v.Hacking[i].y, v.Hacking[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) end end end --[[ for k,v in pairs(Config.Hacks) do for i=1, #v.Cloakrooms, 1 do if GetDistanceBetweenCoords(coords, v.Cloakrooms[i].x, v.Cloakrooms[i].y, v.Cloakrooms[i].z, true) < Config.DrawDistance then DrawMarker(Config.MarkerType, v.Cloakrooms[i].x, v.Cloakrooms[i].y, v.Cloakrooms[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) end end for i=1, #v.Armories, 1 do if GetDistanceBetweenCoords(coords, v.Armories[i].x, v.Armories[i].y, v.Armories[i].z, true) < Config.DrawDistance then DrawMarker(Config.MarkerType, v.Armories[i].x, v.Armories[i].y, v.Armories[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) end end for i=1, #v.Vehicles, 1 do if GetDistanceBetweenCoords(coords, v.Vehicles[i].Spawner.x, v.Vehicles[i].Spawner.y, v.Vehicles[i].Spawner.z, true) < Config.DrawDistance then DrawMarker(Config.MarkerType, v.Vehicles[i].Spawner.x, v.Vehicles[i].Spawner.y, v.Vehicles[i].Spawner.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) end end for i=1, #v.VehicleDeleters, 1 do if GetDistanceBetweenCoords(coords, v.VehicleDeleters[i].x, v.VehicleDeleters[i].y, v.VehicleDeleters[i].z, true) < Config.DrawDistance then DrawMarker(Config.MarkerType, v.VehicleDeleters[i].x, v.VehicleDeleters[i].y, v.VehicleDeleters[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) end end if Config.EnablePlayerManagement and PlayerData.job ~= nil and PlayerData.job.name == 'police' and PlayerData.job.grade_name == 'boss' then for i=1, #v.BossActions, 1 do if not v.BossActions[i].disabled and GetDistanceBetweenCoords(coords, v.BossActions[i].x, v.BossActions[i].y, v.BossActions[i].z, true) < Config.DrawDistance then DrawMarker(Config.MarkerType, v.BossActions[i].x, v.BossActions[i].y, v.BossActions[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) end end end end ]]-- end end end) -- Enter / Exit marker events Citizen.CreateThread(function() while true do Wait(0) print(tostring(PlayerData.job.name)) if PlayerData.job ~= nil and PlayerData.job.name == 'hacker' then local playerPed = GetPlayerPed(-1) local coords = GetEntityCoords(playerPed) local isInMarker = false local currentPart = nil local currentPartNum = nil for k,v in pairs(Config.Hacks) do for i=1, #v.Hacking, 1 do if GetDistanceBetweenCoords(coords, v.Hacking[i].x, v.Hacking[i].y, v.Hacking[i].z, true) < Config.MarkerSize.x then isInMarker = true currentPart = 'Cloakroom' currentPartNum = i end end end local hasExited = false if isInMarker and not HasAlreadyEnteredMarker or (isInMarker and (LastPart ~= currentPart or LastPartNum ~= currentPartNum) ) then if (LastPart ~= nil and LastPartNum ~= nil) and (LastPart ~= currentPart or LastPartNum ~= currentPartNum) then TriggerEvent('esx_hacking:hasExitedMarker', LastPart, LastPartNum) hasExited = true end HasAlreadyEnteredMarker = true LastPart = currentPart LastPartNum = currentPartNum TriggerEvent('esx_hacking:hasEnteredMarker', currentPart, currentPartNum) end if not hasExited and not isInMarker and HasAlreadyEnteredMarker then HasAlreadyEnteredMarker = false TriggerEvent('esx_hacking:hasExitedMarker', LastPart, LastPartNum) end end end end) function HackingCallback(success, timeremaining) if success then TriggerEvent('esx_hacking:successHack') else TriggerEvent('esx:showNotification', xPlayer.source, 'Fail') end end function OpenMinigameMenu() TriggerEvent("mhacking:show") TriggerEvent("mhacking:start",7,35,HackingCallback) print('Debug #3') end -- Key Controls Citizen.CreateThread(function() while true do Citizen.Wait(0) if CurrentAction ~= nil then SetTextComponentFormat('STRING') AddTextComponentString(CurrentActionMsg) DisplayHelpTextFromStringLabel(0, 0, 1, -1) if IsControlPressed(0, Keys['E']) and PlayerData.job ~= nil and PlayerData.job.name == 'hacker' and (GetGameTimer() - GUI.Time) > 150 then print('Debug #2') if CurrentAction == 'hack' then OpenMinigameMenu() end CurrentAction = nil GUI.Time = GetGameTimer() end end end end) -- your code goes here