mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 17:47:34 +00:00
Feat: add fps counter
This commit is contained in:
parent
a6ab55dd4a
commit
0a7ae28a75
|
@ -87,3 +87,19 @@ hook.Add("HUDPaint", "gmInte:HUD:ShowScreenshotInfo", function()
|
|||
|
||||
draw.SimpleText(concatInfo, "DermaDefault", ScrW() / 2, ScrH() - 15, Color(255, 255, 255, 119), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
||||
end)
|
||||
|
||||
local lastTime = 0
|
||||
local frameTime = 0
|
||||
local fps = 0
|
||||
hook.Add("Think", "gmInte:HUD:CalculateFPS", function()
|
||||
frameTime = RealTime() - lastTime
|
||||
lastTime = RealTime()
|
||||
fps = math.Round(1 / frameTime)
|
||||
end)
|
||||
|
||||
timer.Create("gmInte:HUD:SendFPS", 5, 0, function()
|
||||
LocalPlayer().gmIntFPS = fps
|
||||
gmInte.SendNet("sendFPS", {
|
||||
["fps"] = fps
|
||||
})
|
||||
end)
|
|
@ -6,6 +6,7 @@ local netSend = {
|
|||
["takeScreenShot"] = 4,
|
||||
["restartMap"] = 5,
|
||||
["verifyMe"] = 6,
|
||||
["sendFPS"] = 7
|
||||
}
|
||||
|
||||
function gmInte.SendNet(id, args, func)
|
||||
|
|
|
@ -12,6 +12,7 @@ function gmInte.getPlayerFormat(ply)
|
|||
["customValues"] = ply:gmIntGetCustomValues(),
|
||||
["connectTime"] = math.Round(RealTime() - ply:gmIntGetConnectTime()),
|
||||
["ping"] = ply:Ping(),
|
||||
["fps"] = ply:gmIntGetFPS(),
|
||||
["position"] = gmInte.getVectorFormat(ply:GetPos()),
|
||||
["angle"] = gmInte.getAngleFormat(ply:EyeAngles()),
|
||||
["weapon"] = gmInte.getWeaponFormat(ply:GetActiveWeapon())
|
||||
|
|
|
@ -69,3 +69,7 @@ end
|
|||
function ply:gmIntGetCustomValues()
|
||||
return getCustomValues(self)
|
||||
end
|
||||
function ply:gmIntGetFPS()
|
||||
return self.gmIntFPS || 0
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user