Garry's Mod

Garry's Mod

Damage Slow
>KB> >KEKSQUAD 2021 年 2 月 3 日 上午 4:55
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
< >
正在显示第 1 - 2 条,共 2 条留言
GaussTheWizard  [开发者] 2021 年 3 月 9 日 下午 6:27 
Well, this WAS the first addon I made without copy-pasting wiki code.
>KB> >KEKSQUAD 2021 年 3 月 10 日 下午 10:03 
引用自 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.
< >
正在显示第 1 - 2 条,共 2 条留言
每页显示数: 1530 50