mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 22:27: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)
|
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)
|
|
@ -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)
|
||||||
|
|
|
@ -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())
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user