mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
fix: nonsense Wait times
Tick time is ~15ms, so anything that needs to occur on-frame should use Wait(0)
This commit is contained in:
@@ -517,7 +517,7 @@ AddEventHandler("esx:tpm", function()
|
||||
break
|
||||
end
|
||||
|
||||
Wait(5)
|
||||
Wait(0)
|
||||
end
|
||||
TriggerEvent('chatMessage', "Successfully Teleported")
|
||||
else
|
||||
|
||||
@@ -7,7 +7,7 @@ ESX.Scaleform.ShowFreemodeMessage = function(title, msg, sec)
|
||||
EndScaleformMovieMethod()
|
||||
|
||||
while sec > 0 do
|
||||
Wait(1)
|
||||
Wait(0)
|
||||
sec = sec - 0.01
|
||||
|
||||
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255)
|
||||
@@ -38,7 +38,7 @@ ESX.Scaleform.ShowBreakingNews = function(title, msg, bottom, sec)
|
||||
EndScaleformMovieMethod()
|
||||
|
||||
while sec > 0 do
|
||||
Wait(1)
|
||||
Wait(0)
|
||||
sec = sec - 0.01
|
||||
|
||||
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255)
|
||||
@@ -61,7 +61,7 @@ ESX.Scaleform.ShowPopupWarning = function(title, msg, bottom, sec)
|
||||
EndScaleformMovieMethod()
|
||||
|
||||
while sec > 0 do
|
||||
Wait(1)
|
||||
Wait(0)
|
||||
sec = sec - 0.01
|
||||
|
||||
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255)
|
||||
@@ -78,7 +78,7 @@ ESX.Scaleform.ShowTrafficMovie = function(sec)
|
||||
EndScaleformMovieMethod()
|
||||
|
||||
while sec > 0 do
|
||||
Wait(1)
|
||||
Wait(0)
|
||||
sec = sec - 0.01
|
||||
|
||||
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255)
|
||||
|
||||
@@ -5,7 +5,7 @@ function ESX.Streaming.RequestModel(modelHash, cb)
|
||||
RequestModel(modelHash)
|
||||
|
||||
while not HasModelLoaded(modelHash) do
|
||||
Wait(4)
|
||||
Wait(0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ function ESX.Streaming.RequestStreamedTextureDict(textureDict, cb)
|
||||
RequestStreamedTextureDict(textureDict)
|
||||
|
||||
while not HasStreamedTextureDictLoaded(textureDict) do
|
||||
Wait(4)
|
||||
Wait(0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,7 +33,7 @@ function ESX.Streaming.RequestNamedPtfxAsset(assetName, cb)
|
||||
RequestNamedPtfxAsset(assetName)
|
||||
|
||||
while not HasNamedPtfxAssetLoaded(assetName) do
|
||||
Wait(4)
|
||||
Wait(0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,7 +47,7 @@ function ESX.Streaming.RequestAnimSet(animSet, cb)
|
||||
RequestAnimSet(animSet)
|
||||
|
||||
while not HasAnimSetLoaded(animSet) do
|
||||
Wait(4)
|
||||
Wait(0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,7 +61,7 @@ function ESX.Streaming.RequestAnimDict(animDict, cb)
|
||||
RequestAnimDict(animDict)
|
||||
|
||||
while not HasAnimDictLoaded(animDict) do
|
||||
Wait(4)
|
||||
Wait(0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -75,7 +75,7 @@ function ESX.Streaming.RequestWeaponAsset(weaponHash, cb)
|
||||
RequestWeaponAsset(weaponHash)
|
||||
|
||||
while not HasWeaponAssetLoaded(weaponHash) do
|
||||
Wait(4)
|
||||
Wait(0)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ if Config.UseDeferrals then
|
||||
saveIdentityToDatabase(xPlayer.identifier, currentIdentity)
|
||||
end
|
||||
|
||||
Wait(5)
|
||||
Wait(0)
|
||||
alreadyRegistered[xPlayer.identifier] = true
|
||||
TriggerClientEvent('esx_identity:alreadyRegistered', xPlayer.source)
|
||||
|
||||
@@ -142,7 +142,7 @@ elseif not Config.UseDeferrals then
|
||||
Wait(300)
|
||||
|
||||
while not ESX do
|
||||
Wait(10)
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
local xPlayers = ESX.GetExtendedPlayers()
|
||||
@@ -170,7 +170,7 @@ elseif not Config.UseDeferrals then
|
||||
saveIdentityToDatabase(xPlayer.identifier, currentIdentity)
|
||||
end
|
||||
|
||||
Wait(10)
|
||||
Wait(0)
|
||||
TriggerClientEvent('esx_identity:alreadyRegistered', xPlayer.source)
|
||||
|
||||
playerIdentity[xPlayer.identifier] = nil
|
||||
|
||||
@@ -83,7 +83,7 @@ end)
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(10)
|
||||
Wait(0)
|
||||
|
||||
if ESX.Table.SizeOf(OpenedMenus) > 0 then
|
||||
DisableControlAction(0, 1, true) -- LookLeftRight
|
||||
|
||||
@@ -312,7 +312,7 @@ function RemoveItemsAfterRPDeath()
|
||||
DoScreenFadeOut(800)
|
||||
|
||||
while not IsScreenFadedOut() do
|
||||
Wait(10)
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
ESX.TriggerServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function()
|
||||
|
||||
@@ -45,7 +45,7 @@ end)
|
||||
-- Activate menu when player is inside marker
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(10)
|
||||
Wait(0)
|
||||
local coords = GetEntityCoords(PlayerPedId())
|
||||
local canSleep = true
|
||||
isInATMMarker = false
|
||||
|
||||
@@ -135,7 +135,7 @@ end)
|
||||
-- Enter / Exit marker events & draw markers
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(1)
|
||||
Wait(0)
|
||||
local playerCoords, isInMarker, currentZone, letSleep = GetEntityCoords(PlayerPedId()), false, nil, true
|
||||
|
||||
for k,v in pairs(Config.Shops) do
|
||||
|
||||
@@ -263,7 +263,7 @@ end)
|
||||
-- Block UI
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(1)
|
||||
Wait(0)
|
||||
|
||||
if CurrentTest == 'theory' then
|
||||
local playerPed = PlayerPedId()
|
||||
@@ -360,7 +360,7 @@ end)
|
||||
-- Speed / Damage control
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(10)
|
||||
Wait(0)
|
||||
|
||||
if CurrentTest == 'drive' then
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ end
|
||||
|
||||
function GenerateWeedCoords()
|
||||
while true do
|
||||
Wait(1)
|
||||
Wait(0)
|
||||
|
||||
local weedCoordX, weedCoordY
|
||||
|
||||
|
||||
@@ -390,7 +390,7 @@ CreateThread(function()
|
||||
|
||||
TriggerEvent('esx_property:hasExitedMarker', LastGarage, LastPart, LastParking)
|
||||
end
|
||||
Wait(1)
|
||||
Wait(0)
|
||||
else Wait(500) end
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -60,7 +60,7 @@ AddEventHandler('esx_holdup:startTimer', function()
|
||||
end)
|
||||
CreateThread(function()
|
||||
while holdingUp do
|
||||
Wait(1)
|
||||
Wait(0)
|
||||
DrawTxt(0.66, 1.44, 1.0, 1.0, 0.4, _U('robbery_timer', timer), 255, 255, 255, 255)
|
||||
end
|
||||
end)
|
||||
@@ -80,7 +80,7 @@ end)
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(1)
|
||||
Wait(0)
|
||||
local playerPos, letSleep = GetEntityCoords(PlayerPedId()), true
|
||||
for k,v in pairs(Stores) do
|
||||
local distance = #(playerPos - v.position)
|
||||
|
||||
@@ -33,7 +33,7 @@ end)
|
||||
-- Activate menu when player is inside marker, and draw markers
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(1)
|
||||
Wait(0)
|
||||
|
||||
local coords = GetEntityCoords(PlayerPedId())
|
||||
isInMarker = false
|
||||
|
||||
@@ -302,7 +302,7 @@ end)
|
||||
-- Show top left hint
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(10)
|
||||
Wait(0)
|
||||
|
||||
if hintIsShowed then
|
||||
ESX.ShowHelpNotification(hintToDisplay)
|
||||
@@ -315,7 +315,7 @@ end)
|
||||
-- Display markers (only if on duty and the player's job ones)
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(1)
|
||||
Wait(0)
|
||||
local zones = {}
|
||||
|
||||
if ESX.PlayerData.job ~= nil then
|
||||
@@ -401,7 +401,7 @@ end)
|
||||
CreateThread(function()
|
||||
while true do
|
||||
|
||||
Wait(1)
|
||||
Wait(0)
|
||||
|
||||
if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name ~= 'unemployed' then
|
||||
local zones = nil
|
||||
|
||||
@@ -6,7 +6,7 @@ CreateThread(function()
|
||||
local timeNow = os.clock()
|
||||
|
||||
for playerId,data in pairs(playersWorking) do
|
||||
Wait(10)
|
||||
Wait(0)
|
||||
local xPlayer = ESX.GetPlayerFromId(playerId)
|
||||
|
||||
-- is player still online?
|
||||
|
||||
@@ -767,7 +767,7 @@ end)
|
||||
-- Pop NPC mission vehicle when inside area
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(10)
|
||||
Wait(0)
|
||||
|
||||
if NPCTargetTowableZone and not NPCHasSpawnedTowable then
|
||||
local coords = GetEntityCoords(PlayerPedId())
|
||||
@@ -838,7 +838,7 @@ end)
|
||||
-- Enter / Exit marker events
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(10)
|
||||
Wait(0)
|
||||
|
||||
if ESX.PlayerData.job and ESX.PlayerData.job.name == 'mechanic' then
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ function OpenCloakroomMenu()
|
||||
end, 'police')
|
||||
|
||||
while awaitService == nil do
|
||||
Wait(5)
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
-- if we couldn't enter service don't let the player get changed
|
||||
|
||||
@@ -328,7 +328,7 @@ ESX.RegisterServerCallback('esx_society:getOnlinePlayers', function(source, cb)
|
||||
onlinePlayers = {}
|
||||
return
|
||||
end
|
||||
while getOnlinePlayers do Wait(10) end -- Wait for the xPlayer loop to finish
|
||||
while getOnlinePlayers do Wait(0) end -- Wait for the xPlayer loop to finish
|
||||
cb(onlinePlayers)
|
||||
end)
|
||||
|
||||
|
||||
@@ -628,7 +628,7 @@ CreateThread(function()
|
||||
targetCoords = Config.JobLocations[GetRandomIntInRange(1, #Config.JobLocations)]
|
||||
local distance = #(playerCoords - targetCoords)
|
||||
while distance < Config.MinimumDistance do
|
||||
Wait(5)
|
||||
Wait(0)
|
||||
|
||||
targetCoords = Config.JobLocations[GetRandomIntInRange(1, #Config.JobLocations)]
|
||||
distance = #(playerCoords - targetCoords)
|
||||
|
||||
@@ -756,7 +756,7 @@ end)
|
||||
-- Enter / Exit marker events & Draw Markers
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(4)
|
||||
Wait(0)
|
||||
local playerCoords = GetEntityCoords(PlayerPedId())
|
||||
local isInMarker, letSleep, currentZone = false, true
|
||||
|
||||
@@ -796,7 +796,7 @@ end)
|
||||
-- Key controls
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(5)
|
||||
Wait(0)
|
||||
|
||||
if CurrentAction then
|
||||
ESX.ShowHelpNotification(CurrentActionMsg)
|
||||
|
||||
@@ -11,7 +11,7 @@ function GeneratePlate()
|
||||
local doBreak = false
|
||||
|
||||
while true do
|
||||
Wait(2)
|
||||
Wait(0)
|
||||
math.randomseed(GetGameTimer())
|
||||
if Config.PlateUseSpace then
|
||||
generatedPlate = string.upper(GetRandomLetter(Config.PlateLetters) .. ' ' .. GetRandomNumber(Config.PlateNumbers))
|
||||
|
||||
@@ -43,7 +43,7 @@ end)
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(1)
|
||||
Wait(0)
|
||||
|
||||
if IsControlJustPressed(1, Keys['H']) and IsControlPressed(1, Keys['LEFTSHIFT']) then
|
||||
voice.current = (voice.current + 1) % 3
|
||||
|
||||
Reference in New Issue
Block a user