From 44c744b8fd4da788c02275599136ae3ffa0af58d Mon Sep 17 00:00:00 2001 From: Arthurdead Date: Mon, 26 Jun 2017 07:18:12 -0300 Subject: [PATCH] Add native to get gpGlobals->frametime (#629) --- core/smn_halflife.cpp | 6 ++++++ plugins/include/halflife.inc | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/core/smn_halflife.cpp b/core/smn_halflife.cpp index 20782566..ab0c1989 100644 --- a/core/smn_halflife.cpp +++ b/core/smn_halflife.cpp @@ -116,6 +116,11 @@ static cell_t GetGameTickCount(IPluginContext *pContext, const cell_t *params) return gpGlobals->tickcount; } +static cell_t GetGameFrameTime(IPluginContext *pContext, const cell_t *params) +{ + return sp_ftoc(gpGlobals->frametime); +} + static cell_t CreateFakeClient(IPluginContext *pContext, const cell_t *params) { if (!g_SourceMod.IsMapRunning()) @@ -607,6 +612,7 @@ REGISTER_NATIVES(halflifeNatives) {"GetGameFolderName", GetGameFolderName}, {"GetGameTime", GetGameTime}, {"GetGameTickCount", GetGameTickCount}, + {"GetGameFrameTime", GetGameFrameTime}, {"GetRandomFloat", GetRandomFloat}, {"GetRandomInt", GetRandomInt}, {"IsDedicatedServer", IsDedicatedServer}, diff --git a/plugins/include/halflife.inc b/plugins/include/halflife.inc index 6dfa067f..6c6aa95c 100644 --- a/plugins/include/halflife.inc +++ b/plugins/include/halflife.inc @@ -211,6 +211,13 @@ native float GetGameTime(); */ native int GetGameTickCount(); +/** + * Returns the time the Game took processing the last frame. + * + * @return Game frame time. + */ +native float GetGameFrameTime(); + /** * Returns the game description from the mod. *