From 314e7097f86295f222b08761a82f7fe3d6cb2896 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 21 May 2007 01:54:17 +0000 Subject: [PATCH] added request amb285 --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40828 --- core/smn_timers.cpp | 12 ++++++++++++ plugins/include/timers.inc | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/core/smn_timers.cpp b/core/smn_timers.cpp index 3fb77e74..bc8ef4f0 100644 --- a/core/smn_timers.cpp +++ b/core/smn_timers.cpp @@ -227,10 +227,22 @@ static cell_t smn_TriggerTimer(IPluginContext *pCtx, const cell_t *params) return 1; } +static cell_t smn_GetTickedTime(IPluginContext *pContext, const cell_t *params) +{ + cell_t *simulating; + pContext->LocalToPhysAddr(params[1], &simulating); + + *simulating = g_SimTicks.ticking ? 0 : 1; + + float t = g_SimTicks.ticking ? gpGlobals->curtime : g_SimTicks.ticktime; + return sp_ftoc(t); +} + REGISTER_NATIVES(timernatives) { {"CreateTimer", smn_CreateTimer}, {"KillTimer", smn_KillTimer}, {"TriggerTimer", smn_TriggerTimer}, + {"GetTickedTime", smn_GetTickedTime}, {NULL, NULL} }; diff --git a/plugins/include/timers.inc b/plugins/include/timers.inc index ce920395..f639bcf9 100644 --- a/plugins/include/timers.inc +++ b/plugins/include/timers.inc @@ -88,6 +88,17 @@ native KillTimer(Handle:timer, bool:autoClose=false); */ native TriggerTimer(Handle:timer, bool:reset=false); +/** + * Returns the simulated game time. + * + * @param simulated Retrieves whether or not the tick count + * is being manually simulated by SourceMod. + * This is the case if no players have joined + * the map yet. + * @return Time based on the game tick count. + */ +native Float:GetTickedTime(&bool:simulated); + /** * Creates a timer associated with a new data pack, and returns the datapack. * @note The datapack is automatically freed when the timer ends.