added request amb80 (system time)

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40601
This commit is contained in:
David Anderson 2007-03-11 18:30:29 +00:00
parent d51ea0695f
commit c2f106d4c6
2 changed files with 21 additions and 0 deletions

View File

@ -11,6 +11,7 @@
* Version: $Id$
*/
#include <time.h>
#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<cell_t>(t);
}
REGISTER_NATIVES(coreNatives)
{
{"GetTime", GetTime},
{"ThrowError", ThrowError},
{NULL, NULL},
};

View File

@ -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
*