Skip to content

Commit deacb09

Browse files
Add files via upload
1 parent 9912dbf commit deacb09

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

A_Swing_Prediction.lua

+18-17
Original file line numberDiff line numberDiff line change
@@ -567,22 +567,24 @@ local function PropUpdate()
567567
local pWeapon = lastswingtracedata[1]
568568
local spherePos = lastswingtracedata[2]
569569
local closestPoint = lastswingtracedata[3]
570-
local Angle = Math.PositionAngles(spherePos, closestPoint)
570+
if spherePos and closestPoint then
571+
local Angle = Math.PositionAngles(spherePos, closestPoint)
571572

572-
-- Adjust player position and view angles for swing trace
573-
pLocal:SetPropVector(spherePos, "tfnonlocaldata", "m_vecOrigin")
574-
pLocal:SetPropVector(Vector3(Angle.x, Angle.y, Angle.z), "tfnonlocaldata", "m_angEyeAngles[0]")
573+
-- Adjust player position and view angles for swing trace
574+
pLocal:SetPropVector(spherePos, "tfnonlocaldata", "m_vecOrigin")
575+
pLocal:SetPropVector(Vector3(Angle.x, Angle.y, Angle.z), "tfnonlocaldata", "m_angEyeAngles[0]")
575576

576-
-- Perform the swing trace
577-
local SwingTrace = pLocal.DoSwingTrace(pWeapon)
578-
swingresult = SwingTrace
577+
-- Perform the swing trace
578+
local SwingTrace = pLocal.DoSwingTrace(pWeapon)
579+
swingresult = SwingTrace
579580

580-
-- Reset the player's original position and view angles
581-
pLocal:SetPropVector(OriginalPosition, "tfnonlocaldata", "m_vecOrigin")
582-
pLocal:SetPropVector(OriginalAngles, "tfnonlocaldata", "m_angEyeAngles[0]")
581+
-- Reset the player's original position and view angles
582+
pLocal:SetPropVector(OriginalPosition, "tfnonlocaldata", "m_vecOrigin")
583+
pLocal:SetPropVector(OriginalAngles, "tfnonlocaldata", "m_angEyeAngles[0]")
583584

584-
-- Clear last swing trace data
585-
lastswingtracedata = nil
585+
-- Clear last swing trace data
586+
lastswingtracedata = nil
587+
end
586588
end
587589
end
588590

@@ -726,7 +728,7 @@ local function checkInRangeWithLatency(playerIndex, swingRange, pWeapon, cmd)
726728
if inRange then
727729
return inRange, point, can_charge
728730
end
729-
elseif fakelatencyON == 1 then
731+
elseif fakelatencyON == 1 and playerTicks and playerTicks[playerIndex] then
730732
if not hasNotified then
731733
Notify.Simple("Fake Latency is enabled", " this may cause issues with the script", 7)
732734
hasNotified = true
@@ -1123,10 +1125,6 @@ vdistance = (vPlayerOrigin - pLocalOrigin):Length()
11231125
::continue::
11241126
end
11251127

1126-
local lastToggleTime = 0
1127-
local Lbox_Menu_Open = true
1128-
local toggleCooldown = 0.2 -- 200 milliseconds
1129-
11301128
-- Sphere cache and drawn edges cache
11311129
local sphere_cache = { vertices = {}, radius = 90, center = Vector3(0, 0, 0) }
11321130
local drawnEdges = {}
@@ -1291,6 +1289,9 @@ local drawPolygon = (function()
12911289
end
12921290
end)();
12931291

1292+
local lastToggleTime = 0
1293+
local Lbox_Menu_Open = true
1294+
local toggleCooldown = 0.2 -- 200 milliseconds
12941295

12951296
local function toggleMenu()
12961297
local currentTime = globals.RealTime()

0 commit comments

Comments
 (0)