Garry's Mod

Garry's Mod

Damage Slow
Optimization
BadCoderz reports this function using 86 calls per second.

function Think() if GetConVar("damageslow_enabled"):GetBool() then for _,ply in pairs(player.GetAll()) do if not runSpeed or not walkSpeed then runSpeed = ply:GetRunSpeed() walkSpeed = ply:GetWalkSpeed() end if ply:Health() <= GetConVar("damageslow_threshold"):GetInt() then ply:SetRunSpeed(runSpeed / 2) ply:SetWalkSpeed(walkSpeed / 2) else ply:SetRunSpeed(runSpeed) ply:SetWalkSpeed(walkSpeed) end end end end
< >
Showing 1-2 of 2 comments
GaussTheWizard  [developer] 9 Mar, 2021 @ 6:27pm 
Well, this WAS the first addon I made without copy-pasting wiki code.
>KB> >KEKSQUAD 10 Mar, 2021 @ 10:03pm 
Originally posted by Sninctbur:
Well, this WAS the first addon I made without copy-pasting wiki code.
You could get it down to next to none by caching players.GetAll() outside of the Think function.
< >
Showing 1-2 of 2 comments
Per page: 1530 50