diff --git a/client.lua b/client.lua index 2d84079..94cec0f 100644 --- a/client.lua +++ b/client.lua @@ -15,6 +15,8 @@ local KeepSelfInDb = true local FocusTarget local FocusTargetPos local FreeFocus = false +local MessageRate = 70 +local MessageInterval = true local showEntityHandles = false local SpoonerPrompts, ClearTasksPrompt, DetachPrompt @@ -324,29 +326,21 @@ function GetInView(x1, y1, z1, pitch, roll, yaw) end function GetModelName(model) - for _, name in ipairs(Peds) do - if model == GetHashKey(name) then - return name - end - end + if PedsHashLookup[model] then + return PedsHashLookup[model] + end - for _, name in ipairs(Vehicles) do - if model == GetHashKey(name) then - return name - end - end + if VehiclesHashLookup[model] then + return VehiclesHashLookup[model] + end - for _, name in ipairs(Objects) do - if model == GetHashKey(name) then - return name - end - end + if ObjectsHashLookup[model] then + return ObjectsHashLookup[model] + end - for _, name in ipairs(Pickups) do - if model == GetHashKey(name) then - return name - end - end + if PickupsHashLookup[model] then + return PickupsHashLookup[model] + end return tostring(model) end @@ -2775,32 +2769,38 @@ function MainSpoonerUpdates() elseif FocusTarget and not FreeFocus then entity = FocusTarget end - - SendNUIMessage({ - type = 'updateSpoonerHud', - entity = entity, - netId = NetworkGetEntityIsNetworked(entity) and ObjToNet(entity), - entityType = GetSpoonerEntityType(entity), - modelName = GetModelName(GetSpoonerEntityModel(entity)), - attachedEntity = AttachedEntity, - speed = string.format('%.2f', Speed), - currentSpawn = CurrentSpawn and CurrentSpawn.modelName, - rotateMode = RotateMode, - adjustMode = AdjustMode, - speedMode = SpeedMode, - placeOnGround = PlaceOnGround, - adjustSpeed = AdjustSpeed, - rotateSpeed = RotateSpeed, - cursorX = string.format('%.2f', spawnPos.x), - cursorY = string.format('%.2f', spawnPos.y), - cursorZ = string.format('%.2f', spawnPos.z), - camX = string.format('%.2f', x2), - camY = string.format('%.2f', y2), - camZ = string.format('%.2f', z2), - camHeading = string.format('%.2f', yaw2), - focusTarget = FocusTarget, - freeFocus = FreeFocus - }) + if MessageInterval then + MessageInterval = false + CreateThread(function() + Wait(MessageRate) + MessageInterval = true + end) + SendNUIMessage({ + type = 'updateSpoonerHud', + entity = entity, + netId = NetworkGetEntityIsNetworked(entity) and ObjToNet(entity), + entityType = GetSpoonerEntityType(entity), + modelName = GetModelName(GetSpoonerEntityModel(entity)), + attachedEntity = AttachedEntity, + speed = string.format('%.2f', Speed), + currentSpawn = CurrentSpawn and CurrentSpawn.modelName, + rotateMode = RotateMode, + adjustMode = AdjustMode, + speedMode = SpeedMode, + placeOnGround = PlaceOnGround, + adjustSpeed = AdjustSpeed, + rotateSpeed = RotateSpeed, + cursorX = string.format('%.2f', spawnPos.x), + cursorY = string.format('%.2f', spawnPos.y), + cursorZ = string.format('%.2f', spawnPos.z), + camX = string.format('%.2f', x2), + camY = string.format('%.2f', y2), + camZ = string.format('%.2f', z2), + camHeading = string.format('%.2f', yaw2), + focusTarget = FocusTarget, + freeFocus = FreeFocus + }) + end if CheckControls(IsDisabledControlPressed, 0, Config.IncreaseSpeedControl) then if SpeedMode == 0 then diff --git a/data/gta5/objects.lua b/data/gta5/objects.lua index 625d88d..fc3e637 100644 --- a/data/gta5/objects.lua +++ b/data/gta5/objects.lua @@ -18503,3 +18503,6 @@ Objects = { "xs3_prop_int_xmas_tree_01", "zprop_bin_01a_old", } + +ObjectsHashLookup = {} +for _, name in ipairs(Objects) do ObjectsHashLookup[GetHashKey(name)] = name; end diff --git a/data/gta5/peds.lua b/data/gta5/peds.lua index c4f634b..7264b74 100644 --- a/data/gta5/peds.lua +++ b/data/gta5/peds.lua @@ -934,3 +934,6 @@ Peds = { "U_M_Y_Ushi", "U_M_Y_Zombie_01", } + +PedsHashLookup = {} +for _, name in ipairs(Peds) do PedsHashLookup[GetHashKey(name)] = name; end diff --git a/data/gta5/pickups.lua b/data/gta5/pickups.lua index b19e409..cd34774 100644 --- a/data/gta5/pickups.lua +++ b/data/gta5/pickups.lua @@ -1,2 +1,5 @@ Pickups = { } + +PickupsHashLookup = {} +for _, name in ipairs(Pickups) do PickupsHashLookup[GetHashKey(name)] = name; end diff --git a/data/gta5/vehicles.lua b/data/gta5/vehicles.lua index bbd4f05..8c8140c 100644 --- a/data/gta5/vehicles.lua +++ b/data/gta5/vehicles.lua @@ -758,3 +758,6 @@ Vehicles = { "zr3803", "Ztype", } + +VehiclesHashLookup = {} +for _, name in ipairs(Vehicles) do VehiclesHashLookup[GetHashKey(name)] = name; end diff --git a/data/rdr3/objects.lua b/data/rdr3/objects.lua index f73a3b3..f7b9fc1 100644 --- a/data/rdr3/objects.lua +++ b/data/rdr3/objects.lua @@ -16948,3 +16948,6 @@ Objects = { "yarrow03_p", "yarrow04_p", } + +ObjectsHashLookup = {} +for _, name in ipairs(Objects) do ObjectsHashLookup[GetHashKey(name)] = name; end diff --git a/data/rdr3/peds.lua b/data/rdr3/peds.lua index 8b7d2e8..3afa7a9 100644 --- a/data/rdr3/peds.lua +++ b/data/rdr3/peds.lua @@ -1982,3 +1982,6 @@ Peds = { "western_saddle_03", "western_saddle_04", } + +PedsHashLookup = {} +for _, name in ipairs(Peds) do PedsHashLookup[GetHashKey(name)] = name; end diff --git a/data/rdr3/pickups.lua b/data/rdr3/pickups.lua index 1c37ccd..cf2ea0a 100644 --- a/data/rdr3/pickups.lua +++ b/data/rdr3/pickups.lua @@ -147,3 +147,6 @@ Pickups = { "PICKUP_WEAPON_THROWN_TOMAHAWK_IMPROVED", "PICKUP_WEAPON_THROWN_TOMAHAWK_MP", } + +PickupsHashLookup = {} +for _, name in ipairs(Pickups) do PickupsHashLookup[GetHashKey(name)] = name; end diff --git a/data/rdr3/vehicles.lua b/data/rdr3/vehicles.lua index 4f82de2..fc0d2d2 100644 --- a/data/rdr3/vehicles.lua +++ b/data/rdr3/vehicles.lua @@ -115,3 +115,6 @@ Vehicles = { "wintercoalcar", "winterSteamer", } + +VehiclesHashLookup = {} +for _, name in ipairs(Vehicles) do VehiclesHashLookup[GetHashKey(name)] = name; end