diff --git a/lua/gmod_integration/client/cl_main.lua b/lua/gmod_integration/client/cl_main.lua index e7d0581..9f16fe8 100644 --- a/lua/gmod_integration/client/cl_main.lua +++ b/lua/gmod_integration/client/cl_main.lua @@ -86,4 +86,20 @@ hook.Add("HUDPaint", "gmInte:HUD:ShowScreenshotInfo", function() end 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) \ No newline at end of file diff --git a/lua/gmod_integration/client/cl_net.lua b/lua/gmod_integration/client/cl_net.lua index 8fd7c21..2d1c1b9 100644 --- a/lua/gmod_integration/client/cl_net.lua +++ b/lua/gmod_integration/client/cl_net.lua @@ -6,6 +6,7 @@ local netSend = { ["takeScreenShot"] = 4, ["restartMap"] = 5, ["verifyMe"] = 6, + ["sendFPS"] = 7 } function gmInte.SendNet(id, args, func) diff --git a/lua/gmod_integration/shared/sh_api_format.lua b/lua/gmod_integration/shared/sh_api_format.lua index f13af6e..1b0237c 100644 --- a/lua/gmod_integration/shared/sh_api_format.lua +++ b/lua/gmod_integration/shared/sh_api_format.lua @@ -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()) diff --git a/lua/gmod_integration/shared/sh_player_meta.lua b/lua/gmod_integration/shared/sh_player_meta.lua index 36eded8..977c34f 100644 --- a/lua/gmod_integration/shared/sh_player_meta.lua +++ b/lua/gmod_integration/shared/sh_player_meta.lua @@ -68,4 +68,8 @@ end function ply:gmIntGetCustomValues() return getCustomValues(self) -end \ No newline at end of file +end +function ply:gmIntGetFPS() + return self.gmIntFPS || 0 +end +