Feat: add fps counter

This commit is contained in:
Linventif 2024-11-21 17:07:28 +00:00
parent a6ab55dd4a
commit 0a7ae28a75
4 changed files with 23 additions and 1 deletions

View File

@ -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) draw.SimpleText(concatInfo, "DermaDefault", ScrW() / 2, ScrH() - 15, Color(255, 255, 255, 119), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end) 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)

View File

@ -6,6 +6,7 @@ local netSend = {
["takeScreenShot"] = 4, ["takeScreenShot"] = 4,
["restartMap"] = 5, ["restartMap"] = 5,
["verifyMe"] = 6, ["verifyMe"] = 6,
["sendFPS"] = 7
} }
function gmInte.SendNet(id, args, func) function gmInte.SendNet(id, args, func)

View File

@ -12,6 +12,7 @@ function gmInte.getPlayerFormat(ply)
["customValues"] = ply:gmIntGetCustomValues(), ["customValues"] = ply:gmIntGetCustomValues(),
["connectTime"] = math.Round(RealTime() - ply:gmIntGetConnectTime()), ["connectTime"] = math.Round(RealTime() - ply:gmIntGetConnectTime()),
["ping"] = ply:Ping(), ["ping"] = ply:Ping(),
["fps"] = ply:gmIntGetFPS(),
["position"] = gmInte.getVectorFormat(ply:GetPos()), ["position"] = gmInte.getVectorFormat(ply:GetPos()),
["angle"] = gmInte.getAngleFormat(ply:EyeAngles()), ["angle"] = gmInte.getAngleFormat(ply:EyeAngles()),
["weapon"] = gmInte.getWeaponFormat(ply:GetActiveWeapon()) ["weapon"] = gmInte.getWeaponFormat(ply:GetActiveWeapon())

View File

@ -69,3 +69,7 @@ end
function ply:gmIntGetCustomValues() function ply:gmIntGetCustomValues()
return getCustomValues(self) return getCustomValues(self)
end end
function ply:gmIntGetFPS()
return self.gmIntFPS || 0
end