core/smn_core.cpp
author David Anderson <dvander@alliedmods.net>
Mon Mar 12 00:06:20 2007 +0000 (2007-03-12)
changeset 599 3a098eff4890
parent 595 1d8e56a119f2
child 618 290353a9f2a7
permissions -rw-r--r--
used a better error number
     1 /**
     2  * ===============================================================
     3  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     4  * ===============================================================
     5  *
     6  * This file is not open source and may not be copied without explicit
     7  * written permission of AlliedModders LLC.  This file may not be redistributed 
     8  * in whole or significant part.
     9  * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
    10  *
    11  * Version: $Id$
    12  */
    13 
    14 #include <time.h>
    15 #include "sm_globals.h"
    16 #include "sourcemod.h"
    17 
    18 static cell_t ThrowError(IPluginContext *pContext, const cell_t *params)
    19 {
    20 	char buffer[512];
    21 
    22 	g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 1);
    23 
    24 	if (pContext->GetContext()->n_err == SP_ERROR_NONE)
    25 	{
    26 		pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", buffer);
    27 	}
    28 
    29 	return 0;
    30 }
    31 
    32 static cell_t GetTime(IPluginContext *pContext, const cell_t *params)
    33 {
    34 	time_t t = time(NULL);
    35 	cell_t *addr;
    36 	pContext->LocalToPhysAddr(params[1], &addr);
    37 
    38 	*(time_t *)addr = t;
    39 
    40 	return static_cast<cell_t>(t);
    41 }
    42 
    43 REGISTER_NATIVES(coreNatives)
    44 {
    45 	{"GetTime",				GetTime},
    46 	{"ThrowError",			ThrowError},
    47 	{NULL,					NULL},
    48 };