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