Skip to content

Commit

Permalink
Merge pull request #89 from Noahbg/master
Browse files Browse the repository at this point in the history
Optimize Think Hook
  • Loading branch information
BadgerCode authored Aug 1, 2023
2 parents 3c463d2 + f176356 commit 83b5442
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions lua/damagelogs/shared/autoslay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,9 @@ if CLIENT then
chat.AddText(Color(255, 62, 62), nick .. "(" .. steamid .. ") has disconnected with " .. slays .. auto .. (slays > 1 and "s" or "") .. " left!")
end)

local ents = {}
if aslay then return end

local jails = {}

net.Receive("DL_SendJails", function()
local count = net.ReadUInt(32)
Expand All @@ -513,30 +515,21 @@ if CLIENT then
table.insert(walls, net.ReadEntity())
end

for _, v in pairs(walls) do
table.insert(ents, v)
for _, v in ipairs(walls) do
table.insert(jails, v)
end
end)

hook.Add("Think", "JailWalls", function()
local function CheckWalls()
local found = false

for k, v in pairs(ents) do
if IsValid(v) then
v:SetCustomCollisionCheck(true)
v.jailWall = true
table.remove(ents, k)
found = true
break
end
end

if found then
CheckWalls()
local function CheckWalls()
for k, v in ipairs(jails) do
if IsValid(v) then
v:SetCustomCollisionCheck(true)
v.jailWall = true
end
end

CheckWalls()
end)
jails = {}
end

hook.Add("Think", "JailWalls", CheckWalls)
end

0 comments on commit 83b5442

Please sign in to comment.