added request amb80 (system time)
authorDavid Anderson <dvander@alliedmods.net>
Sun Mar 11 18:30:29 2007 +0000 (2007-03-11)
changeset 5951d8e56a119f2
parent 594 a9e75c1b8efa
child 596 20a01c05806d
added request amb80 (system time)
core/smn_core.cpp
plugins/include/sourcemod.inc
     1.1 --- a/core/smn_core.cpp	Sun Mar 11 03:25:28 2007 +0000
     1.2 +++ b/core/smn_core.cpp	Sun Mar 11 18:30:29 2007 +0000
     1.3 @@ -11,6 +11,7 @@
     1.4   * Version: $Id$
     1.5   */
     1.6  
     1.7 +#include <time.h>
     1.8  #include "sm_globals.h"
     1.9  #include "sourcemod.h"
    1.10  
    1.11 @@ -28,8 +29,20 @@
    1.12  	return 0;
    1.13  }
    1.14  
    1.15 +static cell_t GetTime(IPluginContext *pContext, const cell_t *params)
    1.16 +{
    1.17 +	time_t t = time(NULL);
    1.18 +	cell_t *addr;
    1.19 +	pContext->LocalToPhysAddr(params[1], &addr);
    1.20 +
    1.21 +	*(time_t *)addr = t;
    1.22 +
    1.23 +	return static_cast<cell_t>(t);
    1.24 +}
    1.25 +
    1.26  REGISTER_NATIVES(coreNatives)
    1.27  {
    1.28 +	{"GetTime",				GetTime},
    1.29  	{"ThrowError",			ThrowError},
    1.30  	{NULL,					NULL},
    1.31  };
     2.1 --- a/plugins/include/sourcemod.inc	Sun Mar 11 03:25:28 2007 +0000
     2.2 +++ b/plugins/include/sourcemod.inc	Sun Mar 11 18:30:29 2007 +0000
     2.3 @@ -147,6 +147,14 @@
     2.4  native LogError(const String:format[], {Handle,Float,String,_}:...);
     2.5  
     2.6  /**
     2.7 + * Gets the system time as a unix timestamp.
     2.8 + *
     2.9 + * @param bigStamp		Optional array to store the 64bit timestamp in.
    2.10 + * @return				32bit timestamp (number of seconds since unix epoch).
    2.11 + */
    2.12 +native GetTime(bigStamp[2]={0,0});
    2.13 +
    2.14 +/**
    2.15   * Sets the seed value for the global Half-Life 2 Random Stream
    2.16   *
    2.17   * @param seed			Seed value.