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.