From c2f106d4c63d0a66a58e1fff2c3826f5eaba8437 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 11 Mar 2007 18:30:29 +0000 Subject: [PATCH] added request amb80 (system time) --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40601 --- core/smn_core.cpp | 13 +++++++++++++ plugins/include/sourcemod.inc | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/core/smn_core.cpp b/core/smn_core.cpp index bc7b342a..c37dbd95 100644 --- a/core/smn_core.cpp +++ b/core/smn_core.cpp @@ -11,6 +11,7 @@ * Version: $Id$ */ +#include #include "sm_globals.h" #include "sourcemod.h" @@ -28,8 +29,20 @@ static cell_t ThrowError(IPluginContext *pContext, const cell_t *params) return 0; } +static cell_t GetTime(IPluginContext *pContext, const cell_t *params) +{ + time_t t = time(NULL); + cell_t *addr; + pContext->LocalToPhysAddr(params[1], &addr); + + *(time_t *)addr = t; + + return static_cast(t); +} + REGISTER_NATIVES(coreNatives) { + {"GetTime", GetTime}, {"ThrowError", ThrowError}, {NULL, NULL}, }; diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index 4143dfb6..67cd32b8 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -146,6 +146,14 @@ native LogMessage(const String:format[], {Handle,Float,String,_}:...); */ native LogError(const String:format[], {Handle,Float,String,_}:...); +/** + * Gets the system time as a unix timestamp. + * + * @param bigStamp Optional array to store the 64bit timestamp in. + * @return 32bit timestamp (number of seconds since unix epoch). + */ +native GetTime(bigStamp[2]={0,0}); + /** * Sets the seed value for the global Half-Life 2 Random Stream *