Tweak: MechanicJob - Optimisations

This commit is contained in:
Mycroft
2022-03-24 20:49:52 +00:00
parent f947029eab
commit 7329ac43bd
+13 -15
View File
@@ -771,9 +771,10 @@ end)
-- Pop NPC mission vehicle when inside area
CreateThread(function()
while true do
Wait(0)
local Sleep = 1500
if NPCTargetTowableZone and not NPCHasSpawnedTowable then
Sleep = 0
local coords = GetEntityCoords(PlayerPedId())
local zone = Config.Zones[NPCTargetTowableZone]
@@ -789,14 +790,17 @@ CreateThread(function()
end
if NPCTargetTowableZone and NPCHasSpawnedTowable and not NPCHasBeenNextToTowable then
Sleep = 500
local coords = GetEntityCoords(PlayerPedId())
local zone = Config.Zones[NPCTargetTowableZone]
if #(coords - zone.Pos) < Config.NPCNextToDistance then
Sleep = 0
ESX.ShowNotification(_U('please_tow'))
NPCHasBeenNextToTowable = true
end
end
Wait(Sleep)
end
end)
@@ -818,31 +822,28 @@ end)
-- Display markers
CreateThread(function()
while true do
Wait(0)
local Sleep = 2000
if ESX.PlayerData.job and ESX.PlayerData.job.name == 'mechanic' then
Sleep = 500
local coords, letSleep = GetEntityCoords(PlayerPedId()), true
for k,v in pairs(Config.Zones) do
if v.Type ~= -1 and #(coords - v.Pos) < Config.DrawDistance then
Sleep = 0
DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, true, 2, false, nil, nil, false)
letSleep = false
end
end
if letSleep then
Wait(500)
end
else
Wait(500)
end
Wait(Sleep)
end
end)
-- Enter / Exit marker events
CreateThread(function()
while true do
Wait(0)
local Sleep = 500
if ESX.PlayerData.job and ESX.PlayerData.job.name == 'mechanic' then
@@ -852,6 +853,7 @@ CreateThread(function()
for k,v in pairs(Config.Zones) do
if(#(coords - v.Pos) < v.Size.x) then
Sleep = 0
isInMarker = true
currentZone = k
end
@@ -867,8 +869,8 @@ CreateThread(function()
HasAlreadyEnteredMarker = false
TriggerEvent('esx_mechanicjob:hasExitedMarker', LastZone)
end
end
Wait(Sleep)
end
end)
@@ -917,10 +919,8 @@ end)
-- Key Controls
CreateThread(function()
while true do
while CurrentAction do
Wait(0)
if CurrentAction then
ESX.ShowHelpNotification(CurrentActionMsg)
if IsControlJustReleased(0, 38) and ESX.PlayerData.job and ESX.PlayerData.job.name == 'mechanic' then
@@ -983,8 +983,6 @@ CreateThread(function()
end
end
end
end
end)
AddEventHandler('esx:onPlayerDeath', function(data) isDead = true end)