1 Commits

Author SHA1 Message Date
cf6c73e82f Tagged 0.20-RC6 2006-07-20 04:44:12 +00:00
228 changed files with 5432 additions and 14698 deletions

View File

@ -244,11 +244,7 @@ cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
// exec
cell retVal;
int err = amx_Execv(m_Amx, &retVal, m_Func, m_NumParams, realParams);
// log runtime error, if any
if (err != AMX_ERR_NONE)
LogError(m_Amx, err, "");
amx_Execv(m_Amx, &retVal, m_Func, m_NumParams, realParams);
// cleanup strings & arrays
for (i = 0; i < m_NumParams; ++i)
@ -498,8 +494,7 @@ cell executeForwards(int id, ...)
REAL tmp = (REAL)va_arg(argptr, double); // floats get converted to doubles
params[i] = *(cell*)&tmp;
}
else
params[i] = (cell)va_arg(argptr, cell);
params[i] = (cell)va_arg(argptr, cell);
}
va_end(argptr);
return g_forwards.executeForwards(id, params);
@ -507,20 +502,10 @@ cell executeForwards(int id, ...)
cell CForwardMngr::prepareArray(void *ptr, unsigned int size, ForwardArrayElemType type, bool copyBack)
{
if (m_TmpArraysNum >= FORWARD_MAX_PARAMS)
{
#ifdef MEMORY_TEST
m_validateAllAllocUnits();
#endif // MEMORY_TEST
AMXXLOG_Log("[AMXX] Forwards with more than 32 parameters are not supported (tried to prepare array # %d).", m_TmpArraysNum + 1);
m_TmpArraysNum = 0;
return -1;
}
m_TmpArrays[m_TmpArraysNum].ptr = ptr;
m_TmpArrays[m_TmpArraysNum].size = size;
m_TmpArrays[m_TmpArraysNum].type = type;
m_TmpArrays[m_TmpArraysNum].copyBack = copyBack;
return m_TmpArraysNum++;
}

View File

@ -46,7 +46,7 @@
#ifndef FORWARD_H
#define FORWARD_H
const int FORWARD_MAX_PARAMS = 32;
const int FORWARD_MAX_PARAMS = 16;
enum ForwardExecType
{

View File

@ -498,7 +498,7 @@ int CLangMngr::GetKeyEntry(String &key)
}
#define CHECK_PTR(ptr, start, bufsize) if ((ptr) - (start) >= (bufsize)) { \
LogError(amx, AMX_ERR_STACKERR, "Buffer overflow in string formatting"); \
AMXXLOG_Log("[AMXX] Buffer overflow in formatting (line %d, \"%s\")", amx->curline, g_plugins.findPluginFast(amx)->getName()); \
outbuf[0] = 0; \
len = 0; \
return outbuf; }
@ -509,7 +509,7 @@ int CLangMngr::GetKeyEntry(String &key)
{ \
strcpy(outbuf, ""); \
len = 0; \
LogError(amx, AMX_ERR_PARAMS, "String formatted incorrectly - parameter %d (total %d)", parm, paramCount); \
AMXXLOG_Log("[AMXX] Plugin did not format a string correctly (parameter %d (total %d), line %d, \"%s\")", parm, paramCount, amx->curline, g_plugins.findPluginFast(amx)->getName()); \
return outbuf; \
}
@ -536,7 +536,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
// Handle player ids (1-32) and server language
if (*pAmxLangName == LANG_PLAYER) // LANG_PLAYER
{
if ((int)CVAR_GET_FLOAT("amx_client_languages") == 0)
if ((int)CVAR_GET_FLOAT("amx_client_languages"))
{
cpLangName = g_vault.get("server_language");
} else {
@ -545,7 +545,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
} else if (*pAmxLangName == LANG_SERVER) { // LANG_SERVER
cpLangName = g_vault.get("server_language");
} else if (*pAmxLangName >= 1 && *pAmxLangName <= 32) { // Direct Client Id
if ((int)CVAR_GET_FLOAT("amx_client_languages") == 0)
if ((int)CVAR_GET_FLOAT("amx_client_languages"))
{
cpLangName = g_vault.get("server_language");
} else {
@ -584,64 +584,55 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
if (*def == '%')
{
++def;
if (*def == '%' || *def == 0)
{
*outptr++ = '%';
++def;
}
else
{
static char format[32];
format[0] = '%';
char *ptr = format+1;
static char format[32];
format[0] = '%';
char *ptr = format+1;
while (ptr-format<sizeof(format) && !isalpha(*ptr++ = *def++))
/*nothing*/;
ZEROTERM(format);
while (ptr-format<sizeof(format) && !isalpha(*ptr++ = *def++))
/*nothing*/;
ZEROTERM(format);
*ptr = 0;
switch ( *(ptr-1) )
*ptr = 0;
switch ( *(ptr-1) )
{
case 's':
{
case 's':
{
static char tmpString[4096];
char *tmpPtr = tmpString;
NEXT_PARAM();
cell *tmpCell = get_amxaddr(amx, params[parm++]);
while (tmpPtr-tmpString < sizeof(tmpString) && *tmpCell)
*tmpPtr++ = *tmpCell++;
static char tmpString[4096];
char *tmpPtr = tmpString;
NEXT_PARAM();
cell *tmpCell = get_amxaddr(amx, params[parm++]);
while (tmpPtr-tmpString < sizeof(tmpString) && *tmpCell)
*tmpPtr++ = *tmpCell++;
*tmpPtr = 0;
sprintf(outptr, format, tmpString);
ZEROTERM(outbuf);
break;
}
case 'g':
case 'f':
{
NEXT_PARAM();
sprintf(outptr, format, *(REAL*)get_amxaddr(amx, params[parm++]));
ZEROTERM(outbuf);
break;
}
case 'i':
case 'd':
case 'c':
{
NEXT_PARAM();
sprintf(outptr, format, (int)*get_amxaddr(amx, params[parm++]));
ZEROTERM(outbuf);
break;
}
default:
{
CHECK_OUTPTR(strlen(format)+1);
strcpy(outptr, format);
break;
}
*tmpPtr = 0;
sprintf(outptr, format, tmpString);
ZEROTERM(outbuf);
break;
}
case 'g':
case 'f':
{
NEXT_PARAM();
sprintf(outptr, format, *(REAL*)get_amxaddr(amx, params[parm++]));
ZEROTERM(outbuf);
break;
}
case 'i':
case 'd':
case 'c':
{
NEXT_PARAM();
sprintf(outptr, format, (int)*get_amxaddr(amx, params[parm++]));
ZEROTERM(outbuf);
break;
}
default:
{
CHECK_OUTPTR(strlen(format)+1);
strcpy(outptr, format);
break;
}
outptr += strlen(outptr);
}
outptr += strlen(outptr);
}
else if (*def == '^')
{
@ -966,7 +957,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
return 0;
}
MD5 md5;
md5.update(fp); // closes for us
md5.update(fp);
md5.finalize();
char md5buffer[33];
md5.hex_digest(md5buffer);

View File

@ -153,11 +153,9 @@ void LogEventsMngr::executeLogEvents()
{
int err;
bool valid;
for(CLogEvent* a = logevents[ logArgc ]; a ; a = a->next)
{
for(CLogEvent* a = logevents[ logArgc ]; a ; a = a->next){
valid = true;
for( CLogEvent::LogCond* b = a->filters; b ; b = b->next)
{
for( CLogEvent::LogCond* b = a->filters; b ; b = b->next){
valid = false;
for( CLogEvent::LogCondEle* c = b->list; c ; c = c->next) {
if ( c->cmp->compareCondition( logArgs[b->argnum] ) == 0 ){
@ -165,15 +163,27 @@ void LogEventsMngr::executeLogEvents()
break;
}
}
if (!valid)
break;
if (!valid) break;
}
if (valid)
#ifdef ENABLEEXEPTIONS
try
{
if ((err = amx_Exec(a->plugin->getAMX(), NULL , a->func , 0)) != AMX_ERR_NONE)
LogError(a->plugin->getAMX(), err, "");
#endif
if (valid){
if ((err = amx_Exec(a->plugin->getAMX(), NULL , a->func , 0)) != AMX_ERR_NONE)
LogError(a->plugin->getAMX(), err, "");
}
#ifdef ENABLEEXEPTIONS
}
catch( ... )
{
AMXXLOG_Log( "[AMXX] fatal error at log forward function execution");
}
#endif
}
}

Binary file not shown.

View File

@ -428,7 +428,6 @@ int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
AMX_HEADER *hdr;
AMX_FUNCSTUB *func;
AMX_NATIVE f;
int i =0;
assert(amx!=NULL);
hdr=(AMX_HEADER *)amx->base;
@ -438,7 +437,6 @@ int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
assert(index>=0 && index<(cell)NUMENTRIES(hdr,natives,libraries));
func=GETENTRY(hdr,natives,index);
f=(AMX_NATIVE)func->address;
amx->userdata[2] = (char *)GETENTRYNAME(hdr, func);
assert(f!=NULL);
/* now that we have found the function, patch the program so that any
@ -608,7 +606,6 @@ static int amx_BrowseRelocate(AMX *amx)
} else {
amx->userdata[0] = 0;
amx->userdata[1] = 0;
amx->userdata[2] = 0;
}
#if defined __GNUC__ || defined ASM32 || defined JIT && !defined __64BIT__
@ -1114,18 +1111,12 @@ int AMXAPI amx_Init(AMX *amx,void *program)
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
int memoryFullAccess( void* addr, int len )
{
return mprotect(addr, len, PROT_READ|PROT_WRITE|PROT_EXEC);
}
int memoryFullAccess( void* addr, int len ) { return 1; }
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
int memorySetAccess( void* addr, int len, int access )
{
return mprotect(addr, len, PROT_READ|PROT_EXEC);
}
int memorySetAccess( void* addr, int len, int access ) { return 1; }
#endif /* #if defined __WIN32 __ */
@ -1134,13 +1125,8 @@ int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code)
int mac, res;
AMX_HEADER *hdr;
#ifdef __linux__
mac = memoryFullAccess( (void *)((int)((void*)asm_runJIT)-(int)((void*)asm_runJIT)%sysconf(_SC_PAGESIZE)), 20000 );
if ( mac )
#else
mac = memoryFullAccess((void *)asm_runJIT, 20000);
if ( !mac )
#endif
mac = memoryFullAccess( (void*)asm_runJIT, 20000 );
if ( ! mac )
return AMX_ERR_INIT_JIT;
/* copy the prefix */
@ -3419,6 +3405,7 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index, int numparams, ...)
if (alt==0)
ABORT(amx,AMX_ERR_DIVIDE);
/* divide must always round down; this is a bit
* involved to do in a machine-independent way.
*/
offs=(pri % alt + alt) % alt; /* true modulus */
pri=(pri - offs) / alt; /* division result */

11
amxmodx/amx_mm.def Executable file
View File

@ -0,0 +1,11 @@
; /usr/local/cross-tools/bin/i386-mingw32msvc-dlltool --base-file /tmp/cc4kB6s0.base --output-exp amx_mm.exp --dllname amx_mm.dll --output-def amx_mm.def --add-stdcall-alias --exclude-symbol=DllMainCRTStartup@12 --def /tmp/ccyI7I7K.def
EXPORTS
GetEngineFunctions @ 1 ;
GetEngineFunctions_Post @ 2 ;
GetEntityAPI2 @ 3 ;
GetEntityAPI2_Post @ 4 ;
GiveFnptrsToDll = GiveFnptrsToDll@8 @ 5 ;
GiveFnptrsToDll@8 @ 6 ;
Meta_Attach @ 7 ;
Meta_Detach @ 8 ;
Meta_Query @ 9 ;

View File

@ -351,15 +351,6 @@ static cell AMX_NATIVE_CALL is_linux_server(AMX *amx, cell *params)
#endif
}
static cell AMX_NATIVE_CALL is_amd64_server(AMX *amx, cell *params)
{
#if SMALL_CELL_SIZE==64
return 1;
#else
return 0;
#endif
}
static cell AMX_NATIVE_CALL is_jit_enabled(AMX *amx, cell *params) // PM: Useless ;P
{
#ifdef JIT
@ -1205,14 +1196,6 @@ static cell AMX_NATIVE_CALL message_begin(AMX *amx, cell *params) /* 4 param */
int numparam = *params/sizeof(cell);
float vecOrigin[3];
cell *cpOrigin;
if (params[2] < 1 || ((params[2] > 63) // maximal number of engine messages
&& !GET_USER_MSG_NAME(PLID, params[2], NULL)))
{
AMXXLOG_Log("[AMXX] Plugin called message_begin with an invalid message id (%d).", params[2]);
amx_RaiseError(amx, AMX_ERR_NATIVE);
return 0;
}
switch (params[1]){
case MSG_BROADCAST:
case MSG_ALL:
@ -1220,7 +1203,6 @@ static cell AMX_NATIVE_CALL message_begin(AMX *amx, cell *params) /* 4 param */
MESSAGE_BEGIN( params[1], params[2],NULL );
break;
case MSG_PVS: case MSG_PAS:
case MSG_PVS_R: case MSG_PAS_R:
if (numparam < 3) {
amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0;
@ -1231,13 +1213,12 @@ static cell AMX_NATIVE_CALL message_begin(AMX *amx, cell *params) /* 4 param */
vecOrigin[2] = *(cpOrigin+2);
MESSAGE_BEGIN( params[1], params[2] , vecOrigin );
break;
case MSG_ONE_UNRELIABLE:
case MSG_ONE:
if (numparam < 4) {
amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0;
}
MESSAGE_BEGIN( params[1], params[2], NULL, INDEXENT(params[4]) );
MESSAGE_BEGIN( MSG_ONE, params[2], NULL, INDEXENT(params[4]) );
break;
}
@ -1447,17 +1428,17 @@ static cell AMX_NATIVE_CALL read_data(AMX *amx, cell *params) /* 3 param */
{
return g_events.getCurrentMsgType();
}
switch( *params/sizeof(cell) ) {
case 1:
return g_events.getArgInteger( params[1] );
case 3:
return set_amxstring(amx,params[2], g_events.getArgString( params[1] ),*get_amxaddr(amx,params[3]));
default:
cell *fCell = get_amxaddr(amx, params[2]);
float fparam = g_events.getArgFloat(params[1]);
fCell[0] = amx_ftoc(fparam);
return (int)fparam;
}
switch( *params/sizeof(cell) ) {
case 1:
return g_events.getArgInteger( params[1] );
case 3:
return set_amxstring(amx,params[2], g_events.getArgString( params[1] ),*get_amxaddr(amx,params[3]));
default:
cell *fCell = get_amxaddr(amx,params[2]);
REAL pFloat = amx_ctof(fCell);
pFloat = g_events.getArgFloat( params[1] );
return (int)(pFloat);
}
}
static cell AMX_NATIVE_CALL get_playersnum(AMX *amx, cell *params)
@ -1686,16 +1667,6 @@ static cell AMX_NATIVE_CALL get_user_msgid(AMX *amx, cell *params) /* 1 param */
return GET_USER_MSG_ID(PLID, sptemp , NULL );
}
static cell AMX_NATIVE_CALL get_user_msgname(AMX *amx, cell *params) /* get_user_msgname(msg, str[], len) = 3 params */
{
const char* STRING = GET_USER_MSG_NAME(PLID, params[1], NULL);
if (STRING)
return set_amxstring(amx, params[2], STRING, params[3]);
// Comes here if GET_USER_MSG_NAME failed (ie, invalid msg id)
return 0;
}
static cell AMX_NATIVE_CALL set_task(AMX *amx, cell *params) /* 2 param */
{
@ -1769,11 +1740,7 @@ static cell AMX_NATIVE_CALL register_cvar(AMX *amx, cell *params) /* 3 param */
g_cvars.put( cvar );
if ( CVAR_GET_POINTER(temp) == 0 )
{
static cvar_t cvar_reg_helper;
cvar_reg_helper = *(cvar->getCvar());
CVAR_REGISTER( &cvar_reg_helper );
}
CVAR_REGISTER( cvar->getCvar() );
CVAR_SET_STRING( temp ,get_amxstring(amx,params[2],1,i));
return 1;
@ -2441,49 +2408,6 @@ static cell AMX_NATIVE_CALL callfunc_begin(AMX *amx, cell *params)
return 1; // success: 1
}
// native callfunc_begin_i(funcId, pluginId = -1)
static cell AMX_NATIVE_CALL callfunc_begin_i(AMX *amx, cell *params)
{
CPluginMngr::CPlugin *plugin;
if (params[2] < 0)
plugin = g_plugins.findPluginFast(amx);
else
plugin = g_plugins.findPlugin(params[2]);
if (!plugin)
return -1;
if (!plugin->isExecutable(params[1]))
return -2;
g_CallFunc_Plugin = plugin;
g_CallFunc_Func = params[1];
return 1;
}
// native get_func_id(funcName[], pluginId = -1)
static cell AMX_NATIVE_CALL get_func_id(AMX *amx, cell *params)
{
CPluginMngr::CPlugin *plugin;
if (params[2] < 0)
plugin = g_plugins.findPluginFast(amx);
else
plugin = g_plugins.findPlugin(params[2]);
if (!plugin)
return -1;
int len;
const char *funcName = get_amxstring(amx, params[1], 0, len);
int index;
if (amx_FindPublic(amx, funcName, &index) != AMX_ERR_NONE)
index = -1;
return index;
}
// native callfunc_end();
static cell AMX_NATIVE_CALL callfunc_end(AMX *amx, cell *params)
{
@ -2742,35 +2666,6 @@ cell AMX_NATIVE_CALL require_module(AMX *amx, cell *params)
return 1;
}
static cell AMX_NATIVE_CALL lang_phrase(AMX *amx, cell *params)
{
int len = 0;
int iLang = params[1];
const char *cpLangName=NULL;
// Handle player ids (1-32) and server language
if (iLang == LANG_SERVER) { // LANG_SERVER
cpLangName = g_vault.get("server_language");
} else if (iLang >= 1 && iLang <= 32) { // Direct Client Id
if ((int)CVAR_GET_FLOAT("amx_client_languages") == 0)
{
cpLangName = g_vault.get("server_language");
} else {
cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(iLang)->pEdict, "lang");
}
}
if (!cpLangName || strlen(cpLangName) < 1)
cpLangName = "en";
const char *str = get_amxstring(amx, params[2], 0, len);
const char *dat = g_langMngr.GetDef(cpLangName, str);
set_amxstring(amx, params[3], dat?dat:"ML_LNOTFOUND", params[4]);
return 1;
}
AMX_NATIVE_INFO amxmod_Natives[] = {
{ "client_cmd", client_cmd },
{ "client_print", client_print },
@ -2821,7 +2716,6 @@ AMX_NATIVE_INFO amxmod_Natives[] = {
{ "get_user_ip", get_user_ip },
{ "get_user_menu", get_user_menu},
{ "get_user_msgid", get_user_msgid},
{ "get_user_msgname", get_user_msgname},
{ "get_user_name", get_user_name },
{ "get_user_origin", get_user_origin},
{ "get_user_ping", get_user_ping },
@ -2837,7 +2731,6 @@ AMX_NATIVE_INFO amxmod_Natives[] = {
{ "get_xvar_num", get_xvar_num },
{ "is_dedicated_server",is_dedicated_server },
{ "is_linux_server", is_linux_server },
{ "is_amd64_server", is_amd64_server },
{ "is_jit_enabled", is_jit_enabled },
{ "is_user_authorized", is_user_authorized },
{ "is_map_valid", is_map_valid },
@ -2907,9 +2800,7 @@ AMX_NATIVE_INFO amxmod_Natives[] = {
{ "get_modulesnum", get_modulesnum },
{ "get_module", get_module },
{ "log_amx", log_amx },
{ "get_func_id", get_func_id },
{ "callfunc_begin", callfunc_begin },
{ "callfunc_begin_i", callfunc_begin_i },
{ "callfunc_end", callfunc_end },
{ "callfunc_push_int", callfunc_push_byval },
{ "callfunc_push_str", callfunc_push_str },
@ -2933,6 +2824,5 @@ AMX_NATIVE_INFO amxmod_Natives[] = {
{ "md5", amx_md5 },
{ "md5_file", amx_md5_file },
{ "plugin_flags", plugin_flags},
{ "lang_phrase", lang_phrase},
{ NULL, NULL }
};

View File

@ -33,10 +33,6 @@
#define AMXMODX_H
#ifdef __linux__
#include <unistd.h>
#include <stdlib.h>
#endif
#include "string.h"
#include <extdll.h>
#include <meta_api.h>
@ -66,7 +62,7 @@
#include "amxxlog.h"
#define AMXXLOG_Log g_log.Log
#define AMX_VERSION "1.00"
#define AMX_VERSION "0.2"
extern AMX_NATIVE_INFO core_Natives[];
extern AMX_NATIVE_INFO time_Natives[];

View File

@ -64,7 +64,7 @@ void CLog::CloseFile()
if (fp)
{
fclose(fp);
fp = fopen(m_LogFile.c_str(), "a+");
fopen(m_LogFile.c_str(), "a+");
// get time
time_t td;
@ -106,11 +106,8 @@ void CLog::CreateNewFile()
ALERT(at_logged, "[AMXX] Unexpected fatal logging error. AMXX Logging disabled.\n");
SET_LOCALINFO("amxx_logging", "0");
}
else
{
fprintf(fp, "AMX Mod X log file started (file \"%s/L%02d%02d%03d.log\") (version \"%s\")\n", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday, i, AMX_VERSION);
fclose(fp);
}
fprintf(fp, "AMX Mod X log file started (file \"%s/L%02d%02d%03d.log\") (version \"%s\")\n", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday, i, AMX_VERSION);
fclose(fp);
}
void CLog::UseFile(const String &fileName)

View File

@ -2344,14 +2344,6 @@ CFakeMeta::CFakeMetaPlugin::~CFakeMetaPlugin()
}
}
// ghost_of_evilspy's "could not find memloc for cvar" fix
void FakeMeta_New_CVarRegister(cvar_t *pCVar)
{
static cvar_t tmpvar;
tmpvar = *pCVar;
CVAR_REGISTER(&tmpvar);
}
int CFakeMeta::CFakeMetaPlugin::Query(mutil_funcs_t *pMetaUtilFuncs)
{
// Load the library
@ -2398,13 +2390,7 @@ int CFakeMeta::CFakeMetaPlugin::Query(mutil_funcs_t *pMetaUtilFuncs)
m_Status = PL_BADFILE;
return 0;
}
// ghost_of_evilspy's "Could not find memloc for cvar" fix
static enginefuncs_t fakemeta_engfuncs;
memcpy(&fakemeta_engfuncs, &g_engfuncs, sizeof(enginefuncs_t));
// Override cvar register to our own function
fakemeta_engfuncs.pfnCVarRegister = FakeMeta_New_CVarRegister;
giveEngFuncsFn(&fakemeta_engfuncs, gpGlobals);
giveEngFuncsFn(&g_engfuncs, gpGlobals);
if (queryFn(META_INTERFACE_VERSION, &m_Info, pMetaUtilFuncs) != 1)
{

View File

@ -57,23 +57,6 @@
CVector<FILE *> FileList;
class AutoFilePtr
{
FILE *m_FP;
public:
AutoFilePtr(FILE *fp) : m_FP(fp)
{ }
~AutoFilePtr()
{
if (m_FP)
fclose(m_FP);
}
operator FILE* ()
{
return m_FP;
}
};
static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
{
#ifdef __GNUC__
@ -185,7 +168,7 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
// adding a new line in a middle of already existing file
FILE* pTemp;
char buffor[2048];
char buffor[1024];
if ( (pTemp = tmpfile()) == NULL ){
amx_RaiseError(amx,AMX_ERR_NATIVE);
@ -194,11 +177,11 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
for(i=0;;++i){
if ( i == iLine ){
fgets(buffor,2047,pFile);
fgets(buffor,1023,pFile);
fputs( sText , pTemp );
fputc( '\n', pTemp );
}
else if ( fgets(buffor,2047,pFile) ){
else if ( fgets(buffor,1023,pFile) ){
fputs(buffor , pTemp );
}
else if ( i < iLine ) {
@ -216,7 +199,7 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
return 0;
}
while(fgets(buffor,2047,pTemp))
while(fgets(buffor,1023,pTemp))
fputs(buffor,pFile );
fclose(pTemp);
@ -245,44 +228,41 @@ static cell AMX_NATIVE_CALL file_exists(AMX *amx, cell *params) /* 1 param */
static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
{
int iLen;
char* sFile = get_amxstring(amx,params[1],0,iLen);
AutoFilePtr fp(fopen(build_pathname("%s",sFile),"r"));
if ( fp != NULL)
{
if ( params[0] < 2 || params[2] == 0 )
{
fseek(fp,0,SEEK_END);
int size = ftell(fp);
return size;
}
else if ( params[2] == 1 )
{
int a = 0,lines = 0;
while( a != EOF )
{
++lines;
while ( (a = fgetc(fp)) != '\n' && a != EOF )
;
}
//int a, b = '\n';
//while( (a = fgetc(fp)) != EOF ){
// if ( a == '\n')
// ++lines;
// b = a;
//}
//if ( b != '\n' )
// ++lines;
return lines;
}
else if ( params[2] == 2 ){
fseek(fp,-1,SEEK_END);
if ( fgetc(fp) == '\n' )
return 1;
return 0;
}
}
return -1;
int iLen;
char* sFile = get_amxstring(amx,params[1],0,iLen);
FILE* fp = fopen(build_pathname("%s",sFile),"r");
if ( fp != NULL) {
if ( params[0] < 2 || params[2] == 0 ){
fseek(fp,0,SEEK_END);
int size = ftell(fp);
fclose(fp);
return size;
}
else if ( params[2] == 1 ){
int a = 0,lines = 0;
while( a != EOF ){
++lines;
while ( (a = fgetc(fp)) != '\n' && a != EOF )
;
}
//int a, b = '\n';
//while( (a = fgetc(fp)) != EOF ){
// if ( a == '\n')
// ++lines;
// b = a;
//}
//if ( b != '\n' )
// ++lines;
return lines;
}
else if ( params[2] == 2 ){
fseek(fp,-1,SEEK_END);
if ( fgetc(fp) == '\n' )
return 1;
return 0;
}
}
return -1;
}
//ported from Sanji's file access module by BAILOPAN
@ -474,7 +454,7 @@ static cell AMX_NATIVE_CALL amx_filesize(AMX *amx, cell *params)
int len;
char *file = build_pathname("%s", format_amxstring(amx, params, 1, len));
long size;
AutoFilePtr fp(fopen(file, "rb"));
FILE *fp = fopen(file, "rb");
if (fp) {
fseek(fp, 0, SEEK_END);
size = ftell(fp);

View File

@ -281,7 +281,7 @@ int C_Spawn( edict_t *pent ) {
FF_ClientPutInServer = registerForward("client_putinserver", ET_IGNORE, FP_CELL, FP_DONE);
FF_PluginCfg = registerForward("plugin_cfg", ET_IGNORE, FP_DONE);
FF_PluginPrecache = registerForward("plugin_precache", ET_IGNORE, FP_DONE);
FF_PluginLog = registerForward("plugin_log", ET_STOP, FP_DONE);
FF_PluginLog = registerForward("plugin_log", ET_IGNORE, FP_DONE);
FF_PluginEnd = registerForward("plugin_end", ET_IGNORE, FP_DONE);
FF_InconsistentFile = registerForward("inconsistent_file", ET_STOP, FP_CELL, FP_STRING, FP_STRINGEX, FP_DONE);
FF_ClientAuthorized = registerForward("client_authorized", ET_IGNORE, FP_CELL, FP_DONE);
@ -300,6 +300,7 @@ int C_Spawn( edict_t *pent ) {
(*a).getMin(),(*a).getMax(),(*a).getFilename());
}
RETURN_META_VALUE(MRES_IGNORED, 0);
}
@ -602,35 +603,6 @@ void C_ClientCommand( edict_t *pEntity ) {
META_RES result = MRES_IGNORED;
cell ret = 0;
int err;
const char* cmd = CMD_ARGV(0);
const char* arg = CMD_ARGV(1);
// Handle "amxx" if not on listenserver
if (IS_DEDICATED_SERVER())
{
if (cmd && stricmp(cmd, "amxx")==0)
{
// Print version
static char buf[1024];
sprintf(buf, "%s %s\n", Plugin_info.name, Plugin_info.version);
CLIENT_PRINT(pEntity, print_console, buf);
sprintf(buf, "Authors: %s (%s)\n", "Felix \"SniperBeamer\" Geyer, David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko, Jonny \"Got His Gun\" Bergstrom, and Lukasz \"SidLuke\" Wlasinski.", Plugin_info.url);
CLIENT_PRINT(pEntity, print_console, buf);
sprintf(buf, "Compiled: %s\n", __DATE__ ", " __TIME__);
CLIENT_PRINT(pEntity, print_console, buf);
#ifdef JIT
sprintf(buf, "Core mode: JIT\n");
#else
#ifdef ASM32
sprintf(buf, "Core mode: ASM\n");
#else
sprintf(buf, "Core mode: Normal\n");
#endif
#endif
CLIENT_PRINT(pEntity, print_console, buf);
RETURN_META(MRES_SUPERCEDE);
}
}
#ifdef ENABLEEXEPTIONS
try
@ -647,7 +619,10 @@ void C_ClientCommand( edict_t *pEntity ) {
}
#endif
/* check for command and if needed also for first argument and call proper function */
const char* cmd = CMD_ARGV(0);
const char* arg = CMD_ARGV(1);
#ifdef ENABLEEXEPTIONS
try{
@ -1010,9 +985,7 @@ void C_AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...)
g_logevents.parseLogString( );
if (g_logevents.logEventsExist())
g_logevents.executeLogEvents( );
cell retVal = executeForwards(FF_PluginLog);
if (retVal)
RETURN_META(MRES_HANDLED);
executeForwards(FF_PluginLog);
}
RETURN_META(MRES_IGNORED);

View File

@ -29,11 +29,6 @@
* version.
*/
#ifdef __linux__
#include <malloc.h>
#include <stdlib.h>
#include <sys/mman.h>
#endif
#include "amxmodx.h"
#include "osdep.h" // sleep, etc
#include "CFile.h"
@ -179,16 +174,10 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
return (amx->error = AMX_ERR_INIT);
}
if ( (err = amx_InitJIT(amx, rt, np)) == AMX_ERR_NONE )
if (amx_InitJIT(amx, rt, np) == AMX_ERR_NONE)
{
//amx->base = (unsigned char FAR *)realloc( np, amx->code_size );
#ifndef __linux__
amx->base = new unsigned char[ amx->code_size ];
#else
//posix_memalign((void **)&(amx->base), sysconf(_SC_PAGESIZE), amx->code_size);
amx->base = (unsigned char *)memalign(sysconf(_SC_PAGESIZE), amx->code_size);
mprotect((void *)amx->base, amx->code_size, PROT_READ|PROT_WRITE|PROT_EXEC);
#endif
if ( amx->base )
memcpy( amx->base , np , amx->code_size );
delete[] np;
@ -204,7 +193,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
{
delete[] np;
delete[] rt;
sprintf(error, "Failed to initialize plugin (%d)", err);
strcpy(error,"Failed to initialize plugin");
return (amx->error = AMX_ERR_INIT_JIT);
}
@ -627,11 +616,7 @@ int loadModules(const char* filename)
CModule* cc = new CModule( path.c_str() );
if ( cc == 0 )
{
fclose(fp);
return loaded;
}
if ( cc == 0 ) return loaded;
cc->queryModule();
@ -1177,13 +1162,7 @@ void GenericError(AMX *amx, int err, int line, char buf[], const char *file)
{
sprintf(buf, "Run time error %d on line %d (%s \"%s\").", err, line, (file?"file":"plugin"), (file?file:g_plugins.findPluginFast(amx)->getName()));
} else {
if (err == AMX_ERR_NATIVE && amx->userdata[2])
{
geterr = (char *)(amx->userdata[2]);
sprintf(buf, "Native error in \"%s\" on line %d (%s \"%s\").", geterr, line, (file?"file":"plugin"), (file?file:g_plugins.findPluginFast(amx)->getName()));
} else {
sprintf(buf, "Run time error %d (%s) on line %d (%s \"%s\").", err, geterr, line, (file?"file":"plugin"), (file?file:g_plugins.findPluginFast(amx)->getName()));
}
sprintf(buf, "Run time error %d (%s) on line %d (%s \"%s\").", err, geterr, line, (file?"file":"plugin"), (file?file:g_plugins.findPluginFast(amx)->getName()));
}
}
}
@ -1206,21 +1185,8 @@ void LogError(AMX *amx, int err, const char *fmt, ...)
if (!dbg || !(dbg->tail))
{
if (dbg && amx->curfile < dbg->numFiles && amx->curfile >= 0)
{
GenericError(amx, err, amx->curline, buf, dbg->files[amx->curfile]);
} else {
GenericError(amx, err, amx->curline, buf, NULL);
}
AMXXLOG_Log("[AMXX] %s", buf);
if (*vbuf)
{
AMXXLOG_Log("%s", vbuf);
}
if (!dbg)
{
AMXXLOG_Log("[AMXX] To enable debug mode, add \" debug\" after the plugin name in plugins.ini (without quotes).");
}
GenericError(amx, err, amx->curline, buf, NULL);
AMXXLOG_Log("[AMXX] %s %s", buf, vbuf);
} else {
AMX_TRACE *t = dbg->tail;
AMX_DEBUGCALL tracer = (AMX_DEBUGCALL)(amx->userdata[1]);
@ -1228,20 +1194,19 @@ void LogError(AMX *amx, int err, const char *fmt, ...)
cell line = amx->curline;
cell file = amx->curfile;
int i = 0;
GenericError(amx, err, line, buf, NULL);
if (file >= dbg->numFiles || file < 0)
{
GenericError(amx, err, line, buf, NULL);
} else {
GenericError(amx, err, line, buf, dbg->files[file]);
}
AMXXLOG_Log("[AMXX] %s", buf);
if (*vbuf)
{
AMXXLOG_Log("%s", vbuf);
AMXXLOG_Log("[AMXX] %s", vbuf);
}
AMXXLOG_Log("[AMXX] Debug Trace =>");
//log the error right away
if (file >= dbg->numFiles || file < 0)
{
AMXXLOG_Log("[AMXX] [%d] Line %d, File \"%s\"", i++, line, g_plugins.findPluginFast(amx)->getName());
} else {
AMXXLOG_Log("[AMXX] [%d] Line %d, File \"%s\"", i++, line, dbg->files[file]);
}
while (t != NULL)
{
line = t->line;

View File

@ -316,7 +316,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="..\jit\jits.obj ..\zlib\zlib.lib"
AdditionalDependencies="odbc32.lib odbccp32.lib ..\jit\jits.lib ..\zlib\zlib.lib"
OutputFile="jitdebug/amxmodx_mm.dll"
Version="0.1"
LinkIncremental="1"
@ -780,9 +780,6 @@
<File
RelativePath="..\modules.h">
</File>
<File
RelativePath="..\resource.h">
</File>
<Filter
Name="mmgr"
Filter="">

View File

@ -45,16 +45,6 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2124,7 +2114,6 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2142,7 +2131,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2165,7 +2154,6 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2183,7 +2171,6 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2208,7 +2195,6 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2226,7 +2212,6 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2454,7 +2439,7 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_LOG_ERROR g_fn_LogError;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
@ -2544,7 +2529,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("LogError", g_fn_LogError, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2651,18 +2636,6 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#if defined __LCC__ || defined __DMC__ || defined __linux__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1990,7 +1990,7 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_LOG_ERROR g_fn_LogError;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
@ -2106,7 +2106,7 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_LogError g_fn_LogError
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward

View File

@ -148,8 +148,8 @@ void amx_command(){
{
print_srvconsole( "%s %s\n", Plugin_info.name, Plugin_info.version);
print_srvconsole( "Authors: %s (%s)\n", "Felix \"SniperBeamer\" Geyer, David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko, Jonny \"Got His Gun\" Bergstrom, and Lukasz \"SidLuke\" Wlasinski.", Plugin_info.url);
print_srvconsole( "Compiled: %s\n", __DATE__ ", " __TIME__);
print_srvconsole( "author: %s (%s)\n", Plugin_info.author, Plugin_info.url);
print_srvconsole( "compiled: %s\n", __DATE__ ", " __TIME__);
#ifdef JIT
print_srvconsole( "Core mode: JIT\n");
#else

View File

@ -1,34 +1,8 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEVERSION 0,2,0,0
PRODUCTVERSION 0,2,0,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -39,64 +13,22 @@ VS_VERSION_INFO VERSIONINFO
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "Comments", "AMX Mod X"
VALUE "FileDescription", "AMX Mod X"
VALUE "FileVersion", "1.00"
VALUE "InternalName", "amxmodx"
VALUE "LegalCopyright", "Copyright (c) 2004, AMX Mod X Dev Team"
VALUE "OriginalFilename", "amxmodx_mm.dll"
VALUE "ProductName", "AMX Mod X"
VALUE "ProductVersion", "1.00"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "Comments", "AMX Mod X\0"
VALUE "FileDescription", "AMX Mod X\0"
VALUE "FileVersion", "0.20\0"
VALUE "InternalName", "amxmodx\0"
VALUE "LegalCopyright", "Copyright (c) 2004, AMX Mod X Dev Team\0"
VALUE "OriginalFilename", "amxx_mm.dll\0"
VALUE "ProductName", "AMX Mod X\0"
VALUE "ProductVersion", "0.20\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -14,4 +14,4 @@
"Kick player" "amx_kick #%userid%" "b" "u"
"Slay player" "amx_slay #%userid%" "bd" "u"
"Slap with 1 dmg." "amx_slap #%userid% 1" "bd" "u"
"Ban for 5 minutes" "amx_ban #%userid% 5" "b" "u"
"Ban for 5 minutes" "amx_ban #%userid% id 5" "b" "u"

View File

@ -7,21 +7,18 @@
; ------------------------------
fun_amxx_i386.so
fun_amxx.dll
fun_amxx_amd64.so
; ----------------------------------------------------
; Engine - provides engine functions core to Half-Life
; ----------------------------------------------------
;engine_amxx_i386.so
;engine_amxx.dll
;engine_amxx_amd64.so
; ----------------------------------------------------------
; Fakemeta - provides a massive interface into the HL engine
; ----------------------------------------------------------
;fakemeta_amxx_i386.so
;fakemeta_amxx.dll
;fakemeta_amxx_amd64.so
; -------------------------------------------
; Database Access - only enable one of these
@ -29,7 +26,6 @@ fun_amxx_amd64.so
; MySQL
;mysql_amxx_i386.so
;mysql_amxx.dll
;mysql_amxx_amd64.so
; PostgreSQL
;pgsql_amxx_i386.so
;pgsql_amxx.dll
@ -41,39 +37,27 @@ fun_amxx_amd64.so
; ---------------------------------------------
;geoip_amxx_i386.so
;geoip_amxx.dll
;geoip_amxx_amd64.so
; ------------------------------------
; Array - advanced arrays in scripting
; ------------------------------------
;array_amxx_i386.so
;array_amxx.dll
;array_amxx_amd64.so
; --------------------------------
; Sockets - network socket support
; --------------------------------
;sockets_amxx_i386.so
;sockets_amxx.dll
;sockets_amxx_amd64.so
; --------------------------
; Regular Expression support
; --------------------------
;regex_amxx_i386.so
;regex_amxx.dll
;regex_amxx_amd64.so
; ----------------------------------------------------------
; Counter-Strike - adds functions specific to Counter-Strike
; ----------------------------------------------------------
cstrike_amxx_i386.so
cstrike_amxx.dll
cstrike_amxx_amd64.so
;cstrike_amxx_i386.so
;cstrike_amxx.dll
; -----------------------------------------------------
; CSX - adds functionality for CS statistics and events
; -----------------------------------------------------
csx_amxx_i386.so
csx_amxx.dll
csx_amxx_amd64.so
; ------------------------------------------------
; CS Stats - adds functionality for CS statistical
; ------------------------------------------------
;csstats_amxx_i386.so
;csstats_amxx.dll

View File

@ -35,9 +35,9 @@ statscfg.amxx ; allows to manage stats plugins via menu and commands
; Counter-Strike
;restmenu.amxx ; restrict weapons menu
;statsx.amxx ; stats on death or round end (CSX Module required!)
;statsx.amxx ; stats on death or round end (CSStats Module required!)
;miscstats.amxx ; bunch of events announcement for Counter-Strike
;stats_logging.amxx ; weapons stats logging (CSX Module required!)
;stats_logging.amxx ; weapons stats logging (CSStats Module required!)
; Custom - Add 3rd party plugins here

View File

@ -1,13 +0,0 @@
// Here you can add menu items from any plugin to Menus Front-End plugin, aka "amxmodmenu".
//
// Usage: "amx_addmenuitem <menu text> <menu command> <access flags> <plugin name>"
//
// <menu text>: This is the text displayed in the menu itself for this item.
// <menu command>: This is the client command used to access the menu.
// <access flags>: Specify what access flags admins must have to use this menu item. (Check users.ini for access flags.)
// <plugin name>: This must be the _exact_ (though case insensitive) name of the plugin which holds the menu command. (Use "amxx plugins" in server console, plugin names are listed in Name column.)
//
// Example: (be sure to use quotes around parameters with spaces!)
//
// amx_addmenuitem "Weapon Arena" "weaponarena_menu" "hu" "Weapon Arena"

View File

@ -7,21 +7,18 @@
; ------------------------------
fun_amxx_i386.so
fun_amxx.dll
fun_amxx_amd64.so
; ----------------------------------------------------
; Engine - provides engine functions core to Half-Life
; ----------------------------------------------------
;engine_amxx_i386.so
;engine_amxx.dll
;engine_amxx_amd64.so
; ----------------------------------------------------------
; Fakemeta - provides a massive interface into the HL engine
; ----------------------------------------------------------
;fakemeta_amxx_i386.so
;fakemeta_amxx.dll
;fakemeta_amxx_amd64.so
; -------------------------------------------
; Database Access - only enable one of these
@ -29,7 +26,6 @@ fun_amxx_amd64.so
; MySQL
;mysql_amxx_i386.so
;mysql_amxx.dll
;mysql_amxx_amd64.so
; PostgreSQL
;pgsql_amxx_i386.so
;pgsql_amxx.dll
@ -41,39 +37,27 @@ fun_amxx_amd64.so
; ---------------------------------------------
;geoip_amxx_i386.so
;geoip_amxx.dll
;geoip_amxx_amd64.so
; ------------------------------------
; Array - advanced arrays in scripting
; ------------------------------------
;array_amxx_i386.so
;array_amxx.dll
;array_amxx_amd64.so
; --------------------------------
; Sockets - network socket support
; --------------------------------
;sockets_amxx_i386.so
;sockets_amxx.dll
;sockets_amxx_amd64.so
; --------------------------
; Regular Expression support
; --------------------------
;regex_amxx_i386.so
;regex_amxx.dll
;regex_amxx_amd64.so
; --------------------------------------------------
; Day of Defeat Fun - adds functions specific to DoD
; --------------------------------------------------
dodfun_amxx_i386.so
dodfun_amxx.dll
dodfun_amxx_amd64.so
;dodfun_amxx_i386.so
;dodfun_amxx.dll
; -------------------------------------------------------
; Day of Defeat X - adds stats and addition DoD functions
; -------------------------------------------------------
dodx_amxx_i386.so
dodx_amxx.dll
dodx_amxx_amd64.so
;dodx_amxx_i386.so
;dodx_amxx.dll

View File

@ -7,21 +7,18 @@
; ------------------------------
fun_amxx_i386.so
fun_amxx.dll
fun_amxx_amd64.so
; ----------------------------------------------------
; Engine - provides engine functions core to Half-Life
; ----------------------------------------------------
;engine_amxx_i386.so
;engine_amxx.dll
;engine_amxx_amd64.so
; ----------------------------------------------------------
; Fakemeta - provides a massive interface into the HL engine
; ----------------------------------------------------------
;fakemeta_amxx_i386.so
;fakemeta_amxx.dll
;fakeneta_amxx_amd64.so
; -------------------------------------------
; Database Access - only enable one of these
@ -29,7 +26,6 @@ fun_amxx_amd64.so
; MySQL
;mysql_amxx_i386.so
;mysql_amxx.dll
;mysql_amxx_amd64.so
; PostgreSQL
;pgsql_amxx_i386.so
;pgsql_amxx.dll
@ -41,25 +37,15 @@ fun_amxx_amd64.so
; ---------------------------------------------
;geoip_amxx_i386.so
;geoip_amxx.dll
;geoip_amxx_amd64.so
; ------------------------------------
; Array - advanced arrays in scripting
; ------------------------------------
;array_amxx_i386.so
;array_amxx.dll
;array_amxx_amd64.so
; --------------------------------
; Sockets - network socket support
; --------------------------------
;sockets_amxx_i386.so
;sockets_amxx.dll
;sockets_amxx_amd64.so
; --------------------------
; Regular Expression support
; --------------------------
;regex_amxx_i386.so
;regex_amxx.dll
;regex_amxx_amd64.so

View File

@ -4,26 +4,23 @@
; Add in your mod's maps here
ns_metal
ns_caged
co_sava
co_angst
ns_caged
ns_hera
ns_metal
ns_lost
ns_nothing
co_faceoff
ns_mineshaft
co_daimos
ns_bast
ns_origin
co_kestrel
ns_tanith
ns_nancy
ns_veil
co_core
co_ulysses
ns_eclipse
co_pulse
ns_ayumi
ns_agora
ns_altair
co_ulysses

View File

@ -5,23 +5,20 @@
; ------------------------------
; Fun - provides extra functions
; ------------------------------
fun_amxx_i386.so
fun_amxx.dll
fun_amxx_amd64.so
;fun_amxx_i386.so
;fun_amxx.dll
; ----------------------------------------------------
; Engine - provides engine functions core to Half-Life
; ----------------------------------------------------
;engine_amxx_i386.so
;engine_amxx.dll
;engine_amxx_amd64.so
; ----------------------------------------------------------
; Fakemeta - provides a massive interface into the HL engine
; ----------------------------------------------------------
;fakemeta_amxx_i386.so
;fakemeta_amxx.dll
;fakemeta_amxx_amd64.so
; -------------------------------------------
; Database Access - only enable one of these
@ -29,7 +26,6 @@ fun_amxx_amd64.so
; MySQL
;mysql_amxx_i386.so
;mysql_amxx.dll
;mysql_amxx_amd64.so
; PostgreSQL
;pgsql_amxx_i386.so
;pgsql_amxx.dll
@ -41,31 +37,21 @@ fun_amxx_amd64.so
; ---------------------------------------------
;geoip_amxx_i386.so
;geoip_amxx.dll
;geoip_amxx_amd64.so
; ------------------------------------
; Array - advanced arrays in scripting
; ------------------------------------
;array_amxx_i386.so
;array_amxx.dll
;array_amxx_amd64.so
; --------------------------------
; Sockets - network socket support
; --------------------------------
;sockets_amxx_i386.so
;sockets_amxx.dll
;sockets_amxx_amd64.so
; --------------------------
; Regular Expression support
; --------------------------
;regex_amxx_i386.so
;regex_amxx.dll
;regex_amxx_amd64.so
; -----------------
; Natural Selection
; -----------------
ns_amxx_i386.so
ns_amxx.dll
ns_amxx_amd64.so

View File

@ -35,6 +35,6 @@ pausecfg.amxx ; allows to pause and unpause some plugins
; NS Specific plugins
idlekicker.amxx ; kicks idle players
nscommands.amxx ; extra commands for Natural-Selection
;unstuck.amxx ; Free stuck players (engine & ns modules required!)
unstuck.amxx ; Allows players to free themselves if they get stuck in the map (req engine & ns modules)
; Custom - Add 3rd party plugins here

View File

@ -7,21 +7,18 @@
; ------------------------------
fun_amxx_i386.so
fun_amxx.dll
fun_amxx_amd64.so
; ----------------------------------------------------
; Engine - provides engine functions core to Half-Life
; ----------------------------------------------------
;engine_amxx_i386.so
;engine_amxx.dll
;engine_amxx_amd64.so
; ----------------------------------------------------------
; Fakemeta - provides a massive interface into the HL engine
; ----------------------------------------------------------
;fakemeta_amxx_i386.so
;fakemeta_amxx.dll
;fakemeta_amxx_amd64.so
; -------------------------------------------
; Database Access - only enable one of these
@ -29,7 +26,6 @@ fun_amxx_amd64.so
; MySQL
;mysql_amxx_i386.so
;mysql_amxx.dll
;mysql_amxx_amd64.so
; PostgreSQL
;pgsql_amxx_i386.so
;pgsql_amxx.dll
@ -41,32 +37,21 @@ fun_amxx_amd64.so
; ---------------------------------------------
;geoip_amxx_i386.so
;geoip_amxx.dll
;geoip_amxx_amd64.so
; ------------------------------------
; Array - advanced arrays in scripting
; ------------------------------------
;array_amxx_i386.so
;array_amxx.dll
;array_amxx_amd64.so
; --------------------------------
; Sockets - network socket support
; --------------------------------
;sockets_amxx_i386.so
;sockets_amxx.dll
;sockets_amxx_amd64.so
; --------------------------
; Regular Expression support
; --------------------------
;regex_amxx_i386.so
;regex_amxx.dll
;regex_amxx_amd64.so
; ------------------------------------------------------------------
; Team Fortress Classic X - adds functions and stats specific to TFC
; ------------------------------------------------------------------
tfcx_amxx_i386.so
tfcx_amxx.dll
tfx_amxx_amd64.so
;tfcx_amxx_i386.so
;tfcx_amxx.dll

View File

@ -3,7 +3,7 @@ amxx_logdir addons/amxmodx/logs
amxx_configsdir addons/amxmodx/configs
amxx_datadir addons/amxmodx/data
amxx_modules addons/amxmodx/configs/modules.ini
amxx_plugins addons/amxmodx/configs/plugins.ini
mxx_plugins addons/amxmodx/configs/plugins.ini
amxx_pluginsdir addons/amxmodx/plugins
amxx_modulesdir addons/amxmodx/modules
amxx_vault addons/amxmodx/data/vault.ini

View File

@ -7,21 +7,18 @@
; ------------------------------
fun_amxx_i386.so
fun_amxx.dll
fun_amxx_amd64.so
; ----------------------------------------------------
; Engine - provides engine functions core to Half-Life
; ----------------------------------------------------
;engine_amxx_i386.so
;engine_amxx.dll
;engine_amxx_amd64.so
; ----------------------------------------------------------
; Fakemeta - provides a massive interface into the HL engine
; ----------------------------------------------------------
;fakemeta_amxx_i386.so
;fakemeta_amxx.dll
;fakemeta_amxx_amd64.so
; -------------------------------------------
; Database Access - only enable one of these
@ -29,7 +26,6 @@ fun_amxx_amd64.so
; MySQL
;mysql_amxx_i386.so
;mysql_amxx.dll
;mysql_amxx_amd64.so
; PostgreSQL
;pgsql_amxx_i386.so
;pgsql_amxx.dll
@ -41,32 +37,21 @@ fun_amxx_amd64.so
; ---------------------------------------------
;geoip_amxx_i386.so
;geoip_amxx.dll
;geoip_amxx_amd64.so
; ------------------------------------
; Array - advanced arrays in scripting
; ------------------------------------
;array_amxx_i386.so
;array_amxx.dll
;array_amxx_amd64.so
; --------------------------------
; Sockets - network socket support
; --------------------------------
;sockets_amxx_i386.so
;sockets_amxx.dll
;sockets_amxx_amd64.so
; --------------------------
; Regular Expression support
; --------------------------
;regex_amxx_i386.so
;regex_amxx.dll
;regex_amxx_amd64.so
; -----------------------------------------------------------
; The Specialists X - adds functions and stats specific to TS
; -----------------------------------------------------------
tsx_amxx_i386.so
tsx_amxx.dll
tsx_amxx_amd64.so
;tsx_amxx_i386.so
;tsx_amxx.dll

View File

@ -13,6 +13,7 @@ CCstrikePlayer::CCstrikePlayer()
{
modelled = false;
inspectModel = false;
online = false;
}
bool CCstrikePlayer::GetModelled()
@ -47,3 +48,20 @@ void CCstrikePlayer::SetInspectModel(bool inspectModelIn)
{
inspectModel = inspectModelIn;
}
bool CCstrikePlayer::GetOnline()
{
return online;
}
void CCstrikePlayer::SetOnline(bool onlineIn)
{
online = onlineIn;
}
void CCstrikePlayer::Initialize()
{
SetModelled(false);
SetInspectModel(false);
SetOnline(false);
}

View File

@ -10,6 +10,8 @@ class CCstrikePlayer
public:
CCstrikePlayer();
void Initialize();
bool GetModelled();
bool SetModelled(bool modelledIn);
const char* GetModel();
@ -18,10 +20,13 @@ public:
bool GetInspectModel();
void SetInspectModel(bool inspectModelIn);
bool GetOnline();
void SetOnline(bool onlineIn);
private:
bool inspectModel;
bool modelled;
bool online;
char model[32];
};

View File

@ -45,16 +45,6 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2124,7 +2114,6 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2142,7 +2131,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2165,7 +2154,6 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2183,7 +2171,6 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2208,7 +2195,6 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2226,7 +2212,6 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2454,14 +2439,11 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2471,7 +2453,6 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2544,7 +2525,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2580,8 +2560,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2593,7 +2572,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2651,18 +2629,6 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2683,14 +2649,11 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2701,7 +2664,6 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#if defined __LCC__ || defined __DMC__ || defined __linux__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,14 +1919,11 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1935,9 +1932,8 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1990,14 +1986,11 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2033,7 +2026,6 @@ extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2053,14 +2045,11 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2070,7 +2059,6 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2106,14 +2094,11 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2123,7 +2108,6 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2149,7 +2133,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format
#define MF_Format g_fn_Format;
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -37,7 +37,11 @@
bool UTIL_IsPlayer(AMX* amx, edict_t* pPlayer) {
bool player = false;
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
if (strcmp(STRING(pPlayer->v.classname), "player") == 0)
player = true;
@ -70,10 +74,20 @@ static cell AMX_NATIVE_CALL cs_set_user_money(AMX *amx, cell *params) // cs_set_
// params[3] = flash money?
// Check index
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Give money
*((int *)pPlayer->pvPrivateData + OFFSET_CSMONEY) = params[2];
@ -93,10 +107,20 @@ static cell AMX_NATIVE_CALL cs_get_user_money(AMX *amx, cell *params) // cs_get_
// params[1] = user
// Check index
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Return money
return *((int *)pPlayer->pvPrivateData + OFFSET_CSMONEY);
@ -108,10 +132,20 @@ static cell AMX_NATIVE_CALL cs_get_user_deaths(AMX *amx, cell *params) // cs_get
// params[1] = user
// Check index
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
return *((int *)pPlayer->pvPrivateData + OFFSET_CSDEATHS);
}
@ -123,10 +157,20 @@ static cell AMX_NATIVE_CALL cs_set_user_deaths(AMX *amx, cell *params) // cs_set
// params[2] = new deaths
// Check index
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Set deaths
*((int *)pPlayer->pvPrivateData + OFFSET_CSDEATHS) = params[2];
@ -149,14 +193,24 @@ static cell AMX_NATIVE_CALL cs_get_hostage_id(AMX *amx, cell *params) // cs_get_
// params[1] = hostage entity index
// Valid entity should be within range
CHECK_ENTITY(params[1]);
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into class pointer
edict_t *pEdict = GETEDICT(params[1]);
edict_t *pEdict = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pEdict)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make sure this is a hostage.
if (strcmp(STRING(pEdict->v.classname), "hostage_entity") != 0) {
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a hostage", params[1], STRING(pEdict->v.classname));
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -170,11 +224,21 @@ static cell AMX_NATIVE_CALL cs_get_weapon_silenced(AMX *amx, cell *params) // cs
// params[1] = weapon index
// Valid entity should be within range
CHECK_NONPLAYER(params[1]);
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pWeapon)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
int *silencemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
switch (weapontype) {
@ -190,20 +254,6 @@ static cell AMX_NATIVE_CALL cs_get_weapon_silenced(AMX *amx, cell *params) // cs
return 0;
}
static cell AMX_NATIVE_CALL cs_get_weapon_id(AMX *amx, cell *params) // cs_get_weapon_id(index); = 1 param
{
// Get weapon type. Corresponds to CSW_*
// params[1] = weapon index
// Valid entity should be within range
CHECK_NONPLAYER(params[1]);
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
return *((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
}
static cell AMX_NATIVE_CALL cs_set_weapon_silenced(AMX *amx, cell *params) // cs_set_weapon_silenced(index, silence = 1); = 2 params
{
// Silence/unsilence gun. Does only work on M4A1 and USP.
@ -211,11 +261,21 @@ static cell AMX_NATIVE_CALL cs_set_weapon_silenced(AMX *amx, cell *params) // cs
// params[2] = 1, and we silence the gun, 0 and we unsilence gun.
// Valid entity should be within range
CHECK_NONPLAYER(params[1]);
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pWeapon)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
int *silencemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
@ -265,11 +325,21 @@ static cell AMX_NATIVE_CALL cs_get_weapon_burstmode(AMX *amx, cell *params) // c
// params[1] = weapon index
// Valid entity should be within range
CHECK_NONPLAYER(params[1]);
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pWeapon)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
int* firemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
switch (weapontype) {
@ -292,11 +362,21 @@ static cell AMX_NATIVE_CALL cs_set_weapon_burstmode(AMX *amx, cell *params) // c
// params[2] = 1, and we set burstmode, 0 and we unset it.
// Valid entity should be within range
CHECK_NONPLAYER(params[1]);
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pWeapon)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
int* firemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
@ -352,10 +432,20 @@ static cell AMX_NATIVE_CALL cs_get_user_vip(AMX *amx, cell *params) // cs_get_us
// params[1] = user index
// Valid entity should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
if ( *((int *)pPlayer->pvPrivateData + OFFSET_VIP) & PLAYER_IS_VIP )
return 1;
@ -370,10 +460,20 @@ static cell AMX_NATIVE_CALL cs_set_user_vip(AMX *amx, cell *params) // cs_set_us
// params[2] = if 1, activate vip, else deactivate vip.
// Valid entity should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
if (params[2] == 1) {
// Set to "be" vip.
@ -422,10 +522,20 @@ static cell AMX_NATIVE_CALL cs_get_user_team(AMX *amx, cell *params) // cs_get_u
// params[1] = user index
// Valid entity should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
return *((int *)pPlayer->pvPrivateData + OFFSET_TEAM);
}
@ -438,10 +548,20 @@ static cell AMX_NATIVE_CALL cs_set_user_team(AMX *amx, cell *params) // cs_set_u
// params[3] = model = 0
// Valid entity should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int model = params[3];
@ -469,8 +589,7 @@ static cell AMX_NATIVE_CALL cs_set_user_team(AMX *amx, cell *params) // cs_set_u
strcpy(teaminfo, "SPECTATOR");
break;
default:
int team_nr = (int)params[2];
sprintf(teaminfo, "TEAM_%i", team_nr);
sprintf(teaminfo, "TEAM_%d", params[2]);
}
MESSAGE_BEGIN(MSG_ALL, GET_USER_MSG_ID(PLID, "TeamInfo", NULL));
WRITE_BYTE(params[1]);
@ -486,10 +605,20 @@ static cell AMX_NATIVE_CALL cs_get_user_inside_buyzone(AMX *amx, cell *params) /
// params[1] = user index
// Valid entity should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
return (int)*((int *)pPlayer->pvPrivateData + OFFSET_BUYZONE); // This offset is 0 when outside, 1 when inside.
}
@ -500,10 +629,20 @@ static cell AMX_NATIVE_CALL cs_get_user_plant(AMX *amx, cell *params) // cs_get_
// params[1] = user index
// Valid entity should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
if ((int)*((int *)pPlayer->pvPrivateData + OFFSET_DEFUSE_PLANT) & CAN_PLANT_BOMB)
return 1;
@ -519,10 +658,20 @@ static cell AMX_NATIVE_CALL cs_set_user_plant(AMX *amx, cell *params) // cs_set_
// params[3] = show bomb icon?
// Valid entity should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int* plantskill = ((int *)pPlayer->pvPrivateData + OFFSET_DEFUSE_PLANT);
@ -565,10 +714,20 @@ static cell AMX_NATIVE_CALL cs_get_user_defusekit(AMX *amx, cell *params) // cs_
// params[1] = user index
// Valid entity should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
if ((int)*((int *)pPlayer->pvPrivateData + OFFSET_DEFUSE_PLANT) & HAS_DEFUSE_KIT)
return 1;
@ -588,10 +747,20 @@ static cell AMX_NATIVE_CALL cs_set_user_defusekit(AMX *amx, cell *params) // cs_
// params[7] = flash = 0
// Valid entity should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int* defusekit = ((int *)pPlayer->pvPrivateData + OFFSET_DEFUSE_PLANT);
@ -653,10 +822,20 @@ static cell AMX_NATIVE_CALL cs_get_user_backpackammo(AMX *amx, cell *params) //
// params[2] = weapon, as in CSW_*
// Valid entity should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int offset;
@ -718,7 +897,7 @@ static cell AMX_NATIVE_CALL cs_get_user_backpackammo(AMX *amx, cell *params) //
offset = OFFSET_C4_AMMO;
break;
default:
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", params[2]);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -735,10 +914,20 @@ static cell AMX_NATIVE_CALL cs_set_user_backpackammo(AMX *amx, cell *params) //
// params[3] = new amount
// Valid entity should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int offset;
@ -800,7 +989,7 @@ static cell AMX_NATIVE_CALL cs_set_user_backpackammo(AMX *amx, cell *params) //
offset = OFFSET_C4_AMMO;
break;
default:
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", params[2]);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -815,10 +1004,20 @@ static cell AMX_NATIVE_CALL cs_get_user_nvg(AMX *amx, cell *params) // cs_get_us
// params[1] = user index
// Valid entity should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
if ((int)*((int *)pPlayer->pvPrivateData + OFFSET_NVGOGGLES) & HAS_NVGOGGLES)
return 1;
@ -833,10 +1032,20 @@ static cell AMX_NATIVE_CALL cs_set_user_nvg(AMX *amx, cell *params) // cs_set_us
// params[2] = 1 = give, 0 = remove
// Valid entity should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int* defusekit = ((int *)pPlayer->pvPrivateData + OFFSET_NVGOGGLES);
@ -864,9 +1073,20 @@ static cell AMX_NATIVE_CALL cs_get_user_model(AMX *amx, cell *params) // cs_get_
// params[3] = max length to set
// Valid player index should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
return MF_SetAmxString(amx, params[2], GETCLIENTKEYVALUE(GETINFOKEYBUFFER(pPlayer), "model"), params[3]);
}
@ -878,13 +1098,23 @@ static cell AMX_NATIVE_CALL cs_set_user_model(AMX *amx, cell *params) // cs_set_
// params[2] = model
// Valid player index should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t* pPlayer = MF_GetPlayerEdict(params[1]);
edict_t* pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
if (params[2] == -1) {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid model %d", params[2]);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -907,10 +1137,20 @@ static cell AMX_NATIVE_CALL cs_reset_user_model(AMX *amx, cell *params) // cs_re
// params[1] = user index
// Valid player index should be within range
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t* pPlayer = MF_GetPlayerEdict(params[1]);
edict_t* pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
g_players[params[1]].SetModelled(false);
@ -925,14 +1165,24 @@ static cell AMX_NATIVE_CALL cs_get_hostage_follow(AMX *amx, cell *params) // cs_
// params[1] = hostage index
// Valid index should be within range
CHECK_NONPLAYER(params[1]);
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t* pHostage = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pHostage)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make sure this is a hostage.
if (strcmp(STRING(pHostage->v.classname), "hostage_entity") != 0) {
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a hostage", params[1], STRING(pHostage->v.classname));
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -948,7 +1198,7 @@ static cell AMX_NATIVE_CALL cs_get_hostage_follow(AMX *amx, cell *params) // cs_
edict_t* pEntity = (edict_t*)following;
if (FNullEnt(pEntity)) {
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown error finding hostage parameter");
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -962,14 +1212,24 @@ static cell AMX_NATIVE_CALL cs_set_hostage_follow(AMX *amx, cell *params) // cs_
// params[2] = index to follow, if -1 then set hostage to not follow anything
// Valid index should be within range
CHECK_NONPLAYER(params[1]);
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t* pHostage = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pHostage)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make sure this is a hostage.
if (strcmp(STRING(pHostage->v.classname), "hostage_entity") != 0) {
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a hostage", params[1], STRING(pHostage->v.classname));
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -985,10 +1245,20 @@ static cell AMX_NATIVE_CALL cs_set_hostage_follow(AMX *amx, cell *params) // cs_
}
// Valid index should be within range
CHECK_ENTITY(params[2]);
if (params[2] < 1 || params[2] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t* pEntity = GETEDICT(params[2]);
edict_t* pEntity = INDEXENT(params[2]);
// Check entity validity
if (FNullEnt(pEntity)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
#if !defined __amd64__
*((int *)pHostage->pvPrivateData + OFFSET_HOSTAGEFOLLOW) = (int)pEntity;
@ -1004,11 +1274,21 @@ static cell AMX_NATIVE_CALL cs_get_weapon_ammo(AMX *amx, cell *params) // cs_get
// params[1] = weapon index
// Valid entity should be within range
CHECK_NONPLAYER(params[1]);
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pWeapon)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
return *((int *)pWeapon->pvPrivateData + OFFSET_CLIPAMMO);
}
@ -1019,11 +1299,21 @@ static cell AMX_NATIVE_CALL cs_set_weapon_ammo(AMX *amx, cell *params) // cs_set
// params[2] = newammo
// Valid entity should be within range
CHECK_NONPLAYER(params[1]);
if (params[1] <= gpGlobals->maxClients || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pWeapon)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
*((int *)pWeapon->pvPrivateData + OFFSET_CLIPAMMO) = params[2];
return 1;
@ -1035,10 +1325,14 @@ static cell AMX_NATIVE_CALL cs_get_user_hasprimary(AMX *amx, cell *params) // cs
// params[1] = user index
// Check player
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
return *((int *)pPlayer->pvPrivateData + OFFSET_PRIMARYWEAPON);
}
@ -1057,104 +1351,6 @@ static cell AMX_NATIVE_CALL cs_set_no_knives(AMX *amx, cell *params) // cs_set_n
return 1;
}
// Damaged Soul
static cell AMX_NATIVE_CALL cs_get_user_tked(AMX *amx, cell *params) // cs_get_user_tked(index); = 1 param
{
// Return 1 if user has committed a team killing)
// params[1] = user index
// Check player
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
return *((int *)pPlayer->pvPrivateData + OFFSET_TK);
}
// Damaged Soul
static cell AMX_NATIVE_CALL cs_set_user_tked(AMX *amx, cell *params) // cs_set_user_tked(index, tk = 1, subtract = 1); = 2 arguments
{
// Sets whether or not player has committed a TK.
// params[1] = user
// params[2] = 1: player has TKed, 0: player hasn't TKed
// params[3] = number of frags to subtract
// Check index
CHECK_PLAYER(params[1]);
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
if (params[2]) {
*((int *)pPlayer->pvPrivateData + OFFSET_TK) = 1;
} else {
*((int *)pPlayer->pvPrivateData + OFFSET_TK) = 0;
}
if (params[3]) {
pPlayer->v.frags = pPlayer->v.frags - params[3];
MESSAGE_BEGIN(MSG_ALL, GET_USER_MSG_ID(PLID, "ScoreInfo", NULL));
WRITE_BYTE(params[1]); // user index
WRITE_SHORT((int)pPlayer->v.frags); // frags
WRITE_SHORT(*((int *)pPlayer->pvPrivateData + OFFSET_CSDEATHS)); // deaths
WRITE_SHORT(0); // ?
WRITE_SHORT(*((int *)pPlayer->pvPrivateData + OFFSET_TEAM)); // team
MESSAGE_END();
}
return 1;
}
static cell AMX_NATIVE_CALL cs_get_user_driving(AMX *amx, cell *params) // cs_get_user_driving(index); = 1 param
{
// Returns different values depending on if user is driving a value - and if so at what speed.
// 0: no driving
// 1: driving, but standing still
// 2-4: different positive speeds
// 5: negative speed (backing)
// params[1] = user index
// Check player
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
// If player driving, return 1, if not, return 0
return *((int *)pPlayer->pvPrivateData + OFFSET_ISDRIVING);
}
static cell AMX_NATIVE_CALL cs_get_user_stationary(AMX *amx, cell *params) // cs_get_user_stationary(index); = 1 param
{
// Returns 1 if client is using a stationary guns (maybe also other stuff)
// Check player
CHECK_PLAYER(params[1]);
// Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
// If player driving, return 1, if not, return 0
#if !defined __amd64__
return *((int *)pPlayer->pvPrivateData + OFFSET_STATIONARY);
#else
// The 32 bit server return 0 and 1 by itself from this offset, but the amd64 server has 2 and 3 respectively
// Doing a simple checking of these defined constants here, and mapping to 0 and 1, to keep our plugin authors sane.
// If an unexpected value is encountered, this will be logged.
if (AMD64_STATIONARY_NO == *((int *)pPlayer->pvPrivateData + OFFSET_STATIONARY))
return 0;
else if (AMD64_STATIONARY_YES == *((int *)pPlayer->pvPrivateData + OFFSET_STATIONARY))
return 1;
else {
MF_LogError(amx, AMX_ERR_NATIVE, "Unexpected value at offset. Please report this to development team @ www.amxmodx.org!");
return 0;
}
#endif
}
AMX_NATIVE_INFO cstrike_Exports[] = {
{"cs_set_user_money", cs_set_user_money},
{"cs_get_user_money", cs_get_user_money},
@ -1188,11 +1384,6 @@ AMX_NATIVE_INFO cstrike_Exports[] = {
{"cs_get_user_hasprim", cs_get_user_hasprimary},
{"cs_get_no_knives", cs_get_no_knives},
{"cs_set_no_knives", cs_set_no_knives},
{"cs_get_weapon_id", cs_get_weapon_id},
{"cs_get_user_tked", cs_get_user_tked},
{"cs_set_user_tked", cs_set_user_tked},
{"cs_get_user_driving", cs_get_user_driving},
{"cs_get_user_stationary", cs_get_user_stationary},
//------------------- <-- max 19 characters!
{NULL, NULL}
};

View File

@ -46,60 +46,45 @@
#if defined __linux__
#define EXTRAOFFSET 5 // offsets 5 higher in Linux builds
#define EXTRAOFFSET_WEAPONS 4 // weapon offsets are obviously only 4 steps higher on Linux!
#else
#define EXTRAOFFSET 0 // no change in Windows builds
#define EXTRAOFFSET_WEAPONS 0
#endif // defined __linux__
/*
Offset history:
041029:
Confirmed (pretty much) ALL offsets for 32 bit Windows, 32 bit Linux and amd64 (yes that's all of them).
Found out that weapon offsets are only +4 higher on Linux.
Also backpack ammo offsets were all obviously 5 steps too high since unknown time...
*/
// "player" entities
#if !defined __amd64__
// 32 bit offsets here
#define OFFSET_TEAM 114 + EXTRAOFFSET
#define OFFSET_CSMONEY 115 + EXTRAOFFSET
#define OFFSET_PRIMARYWEAPON 116 + EXTRAOFFSET
#define OFFSET_INTERNALMODEL 126 + EXTRAOFFSET
#define OFFSET_NVGOGGLES 129 + EXTRAOFFSET
#define OFFSET_DEFUSE_PLANT 193 + EXTRAOFFSET
#define OFFSET_VIP 209 + EXTRAOFFSET
#define OFFSET_TK 216 + EXTRAOFFSET // 040926
#define OFFSET_BUYZONE 235 + EXTRAOFFSET
#define OFFSET_ISDRIVING 350 + EXTRAOFFSET // 040926
#define OFFSET_STATIONARY 362 + EXTRAOFFSET // 040927 (363 works also!)
#define OFFSET_VIP 215 + EXTRAOFFSET
#define OFFSET_BUYZONE 241 + EXTRAOFFSET
#define OFFSET_AWM_AMMO 377 + EXTRAOFFSET // 041029: All of these *_AMMO:s were changed -5
#define OFFSET_SCOUT_AMMO 378 + EXTRAOFFSET
#define OFFSET_PARA_AMMO 379 + EXTRAOFFSET
#define OFFSET_FAMAS_AMMO 380 + EXTRAOFFSET
#define OFFSET_M3_AMMO 381 + EXTRAOFFSET
#define OFFSET_USP_AMMO 382 + EXTRAOFFSET
#define OFFSET_FIVESEVEN_AMMO 383 + EXTRAOFFSET
#define OFFSET_DEAGLE_AMMO 384 + EXTRAOFFSET
#define OFFSET_P228_AMMO 385 + EXTRAOFFSET
#define OFFSET_GLOCK_AMMO 386 + EXTRAOFFSET
#define OFFSET_FLASH_AMMO 387 + EXTRAOFFSET
#define OFFSET_HE_AMMO 388 + EXTRAOFFSET
#define OFFSET_SMOKE_AMMO 389 + EXTRAOFFSET
#define OFFSET_C4_AMMO 390 + EXTRAOFFSET
#define OFFSET_AWM_AMMO 382 + EXTRAOFFSET
#define OFFSET_SCOUT_AMMO 383 + EXTRAOFFSET
#define OFFSET_PARA_AMMO 384 + EXTRAOFFSET
#define OFFSET_FAMAS_AMMO 385 + EXTRAOFFSET
#define OFFSET_M3_AMMO 386 + EXTRAOFFSET
#define OFFSET_USP_AMMO 387 + EXTRAOFFSET
#define OFFSET_FIVESEVEN_AMMO 388 + EXTRAOFFSET
#define OFFSET_DEAGLE_AMMO 389 + EXTRAOFFSET
#define OFFSET_P228_AMMO 390 + EXTRAOFFSET
#define OFFSET_GLOCK_AMMO 391 + EXTRAOFFSET
#define OFFSET_FLASH_AMMO 392 + EXTRAOFFSET
#define OFFSET_HE_AMMO 393 + EXTRAOFFSET
#define OFFSET_SMOKE_AMMO 394 + EXTRAOFFSET
#define OFFSET_C4_AMMO 395 + EXTRAOFFSET
#define OFFSET_CSDEATHS 444 + EXTRAOFFSET // 040926
#define OFFSET_CSDEATHS 449 + EXTRAOFFSET
// "weapon_*" entities
#define OFFSET_WEAPONTYPE 43 + EXTRAOFFSET_WEAPONS
#define OFFSET_CLIPAMMO 51 + EXTRAOFFSET_WEAPONS
#define OFFSET_SILENCER_FIREMODE 74 + EXTRAOFFSET_WEAPONS
#define OFFSET_WEAPONTYPE 43 + EXTRAOFFSET
#define OFFSET_CLIPAMMO 51 + EXTRAOFFSET
#define OFFSET_SILENCER_FIREMODE 74 + EXTRAOFFSET
// "hostage_entity" entities
#define OFFSET_HOSTAGEFOLLOW 86 + EXTRAOFFSET
#define OFFSET_HOSTAGEID 487 + EXTRAOFFSET
#else
// Amd64 offsets here
#define OFFSET_TEAM 139 + EXTRAOFFSET // +25
#define OFFSET_CSMONEY 140 + EXTRAOFFSET // +25
#define OFFSET_PRIMARYWEAPON 141 + EXTRAOFFSET // +25
@ -107,10 +92,7 @@
#define OFFSET_NVGOGGLES 155 + EXTRAOFFSET // +26
#define OFFSET_DEFUSE_PLANT 219 + EXTRAOFFSET // +26
#define OFFSET_VIP 242 + EXTRAOFFSET // +27
#define OFFSET_TK 249 + EXTRAOFFSET // +33 040927
#define OFFSET_BUYZONE 268 + EXTRAOFFSET // +27
#define OFFSET_ISDRIVING 386 + EXTRAOFFSET // 040927
#define OFFSET_STATIONARY 400 + EXTRAOFFSET // 040927 (401 works also)
#define OFFSET_AWM_AMMO 426 + EXTRAOFFSET // +44
#define OFFSET_SCOUT_AMMO 427 + EXTRAOFFSET // +44
@ -127,13 +109,13 @@
#define OFFSET_SMOKE_AMMO 438 + EXTRAOFFSET // +44
#define OFFSET_C4_AMMO 439 + EXTRAOFFSET // +44
#define OFFSET_CSDEATHS 493 + EXTRAOFFSET // +49
#define OFFSET_CSDEATHS 493 + EXTRAOFFSET // +44
// "weapon_*" entities
#define OFFSET_WEAPONTYPE 57 + EXTRAOFFSET // +14
#define OFFSET_CLIPAMMO 65 + EXTRAOFFSET // +14
#define OFFSET_SILENCER_FIREMODE 88 + EXTRAOFFSET // +14
// "hostage_entity" entities
#define OFFSET_HOSTAGEFOLLOW 51 + EXTRAOFFSET // +21, long=51, int=107! (must use the long* offset because pointers on amd64 are stored the size of longs, 8 bytes, instead of the usual int 4 bytes.)
#define OFFSET_HOSTAGEFOLLOW 51 + EXTRAOFFSET // +21, long=51, int=107! (must use the long* offset becuase pointers on amd64 are stored the size of longs, 8 bytes, instead of the usual int 4 bytes.)
#define OFFSET_HOSTAGEID 516 + EXTRAOFFSET // +29
#endif
@ -202,9 +184,6 @@
#define SCOREATTRIB_BOMB 2 // t only
#define SCOREATTRIB_VIP 4 // ct only
#define AMD64_STATIONARY_NO 2
#define AMD64_STATIONARY_YES 3
enum CS_Internal_Models {
CS_DONTCHANGE = 0,
CS_CT_URBAN = 1,
@ -223,46 +202,3 @@ CCstrikePlayer g_players[33];
bool g_precachedknife = false;
bool g_noknives = false;
// Globals above
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#define CHECK_PLAYER(x) \
if (x < 1 || x > gpGlobals->maxClients) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
} else { \
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
return 0; \
} \
}
#define CHECK_NONPLAYER(x) \
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \
return 0; \
} else { \
if (FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid non-player entity %d", x); \
return 0; \
} \
}
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))

View File

@ -118,8 +118,6 @@
TargetEnvironment="1"
TypeLibraryName=".\Release/cstrike.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
@ -214,9 +212,6 @@
RelativePath=".\moduleconfig.h">
</File>
</Filter>
<File
RelativePath="..\plugins\include\cstrike.inc">
</File>
</Files>
<Globals>
</Globals>

View File

@ -4,8 +4,8 @@
#define __MODULECONFIG_H__
// Module info
#define MODULE_NAME "CStrike"
#define MODULE_VERSION "1.00"
#define MODULE_NAME "Counter-Strike"
#define MODULE_VERSION "0.20"
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org"
#define MODULE_LOGTAG "CSTRIKE"

View File

@ -0,0 +1,61 @@
#if defined _csstats_included
#endinput
#endif
#define _csstats_included
/* Gets stats from given weapon index. If wpnindex is 0
* then the stats are from all weapons. If weapon has not been used function
* returns 0 in other case 1. Fields in stats are:
* 0 - kills
* 1 - deaths
* 2 - headshots
* 3 - teamkilling
* 4 - shots
* 5 - hits
* 6 - damage
* For body hits fields see amxconst.inc. */
native get_user_wstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets round stats from given weapon index.*/
native get_user_wrstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets overall stats which are stored in file on server
* and updated on every respawn or user disconnect.
* Function returns the position in stats by diff. kills to deaths. */
native get_user_stats(index,stats[8],bodyhits[8]);
/* Gets round stats of player. */
native get_user_rstats(index,stats[8],bodyhits[8]);
/* Gets stats with which user have killed/hurt his victim. If victim is 0
* then stats are from all victims. If victim has not been hurt, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_vstats(index,victim,stats[8],bodyhits[8],wpnname[]="",len=0);
/* Gets stats with which user have been killed/hurt. If killer is 0
* then stats are from all attacks. If killer has not hurt user, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_astats(index,wpnindex,stats[8],bodyhits[8],wpnname[]="",len=0);
/* Resets life, weapon, victims and attackers user stats. */
native reset_user_wstats(index);
/* Gets overall stats which stored in stats.dat file in amx folder
* and updated on every mapchange or user disconnect.
* Function returns next index of stats entry or 0 if no more exists. */
native get_stats(index,stats[8],bodyhits[8],name[],len);
/* Returns number of all entries in stats. */
native get_statsnum();
/*
* new stats:
* 0 - total defusions
* 1 - bomb defused
* 2 - bomb plants
* 3 - bomb explosions
*/
native get_user_stats2(index,stats[4]);
native get_stats2(index,stats[4]);

515
dlls/csx/plugins/miscstats.sma Executable file
View File

@ -0,0 +1,515 @@
/* AMX Mod X
* Misc. Stats Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/
#include <amxmodx>
public MultiKill
public MultiKillSound
public BombPlanting
public BombDefusing
public BombPlanted
public BombDefused
public BombFailed
public BombPickUp
public BombDrop
public BombCountVoice
public BombCountDef
public BombReached
public ItalyBonusKill
public EnemyRemaining
public LastMan
public KnifeKill
public KnifeKillSound
public GrenadeKill
public GrenadeSuicide
public HeadShotKill
public HeadShotKillSound
public RoundCounterSound
public RoundCounter
public KillingStreak
public KillingStreakSound
public DoubleKill
public DoubleKillSound
public PlayerName
public FirstBloodSound
new g_streakKills[33][2]
new g_multiKills[33][2]
new g_C4Timer
new g_Defusing
new g_Planter
new Float:g_LastOmg
new g_LastAnnounce
new g_roundCount
new Float:g_doubleKill
new g_doubleKillId
new g_friend[33]
new g_firstBlood
new g_MultiKillMsg[7][] = {
"Multi-Kill! %s^n%L %d kills (%d hs)",
"Ultra-Kill!!! %s^n%L %d kills (%d hs)",
"%s IS ON A KILLING SPREE!!!^n%L %d kills (%d hs)",
"RAMPAGE!!! %s^n%L %d kills (%d hs)" ,
"%s IS UNSTOPPABLE!!!^n%L %d kills (%d hs)",
"%s IS A MONSTER!^n%L %d kills (%d hs)",
"%s IS GODLIKE!!!!^n%L %d kills (%d hs)"
}
new g_Sounds[7][] = {
"multikill",
"ultrakill",
"killingspree",
"rampage",
"unstoppable",
"monsterkill",
"godlike"
}
new g_KillingMsg[7][] = {
"%s: Multi-Kill!",
"%s: Ultra-Kill!!!",
"%s IS ON A KILLING SPREE!!!",
"%s: RAMPAGE!!!",
"%s IS UNSTOPPABLE!!!",
"%s IS A MONSTER!",
"%s IS GODLIKE!!!"
}
new g_KinfeMsg[4][] = {
"KNIFE_MSG_1",
"KNIFE_MSG_2",
"KNIFE_MSG_3",
"KNIFE_MSG_4"
}
new g_LastMessages[4][] = {
"LAST_MSG_1",
"LAST_MSG_2",
"LAST_MSG_3",
"LAST_MSG_4"
}
new g_HeMessages[4][] = {
"HE_MSG_1",
"HE_MSG_2",
"HE_MSG_3",
"HE_MSG_4"
}
new g_SHeMessages[4][] = {
"SHE_MSG_1",
"SHE_MSG_2",
"SHE_MSG_3",
"SHE_MSG_4"
}
new g_HeadShots[7][] = {
"HS_MSG_1",
"HS_MSG_2",
"HS_MSG_3",
"HS_MSG_4",
"HS_MSG_5",
"HS_MSG_6",
"HS_MSG_7"
}
new g_teamsNames[4][] = {
"TERRORIST",
"CT",
"TERRORISTS",
"CTS"
}
public plugin_init() {
register_plugin("CS Misc. Stats",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("miscstats.txt")
register_event("TextMsg","eRestart","a","2&#Game_C","2&#Game_w")
register_event("SendAudio", "eEndRound", "a", "2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw")
register_event("RoundTime", "eNewRound", "bc")
register_event("StatusValue","setTeam","be","1=1")
register_event("StatusValue","showStatus","be","1=2","2!0")
register_event("StatusValue","hideStatus","be","1=1","2=0")
new mapname[32]
get_mapname(mapname,31)
if (equali(mapname,"de_",3)||equali(mapname,"csde_",5)) {
register_event("StatusIcon", "eGotBomb", "be", "1=1", "1=2", "2=c4")
register_event("TextMsg", "eBombPickUp", "bc", "2&#Got_bomb")
register_event("TextMsg", "eBombDrop", "bc", "2&#Game_bomb_d")
}
else if ( equali( mapname , "cs_italy" ) ) {
register_event( "23" , "chickenKill", "a" , "1=108" , /*"12=106",*/ "15=4" )
register_event( "23" , "radioKill", "a" , "1=108" , /*"12=294",*/ "15=2" )
}
}
public plugin_cfg() {
new g_addStast[] = "amx_statscfg add ^"%s^" %s"
server_cmd(g_addStast,"MultiKill","MultiKill")
server_cmd(g_addStast,"MultiKillSound","MultiKillSound")
server_cmd(g_addStast,"Bomb Planting","BombPlanting")
server_cmd(g_addStast,"Bomb Defusing","BombDefusing")
server_cmd(g_addStast,"Bomb Planted","BombPlanted")
server_cmd(g_addStast,"Bomb Defuse Succ.","BombDefused")
server_cmd(g_addStast,"Bomb Def. Failure","BombFailed")
server_cmd(g_addStast,"Bomb PickUp","BombPickUp")
server_cmd(g_addStast,"Bomb Drop","BombDrop")
server_cmd(g_addStast,"Bomb Count Down","BombCountVoice")
server_cmd(g_addStast,"Bomb Count Down (def)","BombCountDef")
server_cmd(g_addStast,"Bomb Site Reached","BombReached")
server_cmd(g_addStast,"Italy Bonus Kill","ItalyBonusKill")
server_cmd(g_addStast,"Last Man","LastMan")
server_cmd(g_addStast,"Knife Kill","KnifeKill")
server_cmd(g_addStast,"Knife Kill Sound","KnifeKillSound")
server_cmd(g_addStast,"Grenade Kill","GrenadeKill")
server_cmd(g_addStast,"Grenade Suicide","GrenadeSuicide")
server_cmd(g_addStast,"HeadShot Kill","HeadShotKill")
server_cmd(g_addStast,"HeadShot Kill Sound","HeadShotKillSound")
server_cmd(g_addStast,"Round Counter","RoundCounter")
server_cmd(g_addStast,"Round Counter Sound","RoundCounterSound")
server_cmd(g_addStast,"Killing Streak","KillingStreak")
server_cmd(g_addStast,"Killing Streak Sound","KillingStreakSound")
server_cmd(g_addStast,"Enemy Remaining","EnemyRemaining")
server_cmd(g_addStast,"Double Kill","DoubleKill")
server_cmd(g_addStast,"Double Kill Sound","DoubleKillSound")
server_cmd(g_addStast,"Player Name","PlayerName")
server_cmd(g_addStast,"First Blood Sound","FirstBloodSound")
}
public client_putinserver(id)
g_multiKills[id] = g_streakKills[ id ] = { 0 , 0 }
public client_death(killer,victim,wpnindex,hitplace,TK) {
new headshot = ( hitplace == HIT_HEAD ) ? 1:0
if ( g_firstBlood ) {
g_firstBlood = 0
if ( FirstBloodSound ) client_cmd(0,"spk misc/firstblood")
}
if ( (KillingStreak || KillingStreakSound) && !TK ) {
g_streakKills[ killer ][ 0 ]++
g_streakKills[ killer ][ 1 ] = 0
g_streakKills[ victim ][ 1 ]++
g_streakKills[ victim ][ 0 ] = 0
new a = g_streakKills[ killer ][ 0 ] - 3
if ( (a > -1) && !( a % 2 ) ) {
new name[32]
get_user_name( killer , name , 31 )
if ( (a >>= 1) > 6 ) a = 6
if ( KillingStreak ){
set_hudmessage(0, 100, 255, 0.05, 0.55, 2, 0.02, 6.0, 0.01, 0.1, 3)
show_hudmessage(0,g_KillingMsg[ a ], name )
}
if ( KillingStreakSound ) client_cmd( 0, "spk misc/%s", g_Sounds[ a ] )
}
}
if ( MultiKill || MultiKillSound ) {
if (killer && !TK ) {
g_multiKills[killer][0]++
g_multiKills[killer][1] += headshot
new param[2]
param[0] = killer
param[1] = g_multiKills[killer][0]
set_task( 4.0 + float( param[1] ) ,"checkKills",0,param,2)
}
}
if ( EnemyRemaining ) {
new ppl[32], pplnum
new team = get_user_team( victim ) - 1
get_players(ppl,pplnum,"e", g_teamsNames[1 - team] )
if (pplnum) {
new eppl[32], epplnum
get_players(eppl,epplnum,"ae",g_teamsNames[team])
if (epplnum) {
new message[128],team_name[32]
set_hudmessage(255,255,255,0.02,0.85,2, 0.05, 0.1, 0.02, 3.0, 3)
for(new a=0; a<pplnum; ++a){
format(team_name,31,"%L",ppl[a],(epplnum==1)?g_teamsNames[team]:g_teamsNames[team+2])
format(message,127,"%L",ppl[a],"REMAINING",epplnum,team_name)
show_hudmessage(ppl[a],message)
}
}
}
}
if ( LastMan ) {
new cts[32], ts[32], ctsnum, tsnum
get_players(cts,ctsnum,"ae", g_teamsNames[1] )
get_players(ts,tsnum,"ae", g_teamsNames[0] )
if ( ctsnum == 1 && tsnum == 1 ) {
new ctname[32], tname[32]
get_user_name(cts[0],ctname,31)
get_user_name(ts[0],tname,31)
set_hudmessage(0, 255, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 3)
show_hudmessage(0,"%s vs. %s",ctname,tname)
client_cmd(0,"spk misc/maytheforce")
}
else if ( !g_LastAnnounce ) {
new oposite = 0, team = 0
if ( ctsnum == 1 && tsnum > 1 ) {
g_LastAnnounce = cts[0]
oposite = tsnum
team = 0
}
else if ( tsnum == 1 && ctsnum > 1 ) {
g_LastAnnounce = ts[0]
oposite = ctsnum
team = 1
}
if (g_LastAnnounce) {
new name[32]
get_user_name(g_LastAnnounce,name,31)
set_hudmessage(0, 255, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 3)
show_hudmessage(0,"%s (%d HP) vs. %d %s%s: %L",name,
get_user_health(g_LastAnnounce),oposite,
g_teamsNames[team],(oposite==1)?"":"S",LANG_PLAYER,g_LastMessages[ random_num(0,3) ] )
client_cmd(g_LastAnnounce,"spk misc/oneandonly")
}
}
}
if ( wpnindex == 29 && ( KnifeKill || KnifeKillSound ) ) {
if ( KnifeKill ) {
new killer_name[32],victim_name[32]
get_user_name(killer,killer_name,31)
get_user_name(victim,victim_name,31)
set_hudmessage(255, 100, 100, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0,"%L",LANG_PLAYER,g_KinfeMsg[ random_num(0,3) ],killer_name,victim_name)
}
if ( KnifeKillSound ) client_cmd(0,"spk misc/humiliation")
}
if ( wpnindex == 4 && (GrenadeKill || GrenadeSuicide) ) {
new killer_name[32],victim_name[32]
get_user_name(killer,killer_name,32)
get_user_name(victim,victim_name,32)
set_hudmessage(255, 100, 100, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, 1)
if ( killer != victim ) {
if ( GrenadeKill ) show_hudmessage(0,"%L",LANG_PLAYER,g_HeMessages[ random_num(0,3)],killer_name,victim_name)
}
else if ( GrenadeSuicide ) show_hudmessage(0,"%L",LANG_PLAYER,g_SHeMessages[ random_num(0,3) ],victim_name)
}
if ( headshot && (HeadShotKill || HeadShotKillSound) ) {
if ( HeadShotKill ) {
new killer_name[32], victim_name[32], weapon_name[32], message[128], players[32], pnum
get_weaponname(wpnindex,weapon_name,31)
get_user_name(killer,killer_name,31)
get_user_name(victim,victim_name,31)
get_players(players,pnum,"c")
for (new i=0;i<pnum;i++) {
format( message, 127, "%L",players[i],g_HeadShots[ random_num(0,6) ] )
replace( message, 127 , "$vn", victim_name )
replace( message, 127 , "$wn", weapon_name )
replace( message, 127 , "$kn", killer_name )
set_hudmessage(100, 100, 255, -1.0, 0.29, 0, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(players[i],message )
}
}
if ( HeadShotKillSound ) {
client_cmd(killer,"spk misc/headshot")
client_cmd(victim,"spk misc/headshot")
}
}
if ( DoubleKill || DoubleKillSound ) {
new Float:nowtime = get_gametime()
if ( g_doubleKill == nowtime && g_doubleKillId == killer ) {
if ( DoubleKill ) {
new name[32]
get_user_name( killer , name , 31 )
set_hudmessage(255, 0, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 3)
show_hudmessage(0,"%L",LANG_PLAYER,"DOUBLE_KILL",name )
}
if ( DoubleKillSound ) client_cmd(0,"spk misc/doublekill")
}
g_doubleKill = nowtime
g_doubleKillId = killer
}
}
public hideStatus(id) {
if ( PlayerName ) {
set_hudmessage(0,0,0,0.0,0.0,0, 0.0, 0.01, 0.0, 0.0, 4)
show_hudmessage(id,"")
}
}
public setTeam(id)
g_friend[id] = read_data(2)
public showStatus(id) {
if ( PlayerName ) {
new name[32],pid = read_data(2)
get_user_name(pid,name,31)
new color1 = 0,color2 = 0
if ( get_user_team(pid)==1 )
color1 = 255
else
color2 = 255
if (g_friend[id]==1) { // friend
new clip, ammo, wpnid = get_user_weapon(pid,clip,ammo)
new wpnname[32]
get_weaponname(wpnid,wpnname,31)
set_hudmessage(color1,50,color2,-1.0,0.60,1, 0.01, 3.0, 0.01, 0.01, 4)
show_hudmessage(id,"%s -- %d HP / %d AP / %s",name,
get_user_health(pid),get_user_armor(pid),wpnname[7])
}
else {
set_hudmessage(color1,50,color2,-1.0,0.60,1, 0.01, 3.0, 0.01, 0.01, 4)
show_hudmessage(id,name)
}
}
}
public eNewRound()
if ( read_data(1) == floatround(get_cvar_float("mp_roundtime") * 60.0) ) {
g_firstBlood = 1
g_C4Timer = 0
++g_roundCount
if ( RoundCounter ) {
set_hudmessage(200, 0, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0, "%L", LANG_PLAYER, "PREPARE_FIGHT", g_roundCount )
}
if ( RoundCounterSound ) client_cmd( 0 , "spk misc/prepare" )
if ( KillingStreak ) {
new appl[32],ppl, i
get_players(appl,ppl, "ac" )
for (new a = 0; a < ppl; ++a) {
i = appl[ a ]
if ( g_streakKills[ i ][ 0 ] >= 2 )
client_print( i , print_chat , "* %L", i, "KILLED_ROW", g_streakKills[ i ][ 0 ] )
else if ( g_streakKills[ i ][ 1 ] >= 2 )
client_print( i , print_chat , "* %L", i, "DIED_ROUNDS", g_streakKills[ i ][ 1 ] )
}
}
}
public eRestart() {
eEndRound()
g_roundCount = 0
g_firstBlood = 1
}
public eEndRound() {
g_C4Timer = -2
g_LastOmg = 0.0
remove_task(8038)
g_LastAnnounce = 0
}
public checkKills(param[]) {
new id = param[0]
new a = param[1]
if (a == g_multiKills[id][0]) {
a -= 3
if ( a > -1 ) {
if ( MultiKill ) {
new name[32]
get_user_name(id,name,31)
set_hudmessage(255, 0, 100, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, 2)
if ( a > 6 ) a = 6
show_hudmessage(0,g_MultiKillMsg[a],name,LANG_PLAYER,"WITH",g_multiKills[id][0],g_multiKills[id][1])
}
if ( MultiKillSound ) client_cmd(0,"spk misc/%s",g_Sounds[a])
}
g_multiKills[id] = { 0,0 }
}
}
public chickenKill()
if ( ItalyBonusKill ) announceEvent( 0 , "KILLED_CHICKEN" )
public radioKill() {
if ( ItalyBonusKill ) announceEvent( 0 , "BLEW_RADIO" )
}
announceEvent( id, message[] ) {
new name[32]
get_user_name(id, name , 31)
set_hudmessage(255, 100, 50, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0,"%L",LANG_PLAYER,message,name)
}
public eBombPickUp(id)
if (BombPickUp) announceEvent(id , "PICKED_BOMB")
public eBombDrop()
if (BombDrop) announceEvent(g_Planter , "DROPPED_BOMB")
public eGotBomb(id) {
g_Planter = id
if ( BombReached && read_data(1)==2 && g_LastOmg<get_gametime()) {
g_LastOmg = get_gametime() + 15.0
announceEvent(g_Planter, "REACHED_TARGET" )
}
}
public bombTimer() {
if (--g_C4Timer > 0) {
if (BombCountVoice) {
if (g_C4Timer == 30 || g_C4Timer == 20) {
new temp[48]
num_to_word(g_C4Timer,temp,47)
client_cmd(0,"spk ^"vox/%s seconds until explosion^"",temp)
}
else if (g_C4Timer < 11) {
new temp[48]
num_to_word(g_C4Timer,temp,47)
client_cmd(0,"spk ^"vox/%s^"",temp)
}
}
if (BombCountDef && g_Defusing) client_print(g_Defusing,print_center,"%d",g_C4Timer)
}
else remove_task(8038)
}
public bomb_planted(planter){
g_Defusing = 0
if (BombPlanted) announceEvent(planter, "SET_UP_BOMB" )
g_C4Timer = get_cvar_num("mp_c4timer")
set_task(1.0,"bombTimer",8038,"",0,"b")
}
public bomb_planting(planter)
if (BombPlanting) announceEvent(planter, "PLANT_BOMB" )
public bomb_defusing(defuser){
if (BombDefusing) announceEvent(defuser, "DEFUSING_BOMB" )
g_Defusing = defuser
}
public bomb_defused(defuser)
if (BombDefused) announceEvent(defuser, "DEFUSED_BOMB" )
public bomb_explode(planter,defuser)
if (BombFailed && defuser) announceEvent(defuser , "FAILED_DEFU" )
public plugin_modules()
{
require_module("csx")
}

44
dlls/csx/plugins/miscstats.txt Executable file
View File

@ -0,0 +1,44 @@
[en]
WITH = with
KNIFE_MSG_1 = %s sliced and diced %s
KNIFE_MSG_2 = %s pulled out knife and gutted %s
KNIFE_MSG_3 = %s sneaks carefully behind and knifed %s
KNIFE_MSG_4 = %s knived %s
LAST_MSG_1 = Now all depend on you!
LAST_MSG_2 = I hope you still have a healthpack.
LAST_MSG_3 = All your teammates were killed. Good luck!
LAST_MSG_4 = Now you are alone. Have fun!
HE_MSG_1 = %s sends a little gift to %s
HE_MSG_2 = %s throws a small present to %s
HE_MSG_3 = %s made a precision throw to %s
HE_MSG_4 = %s got a big explosion for %s
SHE_MSG_1 = %s detonated himself with a grenade
SHE_MSG_2 = %s trys the effect of an HE Grenade
SHE_MSG_3 = %s swallows grenades whole!
SHE_MSG_4 = %s explodes!
HS_MSG_1 = $kn killed $vn with a well^nplaced shot to the head!
HS_MSG_2 = $kn removed $vn's^nhead with the $wn
HS_MSG_3 = $kn turned $vn's head^ninto pudding with the $wn
HS_MSG_4 = $vn got pwned by $kn
HS_MSG_5 = $vn's head has been^nturned into red jello
HS_MSG_6 = $kn has superb aim with the $wn,^nas $vn well knows.
HS_MSG_7 = $vn's head stayed in $kn's^ncrosshairs a bit too long...
DOUBLE_KILL = Wow! %s made a double kill!!!
PREPARE_FIGHT = Prepare to FIGHT!^nRound %d
KILLED_ROW = You've killed %d in a row so far
DIED_ROUNDS = Careful! You've died %d rounds in a row now...
KILLED_CHICKEN = Somebody killed a chicken!!!
BLEW_RADIO = Somebody blew up the radio!!!
REACHED_TARGET = Omg! %s reached the target!
PLANT_BOMB = %s is planting the bomb!
DEFUSING_BOMB = %s is defusing the bomb...
SET_UP_BOMB = %s set us up the bomb!!!
DEFUSED_BOMB = %s defused the bomb!
FAILED_DEFU = %s failed to defuse the bomb...
PICKED_BOMB = %s picked up the bomb...
DROPPED_BOMB = %s dropped the bomb!!!
CT = CT
CTS = CTS
TERRORIST = TERRORIST
TERRORISTS = TERRORISTS
REMAINING = %d %s Remaining...

1561
dlls/csx/plugins/statsx.sma Executable file

File diff suppressed because it is too large Load Diff

View File

@ -1,178 +0,0 @@
#!/usr/bin/perl
#(C)2004 AMX Mod X Development Team
# by David "BAILOPAN" Anderson
# output will occur in bin.x.proc
# where x is debug or opt and proc is ix86 or amd64
# You must use this script from the project src dir
#options =
# debug - enable gdb debugging
# amd64 - compile for AMD64
# proc=ix86 - assumed not amd64
# clean - clean the specifications above
$PROJECT = "csx_amxx";
$sdk = "../../../hlsdk/SourceCode";
$mm = "../../../metamod/metamod";
$gccf = "gcc";
@CPP_SOURCE_FILES = ("amxxmodule.cpp", "CMisc.cpp", "usermsg.cpp", "meta_api.cpp", "rank.cpp", "CRank.cpp");
@C_SOURCE_FILES = ();
my %OPTIONS, %OPT;
$OPT{"debug"} = "-g -ggdb";
$OPT{"opt"} = "-O2 -ffast-math -funroll-loops -fomit-frame-pointer -s -DNDEBUG -Wall -Wno-unknown-pragmas -DOPT_TYPE=\"optimized\" -fno-exceptions -fno-rtti";
$OPTIONS{"include"} = "-I$sdk -I. -I$mm -I$sdk/engine -I$sdk/common -I$sdk/pm_shared -I$sdk/dlls";
while ($cmd = shift)
{
if ($cmd =~ /amd64/) {
$OPTIONS{"amd64"} = 1;
} elsif ($cmd =~ /debug/) {
$OPTIONS{"debug"} = 1;
} elsif ($cmd =~ /proc=i(\d)86/) {
$proc = $1;
if ($OPTIONS{"amd64"})
{
die "You cannot compile for i".$proc."86 and AMD64.\n";
} else {
$OPTIONS{"proc"} = "i".$proc."86";
}
} elsif ($cmd =~ /clean/) {
$OPTIONS{"clean"} = 1;
}
}
$gcc = `$gccf --version`;
if ($gcc =~ /2\.9/)
{
$OPT{"opt"} .= " -malign-loops=2 -malign-jumps=2 -malign-functions=2";
} else {
$OPT{"opt"} .= " -falign-loops=2 -falign-jumps=2 -falign-functions=2";
}
if ($OPTIONS{"debug"})
{
$cflags = $OPT{"debug"};
} else {
if (!$OPTIONS{"amd64"})
{
$proc = $OPTIONS{"proc"};
if (!$proc)
{
$proc = 3;
}
$cflags = "-march=i".$proc."86 ".$OPT{"opt"};
} else {
$cflags = $OPT{"opt"};
}
}
if ($OPTIONS{"amd64"})
{
$cflags .= " -m64 -DHAVE_I64 -DSMALL_CELL_SIZE=64 $cflags";
}
if ($OPTIONS{"debug"})
{
$outdir = "bin.debug";
} else {
$outdir = "bin.opt";
}
if ($OPTIONS{"amd64"})
{
$outdir .= ".amd64";
$bin = $PROJECT."_amd64.so";
} else {
$proc = $OPTIONS{"proc"};
if ($proc)
{
$outdir .= ".i".$proc."86";
$bin = $PROJECT."_i".$proc."86.so";
} else {
$outdir .= ".i386";
$bin = $PROJECT."_i386.so";
}
}
unlink("$outdir/$bin");
if ($OPTIONS{"clean"})
{
`rm $outdir/*.o`;
die("Project cleaned.\n");
}
#create the dirs
#build link list
my @LINK;
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
{
$file = $CPP_SOURCE_FILES[$i];
$file =~ s/\.cpp/\.o/;
push(@LINK, $outdir."/".$file);
}
for ($i=0; $i<=$#C_SOURCE_FILES; $i++)
{
$file = $C_SOURCE_FILES[$i];
$file =~ s/\.c/\.o/;
push(@LINK, $outdir."/".$file);
}
if (!(-d $outdir))
{
mkdir($outdir);
}
$inc = $OPTIONS{"include"};
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
{
$file = $CPP_SOURCE_FILES[$i];
$ofile = $file;
$ofile =~ s/\.cpp/\.o/;
$ofile = "$outdir/$ofile";
$gcc = "$gccf $cflags -Dstrcmpi=strcasecmp -fPIC $inc -c $file -o $ofile";
if (-e $ofile)
{
$file_time = (stat($file))[9];
$ofile_time = (stat($ofile))[9];
if ($file_time > $ofile_time)
{
print "$gcc\n";
`$gcc`;
}
} else {
print "$gcc\n";
`$gcc`;
}
}
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
{
$file = $C_SOURCE_FILES[$i];
$ofile = $file;
$ofile =~ s/\.c/\.o/;
$ofile = "$outdir/$ofile";
$gcc = "cc $cflags -Dstrcmpi=strcasecmp -fPIC $inc -c $file -o $ofile";
if (-e $ofile)
{
$file_time = (stat($file))[9];
$ofile_time = (stat($ofile))[9];
if ($file_time > $ofile_time)
{
print "$gcc\n";
`$gcc`;
}
} else {
print "$gcc\n";
`$gcc`;
}
}
$gcc = "$gccf $cflags -shared -ldl -lm @LINK -o $outdir/$bin";
print "$gcc\n";
`$gcc`;

View File

@ -45,16 +45,6 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2124,7 +2114,6 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2142,7 +2131,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2165,7 +2154,6 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2183,7 +2171,6 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2208,7 +2195,6 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2226,7 +2212,6 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2296,11 +2281,6 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_
C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs)
{
if ( gpGamedllFuncs ){
LOG_ERROR(PLID,"gpGamedllFuncs already set");
return(FALSE);
}
if(now > Plugin_info.loadable) {
LOG_ERROR(PLID, "Can't load module right now");
return(FALSE);
@ -2459,14 +2439,11 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2476,7 +2453,6 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2549,7 +2525,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2585,8 +2560,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2598,7 +2572,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2656,18 +2629,6 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2688,14 +2649,11 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2706,7 +2664,6 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#if defined __LCC__ || defined __DMC__ || defined __linux__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,14 +1919,11 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1935,9 +1932,8 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1990,14 +1986,11 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2033,7 +2026,6 @@ extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2053,14 +2045,11 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2070,7 +2059,6 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2106,14 +2094,11 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2123,7 +2108,6 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2149,7 +2133,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format
#define MF_Format g_fn_Format;
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -110,18 +110,6 @@ const char* get_localinfo( const char* name , const char* def = 0 )
return b;
}
void ClientKill(edict_t *pEntity){
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
if ( !pPlayer->IsAlive())
RETURN_META(MRES_IGNORED);
MF_ExecuteForward( iFDamage,pPlayer->index , pPlayer->index , 0, 0, 0, 0 );
pPlayer->saveKill(pPlayer,0,0,0);
MF_ExecuteForward( iFDeath,pPlayer->index, pPlayer->index, 0, 0, 0 );
RETURN_META(MRES_IGNORED);
}
void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax ){
rankBots = (int)csstats_rankbots->value ? true:false;

View File

@ -5,8 +5,8 @@
// Module info
#define MODULE_NAME "CSX"
#define MODULE_VERSION "1.00"
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_VERSION "0.20"
#define MODULE_AUTHOR "AMXx Dev Team"
#define MODULE_URL "http://www.amxmodx.org/"
#define MODULE_LOGTAG "CSX"
// If you want the module not to be reloaded on mapchange, remove / comment out the next line
@ -70,7 +70,7 @@
// #define FN_ResetGlobalState ResetGlobalState /* pfnResetGlobalState() */
// #define FN_ClientConnect ClientConnect /* pfnClientConnect() (wd) Client has connected */
#define FN_ClientDisconnect ClientDisconnect /* pfnClientDisconnect() (wd) Player has left the game */
#define FN_ClientKill ClientKill /* pfnClientKill() (wd) Player has typed "kill" */
// #define FN_ClientKill ClientKill /* pfnClientKill() (wd) Player has typed "kill" */
// #define FN_ClientPutInServer ClientPutInServer /* pfnClientPutInServer() (wd) Client is entering the game */
// #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */
// #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */
@ -332,7 +332,7 @@
// #define FN_DropToFloor_Post DropToFloor_Post
// #define FN_WalkMove_Post WalkMove_Post
// #define FN_SetOrigin_Post SetOrigin_Post
#define FN_EmitSound_Post EmitSound_Post
// #define FN_EmitSound_Post EmitSound_Post
// #define FN_EmitAmbientSound_Post EmitAmbientSound_Post
#define FN_TraceLine_Post TraceLine_Post
// #define FN_TraceToss_Post TraceToss_Post

View File

@ -1,21 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "csx", "csx.vcproj", "{1DC4A99A-F23F-4AAE-881C-79D157C91155}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{1DC4A99A-F23F-4AAE-881C-79D157C91155}.Debug.ActiveCfg = Debug|Win32
{1DC4A99A-F23F-4AAE-881C-79D157C91155}.Debug.Build.0 = Debug|Win32
{1DC4A99A-F23F-4AAE-881C-79D157C91155}.Release.ActiveCfg = Release|Win32
{1DC4A99A-F23F-4AAE-881C-79D157C91155}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View File

@ -1,311 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="csx"
ProjectGUID="{1DC4A99A-F23F-4AAE-881C-79D157C91155}"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\release"
IntermediateDirectory=".\release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\metamod,..\..\sdk\common,..\..\sdk\engine,..\..\sdk\dlls"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;csx_EXPORTS;JIT"
StringPooling="TRUE"
RuntimeLibrary="0"
StructMemberAlignment="3"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\release/csx.pch"
AssemblerListingLocation=".\release/"
ObjectFile=".\release/"
ProgramDataBaseFileName=".\release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="release/csx_amxx.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\release/csx_amxx.pdb"
ImportLibrary=".\release/csx_amxx.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\release/csx.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\debug"
IntermediateDirectory=".\debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\metamod,..\..\sdk\common,..\..\sdk\engine,..\..\sdk\dlls,..\..\hlsdk\sourcecode\pm_shared"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;csx_EXPORTS"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\debug/csx.pch"
AssemblerListingLocation=".\debug/"
ObjectFile=".\debug/"
ProgramDataBaseFileName=".\debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="debug/csx_amxx.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\debug/csx_amxx.pdb"
ImportLibrary=".\debug/csx_amxx.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\debug/csx.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="..\amxxmodule.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\CMisc.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\CRank.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\meta_api.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\rank.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\usermsg.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csx_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="..\amxxmodule.h">
</File>
<File
RelativePath="..\CMisc.h">
</File>
<File
RelativePath="..\CRank.h">
</File>
<File
RelativePath="..\moduleconfig.h">
</File>
<File
RelativePath="..\rank.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -7,9 +7,15 @@
static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
CHECK_PLAYERRANGE(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int attacker = params[2];
CHECK_PLAYERRANGE(attacker);
if (attacker<0||attacker>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->attackers[attacker].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
@ -34,9 +40,15 @@ static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param *
static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
CHECK_PLAYERRANGE(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int victim = params[2];
CHECK_PLAYERRANGE(victim);
if (victim<0||victim>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->victims[victim].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
@ -61,10 +73,13 @@ static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param *
static cell AMX_NATIVE_CALL get_user_wrstats(AMX *amx, cell *params) /* 4 param */ // DEC-Weapon (round) stats (end)
{
int index = params[1];
CHECK_PLAYERRANGE(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[2];
if (weapon<0||weapon>=MAX_WEAPONS+MAX_CWEAPONS){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
if (weapon<0||weapon>=MAX_WEAPONS){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -89,10 +104,13 @@ static cell AMX_NATIVE_CALL get_user_wrstats(AMX *amx, cell *params) /* 4 param
static cell AMX_NATIVE_CALL get_user_wstats(AMX *amx, cell *params) /* 4 param */
{
int index = params[1];
CHECK_PLAYERRANGE(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[2];
if (weapon<0||weapon>=MAX_WEAPONS+MAX_CWEAPONS){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
if (weapon<0||weapon>=MAX_WEAPONS){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -117,7 +135,10 @@ static cell AMX_NATIVE_CALL get_user_wstats(AMX *amx, cell *params) /* 4 param *
static cell AMX_NATIVE_CALL reset_user_wstats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
GET_PLAYER_POINTER_I(index)->restartStats();
return 1;
}
@ -125,7 +146,10 @@ static cell AMX_NATIVE_CALL reset_user_wstats(AMX *amx, cell *params) /* 6 param
static cell AMX_NATIVE_CALL get_user_rstats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
CHECK_PLAYERRANGE(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->rank){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
@ -147,7 +171,10 @@ static cell AMX_NATIVE_CALL get_user_rstats(AMX *amx, cell *params) /* 3 param *
static cell AMX_NATIVE_CALL get_user_stats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
CHECK_PLAYERRANGE(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->rank ){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
@ -173,7 +200,10 @@ static cell AMX_NATIVE_CALL get_user_stats(AMX *amx, cell *params) /* 3 param */
static cell AMX_NATIVE_CALL get_user_stats2(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
CHECK_PLAYERRANGE(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->rank ){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
@ -267,25 +297,32 @@ static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params){ // name,melee
static cell AMX_NATIVE_CALL custom_wpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg,hp=0
int weapon = params[1];
if ( weapon < MAX_WEAPONS || weapon >= MAX_WEAPONS+MAX_CWEAPONS || !weaponData[weapon].used ){ // only for custom weapons
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_PrintSrvConsole("Weapon ID Is Not Valid!\n");
return 0;
}
int att = params[2];
CHECK_PLAYERRANGE(att);
if (att<1||att>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int vic = params[3];
CHECK_PLAYERRANGE(vic);
if (vic<1||vic>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int dmg = params[4];
if ( dmg<1 ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid damage %d", dmg);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int aim = params[5];
if ( aim < 0 || aim > 7 ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid aim %d", aim);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
@ -312,11 +349,15 @@ static cell AMX_NATIVE_CALL custom_wpn_dmg(AMX *amx, cell *params){ // wid,att,v
static cell AMX_NATIVE_CALL custom_wpn_shot(AMX *amx, cell *params){ // player,wid
int index = params[2];
CHECK_PLAYERRANGE(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[1];
if ( weapon < MAX_WEAPONS || weapon >= MAX_WEAPONS+MAX_CWEAPONS || !weaponData[weapon].used ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_PrintSrvConsole("Weapon ID Is Not Valid!\n");
return 0;
}
@ -329,7 +370,8 @@ static cell AMX_NATIVE_CALL custom_wpn_shot(AMX *amx, cell *params){ // player,w
static cell AMX_NATIVE_CALL get_wpnname(AMX *amx, cell *params){
int id = params[1];
if (id<1 || id>=MAX_WEAPONS+MAX_CWEAPONS ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_PrintSrvConsole("Weapon ID Is Not Valid!\n");
return 0;
}
return MF_SetAmxString(amx,params[2],weaponData[id].name,params[3]);
@ -338,7 +380,8 @@ static cell AMX_NATIVE_CALL get_wpnname(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_wpnlogname(AMX *amx, cell *params){
int id = params[1];
if (id<1 || id>=MAX_WEAPONS+MAX_CWEAPONS ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_PrintSrvConsole("Weapon ID Is Not Valid!\n");
return 0;
}
return MF_SetAmxString(amx,params[2],weaponData[id].logname,params[3]);
@ -347,7 +390,8 @@ static cell AMX_NATIVE_CALL get_wpnlogname(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL is_melee(AMX *amx, cell *params){
int id = params[1];
if (id<1 || id>=MAX_WEAPONS+MAX_CWEAPONS ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
MF_PrintSrvConsole("Weapon ID Is Not Valid!\n");
return 0;
}
if ( id == 29 )
@ -389,7 +433,7 @@ AMX_NATIVE_INFO stats_Natives[] = {
{ "xmod_get_stats_size", get_stats_size },
//***************************************
//{ "get_weaponname", get_wpnname },
{ "get_weaponname", get_wpnname },
///*******************
{ NULL, NULL }

View File

@ -1,3 +1,6 @@
#ifndef RANK_H
#define RANK_H
@ -96,56 +99,6 @@ void Client_BarTime(void*);
bool ignoreBots (edict_t *pEnt, edict_t *pOther = NULL );
bool isModuleActive();
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#define CHECK_PLAYER(x) \
if (x < 1 || x > gpGlobals->maxClients) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
} else { \
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
return 0; \
} \
}
#define CHECK_PLAYERRANGE(x) \
if (x > gpGlobals->maxClients || x < 0) \
{ \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
}
#define CHECK_NONPLAYER(x) \
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \
return 0; \
} else { \
if (FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid non-player entity %d", x); \
return 0; \
} \
}
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))
#endif // RANK_H

View File

@ -9,9 +9,8 @@ int weapon;
int aim;
CPlayer *pAttacker;
void Client_ResetHUD(void* mValue){
if ( mPlayer )
if ( mPlayer && mPlayer->IsAlive() )
mPlayer->clearStats = gpGlobals->time + 0.25f;
}

View File

@ -34,7 +34,10 @@
static cell AMX_NATIVE_CALL set_player_stamina(AMX *amx, cell *params){ // id,(re)set,min,max
int index = params[1];
CHECK_PLAYER(index)
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( params[2] ){ // 0 set , 1 reset
@ -46,12 +49,12 @@ static cell AMX_NATIVE_CALL set_player_stamina(AMX *amx, cell *params){ // id,(r
int min = params[3];
if ( min<0 || min>100 ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid minimum stamina %d", min);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int max = params[4];
if ( max<min || max>100 ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid maximum stamina %d", max);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
if ( pPlayer->ingame ){
@ -65,7 +68,10 @@ static cell AMX_NATIVE_CALL set_player_stamina(AMX *amx, cell *params){ // id,(r
static cell AMX_NATIVE_CALL nade_set_fuse(AMX *amx, cell *params){ // id,(re)set,time,type
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( params[2] ){ // 0 set , 1 reset
@ -76,7 +82,7 @@ static cell AMX_NATIVE_CALL nade_set_fuse(AMX *amx, cell *params){ // id,(re)set
float fFuse = *(float *)((void *)&params[3]);
if ( fFuse<0.1 || fFuse>20.0 ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid fuse %f", fFuse);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
@ -91,10 +97,30 @@ static cell AMX_NATIVE_CALL nade_set_fuse(AMX *amx, cell *params){ // id,(re)set
return 0;
}
static cell AMX_NATIVE_CALL dod_get_wpninfo(AMX *amx, cell *params){ // id
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
//weapon_data_t wdata;
//mm_DispatchThink(pPlayer->pEdict);
//mm_GetWeaponData(pPlayer->pEdict,&wdata);
//MF_PrintSrvConsole("%d \n",wdata.iuser1);
return 1;
}
AMX_NATIVE_INFO base_Natives[] = {
{ "dod_set_stamina", set_player_stamina },
{ "dod_set_fuse", nade_set_fuse },
{ "dod_get_wpninfo", dod_get_wpninfo },
///*******************
{ NULL, NULL }
};

View File

@ -34,7 +34,10 @@
static cell AMX_NATIVE_CALL set_user_class(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index)
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int iClass = params[2];
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -56,10 +59,13 @@ static cell AMX_NATIVE_CALL set_user_class(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL set_user_team(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int iTeam = params[2];
if ( iTeam<1 || iTeam>3 ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid team id %d", iTeam);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
@ -95,7 +101,10 @@ static cell AMX_NATIVE_CALL set_user_team(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_nextclass(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->ingame ){
@ -107,7 +116,10 @@ static cell AMX_NATIVE_CALL get_user_nextclass(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL is_randomclass(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->ingame ){
@ -118,17 +130,23 @@ static cell AMX_NATIVE_CALL is_randomclass(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_deaths(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
return *( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_DEATHS );
}
return -1;
return 0;
}
static cell AMX_NATIVE_CALL set_user_deaths(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
*( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_DEATHS ) = params[2];
@ -148,7 +166,10 @@ static cell AMX_NATIVE_CALL set_user_deaths(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL set_user_score(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
@ -169,42 +190,12 @@ static cell AMX_NATIVE_CALL set_user_score(AMX *amx, cell *params){
return 1;
}
static cell AMX_NATIVE_CALL set_user_frags(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
pPlayer->pEdict->v.frags = (float)params[2];
if ( params[3]){
//ScoreShort message
MESSAGE_BEGIN(MSG_ALL,gmsgScoreShort);
WRITE_BYTE(pPlayer->index);
WRITE_SHORT( *( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_SCORE ) );
WRITE_SHORT((int)pPlayer->pEdict->v.frags);
WRITE_SHORT( *( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_DEATHS ) );
WRITE_BYTE(1);
MESSAGE_END();
}
}
return 1;
}
static cell AMX_NATIVE_CALL get_user_frags(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame)
return (int)pPlayer->pEdict->v.frags;
return -1;
}
static cell AMX_NATIVE_CALL set_user_teamname(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -222,7 +213,10 @@ static cell AMX_NATIVE_CALL set_user_teamname(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_teamname(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -240,7 +234,10 @@ static cell AMX_NATIVE_CALL get_user_teamname(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL is_weapon_deployed(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
if ( *( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_WDEPLOY) == 1 )
@ -252,7 +249,10 @@ static cell AMX_NATIVE_CALL is_weapon_deployed(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL set_user_ammo(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( !pPlayer->ingame )
@ -356,7 +356,10 @@ static cell AMX_NATIVE_CALL set_user_ammo(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_ammo(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( !pPlayer->ingame )
@ -442,7 +445,10 @@ static cell AMX_NATIVE_CALL get_user_ammo(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL test_pd(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int type = params[2];
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
@ -481,9 +487,6 @@ AMX_NATIVE_INFO pd_Natives[] = {
{ "dod_get_user_ammo", get_user_ammo },
{ "dod_set_user_ammo", set_user_ammo },
{ "dod_get_user_kills", get_user_frags },
{ "dod_set_user_kills", set_user_frags },
{ "dod_test_pd", test_pd },
///*******************
{ NULL, NULL }

View File

@ -45,16 +45,6 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2124,7 +2114,6 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2142,7 +2131,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2165,7 +2154,6 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2183,7 +2171,6 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2208,7 +2195,6 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2226,7 +2212,6 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2296,11 +2281,6 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_
C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs)
{
if ( gpGamedllFuncs ){
LOG_ERROR(PLID,"gpGamedllFuncs already set");
return(FALSE);
}
if(now > Plugin_info.loadable) {
LOG_ERROR(PLID, "Can't load module right now");
return(FALSE);
@ -2459,14 +2439,11 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2476,7 +2453,6 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2549,7 +2525,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2585,8 +2560,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2598,7 +2572,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2656,18 +2629,6 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2688,14 +2649,11 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2706,7 +2664,6 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#if defined __LCC__ || defined __DMC__ || defined __linux__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,14 +1919,11 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1935,9 +1932,8 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1990,14 +1986,11 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2033,7 +2026,6 @@ extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2053,14 +2045,11 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2070,7 +2059,6 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2106,14 +2094,11 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2123,7 +2108,6 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2149,7 +2133,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format
#define MF_Format g_fn_Format;
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -58,49 +58,6 @@ extern CPlayer* mPlayer;
edict_t *FindEntityByClassname(edict_t *pentStart, const char *szName);
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#define CHECK_PLAYER(x) \
if (x < 1 || x > gpGlobals->maxClients) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
} else { \
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
return 0; \
} \
}
#define CHECK_NONPLAYER(x) \
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \
return 0; \
} else { \
if (FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid non-player entity %d", x); \
return 0; \
} \
}
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))
#endif // DODFUN_H

View File

@ -5,7 +5,7 @@
// Module info
#define MODULE_NAME "DoD Fun"
#define MODULE_VERSION "1.0"
#define MODULE_VERSION "0.1"
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org"
#define MODULE_LOGTAG "DODFUN"

View File

@ -35,7 +35,7 @@
static cell AMX_NATIVE_CALL get_weapon_name(AMX *amx, cell *params){ // from id to name 3 params id, name, len
int id = params[1];
if (id<0 || id>=DODMAX_WEAPONS){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
return MF_SetAmxString(amx,params[2],weaponData[id].name,params[3]);
@ -67,7 +67,7 @@ static cell AMX_NATIVE_CALL wpnlog_to_id(AMX *amx, cell *params){ // from log to
static cell AMX_NATIVE_CALL get_weapon_logname(AMX *amx, cell *params){ // from id to log
int id = params[1];
if (id<0 || id>=DODMAX_WEAPONS){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
return MF_SetAmxString(amx,params[2],weaponData[id].logname,params[3]);
@ -76,7 +76,7 @@ static cell AMX_NATIVE_CALL get_weapon_logname(AMX *amx, cell *params){ // from
static cell AMX_NATIVE_CALL is_melee(AMX *amx, cell *params){
int id = params[1];
if (id<0 || id>=DODMAX_WEAPONS){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", id);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
return weaponData[id].melee;
@ -97,7 +97,10 @@ static cell AMX_NATIVE_CALL get_team_score(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_score(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return -1;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame)
return pPlayer->savedScore;
@ -106,7 +109,10 @@ static cell AMX_NATIVE_CALL get_user_score(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_class(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame)
return pPlayer->pEdict->v.playerclass;
@ -115,7 +121,10 @@ static cell AMX_NATIVE_CALL get_user_class(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL user_kill(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame && pPlayer->IsAlive() ){
@ -138,7 +147,7 @@ static cell AMX_NATIVE_CALL get_map_info(AMX *amx, cell *params){
return g_map.detect_axis_paras;
break;
default:
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid map info id %d", params[1]);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
break;
}
return -1;
@ -146,7 +155,10 @@ static cell AMX_NATIVE_CALL get_map_info(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_pronestate(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame)
return pPlayer->pEdict->v.iuser3;
@ -156,7 +168,10 @@ static cell AMX_NATIVE_CALL get_user_pronestate(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params){
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
int wpn = pPlayer->current;
@ -175,31 +190,30 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward
#ifdef FORWARD_OLD_SYSTEM
int iFunctionIndex;
int err;
switch( params[1] ){
case 0:
if( (err=MF_AmxFindPublic(amx, "client_damage", &iFunctionIndex)) == AMX_ERR_NONE )
if( MF_AmxFindPublic(amx, "client_damage", &iFunctionIndex) == AMX_ERR_NONE )
g_damage_info.put( amx , iFunctionIndex );
else
MF_LogError(amx, err, "client_damage not found");
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
break;
case 1:
if( (err=MF_AmxFindPublic(amx, "client_death", &iFunctionIndex)) == AMX_ERR_NONE )
if( MF_AmxFindPublic(amx, "client_death", &iFunctionIndex) == AMX_ERR_NONE )
g_death_info.put( amx , iFunctionIndex );
else
MF_LogError(amx, err, "client_Death not found");
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
break;
case 2:
if( (err=MF_AmxFindPublic(amx, "client_score", &iFunctionIndex)) == AMX_ERR_NONE )
if( MF_AmxFindPublic(amx, "client_score", &iFunctionIndex) == AMX_ERR_NONE )
g_score_info.put( amx , iFunctionIndex );
else
MF_LogError(amx, err, "client_score not found");
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
break;
default:
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid forward id %d", params[2]);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
#endif
@ -234,25 +248,31 @@ static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params){ // name,logna
static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg,hp=0
int weapon = params[1];
if ( weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS ){ // only for custom weapons
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid custom weapon id %d", weapon);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int att = params[2];
CHECK_PLAYER(params[2]);
if (att<1||att>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int vic = params[3];
CHECK_PLAYER(params[3]);
if (vic<1||vic>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int dmg = params[4];
if ( dmg<1 ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid damage %d", dmg);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int aim = params[5];
if ( aim < 0 || aim > 7 ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid aim %d", aim);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
@ -286,17 +306,21 @@ static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg
MF_ExecuteForward( iFDeath,pAtt->index, pVic->index, weapon, aim, TA );
#endif
return 1;
}
static cell AMX_NATIVE_CALL cwpn_shot(AMX *amx, cell *params){ // player,wid
int index = params[2];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[1];
if ( weapon < DODMAX_WEAPONS-DODMAX_CUSTOMWPNS ){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid custom weapon id %d", weapon);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
@ -324,7 +348,10 @@ static cell AMX_NATIVE_CALL is_custom(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL dod_get_user_team(AMX *amx, cell *params){ // player,wid
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
return pPlayer->pEdict->v.team;
@ -333,7 +360,10 @@ static cell AMX_NATIVE_CALL dod_get_user_team(AMX *amx, cell *params){ // player
static cell AMX_NATIVE_CALL get_user_team(AMX *amx, cell *params){ // player,wid
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
int iTeam = pPlayer->pEdict->v.team;

View File

@ -35,9 +35,15 @@
static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
CHECK_PLAYERRANGE(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int attacker = params[2];
CHECK_PLAYERRANGE(attacker);
if (attacker<0||attacker>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->attackers[attacker].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
@ -62,9 +68,15 @@ static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param *
static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
CHECK_PLAYERRANGE(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int victim = params[2];
CHECK_PLAYERRANGE(victim);
if (victim<0||victim>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->victims[victim].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
@ -89,10 +101,13 @@ static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param *
static cell AMX_NATIVE_CALL get_user_wlstats(AMX *amx, cell *params) /* 4 param */ // DEC-Weapon (round) stats (end)
{
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[2];
if (weapon<0||weapon>=DODMAX_WEAPONS){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -118,10 +133,13 @@ static cell AMX_NATIVE_CALL get_user_wlstats(AMX *amx, cell *params) /* 4 param
static cell AMX_NATIVE_CALL get_user_wrstats(AMX *amx, cell *params) /* 4 param */ // DEC-Weapon (round) stats (end)
{
int index = params[1];
CHECK_PLAYER(index)
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[2];
if (weapon<0||weapon>=DODMAX_WEAPONS){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -147,10 +165,13 @@ static cell AMX_NATIVE_CALL get_user_wrstats(AMX *amx, cell *params) /* 4 param
static cell AMX_NATIVE_CALL get_user_wstats(AMX *amx, cell *params) /* 4 param */
{
int index = params[1];
CHECK_PLAYER(index)
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[2];
if (weapon<0||weapon>=DODMAX_WEAPONS){
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon id %d", weapon);
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
@ -176,7 +197,10 @@ static cell AMX_NATIVE_CALL get_user_wstats(AMX *amx, cell *params) /* 4 param *
static cell AMX_NATIVE_CALL reset_user_wstats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
pPlayer->restartStats();
return 1;
@ -185,7 +209,10 @@ static cell AMX_NATIVE_CALL reset_user_wstats(AMX *amx, cell *params) /* 6 param
static cell AMX_NATIVE_CALL get_user_stats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->ingame ){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
@ -210,7 +237,10 @@ static cell AMX_NATIVE_CALL get_user_stats(AMX *amx, cell *params) /* 3 param */
static cell AMX_NATIVE_CALL get_user_lstats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
CHECK_PLAYER(index);
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
@ -233,7 +263,10 @@ static cell AMX_NATIVE_CALL get_user_lstats(AMX *amx, cell *params) /* 3 param *
static cell AMX_NATIVE_CALL get_user_rstats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
CHECK_PLAYER(index)
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);

View File

@ -45,16 +45,6 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2124,7 +2114,6 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2142,7 +2131,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2165,7 +2154,6 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2183,7 +2171,6 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2208,7 +2195,6 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2226,7 +2212,6 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2296,11 +2281,6 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_
C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs)
{
if ( gpGamedllFuncs ){
LOG_ERROR(PLID,"gpGamedllFuncs already set");
return(FALSE);
}
if(now > Plugin_info.loadable) {
LOG_ERROR(PLID, "Can't load module right now");
return(FALSE);
@ -2459,14 +2439,11 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2476,7 +2453,6 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2549,7 +2525,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2585,8 +2560,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2598,7 +2572,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2656,18 +2629,6 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2688,14 +2649,11 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2706,7 +2664,6 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#if defined __LCC__ || defined __DMC__ || defined __linux__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,14 +1919,11 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1935,9 +1932,8 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1990,14 +1986,11 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2033,7 +2026,6 @@ extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2053,14 +2045,11 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2070,7 +2059,6 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2106,14 +2094,11 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2123,7 +2108,6 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2149,7 +2133,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format
#define MF_Format g_fn_Format;
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -111,54 +111,6 @@ bool ignoreBots (edict_t *pEnt, edict_t *pOther = NULL );
bool isModuleActive();
edict_t *FindEntityByClassname(edict_t *pentStart, const char *szName);
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#define CHECK_PLAYER(x) \
if (x < 1 || x > gpGlobals->maxClients) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
} else { \
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
return 0; \
} \
}
#define CHECK_PLAYERRANGE(x) \
if (x > gpGlobals->maxClients || x < 0) \
{ \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
}
#define CHECK_NONPLAYER(x) \
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \
return 0; \
} else { \
if (FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid non-player entity %d", x); \
return 0; \
} \
}
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))
#endif // DODX_H

View File

@ -5,7 +5,7 @@
// Module info
#define MODULE_NAME "DoDX"
#define MODULE_VERSION "1.0"
#define MODULE_VERSION "0.20"
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org"
#define MODULE_LOGTAG "DODX"

View File

@ -11,6 +11,17 @@ int AmxStringToEngine(AMX *amx, cell param, int &len)
return ALLOC_STRING(szString);
}
void EngineError(AMX *amx, char *fmt, ...)
{
va_list p;
va_start(p, fmt);
char errbuf[512];
vsprintf(errbuf, fmt, p);
va_end(p);
MF_Log("%s (\"%s\", line %d)", errbuf, MF_GetScriptName(MF_FindScriptByAmx(amx)), amx->curline);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
}
void ClearHooks()
{
register unsigned int i = 0;
@ -90,8 +101,8 @@ void OnPluginsLoaded()
g_pFunctionTable->pfnPlayerPostThink=PlayerPostThink_Post;
g_pFunctionTable->pfnSpawn=NULL; // "pfn_spawn"
//if (CheckForPublic("pfn_spawn")) // JGHG: I commented this if out because we always need the Spawn to precache the rocket mdl used with SetView native
g_pFunctionTable->pfnSpawn=Spawn;
if (CheckForPublic("pfn_spawn"))
g_pFunctionTable->pfnSpawn=Spawn;
g_pFunctionTable->pfnClientKill=NULL; // "client_kill"
if (CheckForPublic("client_kill"))
@ -229,7 +240,7 @@ void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
Msg.clear();
register int i = 0, j = 0;
for (i=0; i<256; i++) {
for (j=0; j<(int)msgHooks[i].size(); j++)
for (j=0; j<msgHooks[i].size(); j++)
if (msgHooks[i].at(j) != -1)
MF_UnregisterSPForward(msgHooks[i].at(j));
msgHooks[i].clear();

View File

@ -32,6 +32,8 @@
* Description: AMX Mod X Module Interface Functions
*/
#include <string.h>
#include <new>
#include <stdarg.h>
@ -51,9 +53,6 @@ DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
@ -2208,7 +2207,6 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2226,7 +2224,6 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2454,14 +2451,11 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2471,7 +2465,6 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2496,11 +2489,6 @@ PFN_CELL_TO_REAL g_fn_CellToReal;
PFN_REGISTER_SPFORWARD g_fn_RegisterSPForward;
PFN_REGISTER_SPFORWARD_BYNAME g_fn_RegisterSPForwardByName;
PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File;
PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format;
// *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2544,9 +2532,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
// Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2554,7 +2539,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("FindAmxScriptByName", g_fn_FindAmxScriptByName, PFN_FIND_AMXSCRIPT_BYNAME);
REQFUNC("LoadAmxScript", g_fn_LoadAmxScript, PFN_LOAD_AMXSCRIPT);
REQFUNC("UnloadAmxScript", g_fn_UnloadAmxScript, PFN_UNLOAD_AMXSCRIPT);
REQFUNC("GetAmxScriptName", g_fn_GetAmxScriptName, PFN_GET_AMXSCRIPTNAME);
REQFUNC("GetAmxScriptName", g_fn_GetAmxScriptName, PFN_GET_AMXSCRIPTNAME);
// String / mem in amx scripts support
REQFUNC("SetAmxString", g_fn_SetAmxString, PFN_SET_AMXSTRING);
@ -2568,7 +2553,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("amx_Execv", g_fn_AmxExecv, PFN_AMX_EXECV);
REQFUNC("amx_FindPublic", g_fn_AmxFindPublic, PFN_AMX_FINDPUBLIC);
REQFUNC("amx_Allot", g_fn_AmxAllot, PFN_AMX_ALLOT);
REQFUNC("amx_FindNative", g_fn_AmxFindNative, PFN_AMX_FINDNATIVE);
// Natives / Forwards
REQFUNC("AddNatives", g_fn_AddNatives, PFN_ADD_NATIVES);
@ -2580,8 +2564,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2593,7 +2576,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2603,8 +2585,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("IsPlayerHLTV", g_fn_IsPlayerHLTV, PFN_IS_PLAYER_HLTV);
REQFUNC("GetPlayerArmor", g_fn_GetPlayerArmor, PFN_GET_PLAYER_ARMOR);
REQFUNC("GetPlayerHealth", g_fn_GetPlayerHealth, PFN_GET_PLAYER_HEALTH);
REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS);
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
// Memory
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
@ -2651,18 +2631,6 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2683,14 +2651,11 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2701,7 +2666,6 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);
@ -2715,14 +2679,11 @@ void ValidateMacros_DontCallThis_Smiley()
MF_AmxExecv(0, 0, 0, 0, 0);
MF_AmxFindPublic(0, 0, 0);
MF_AmxAllot(0, 0, 0, 0);
MF_LoadAmxScript(0, 0, 0, 0, 0);
MF_LoadAmxScript(0, 0, 0, 0);
MF_UnloadAmxScript(0, 0);
MF_RegisterSPForward(0, 0, 0, 0, 0, 0);
MF_RegisterSPForwardByName(0, 0, 0, 0, 0, 0);
MF_UnregisterSPForward(0);
MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0);
MF_Format("", 4, "str");
}
#endif

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#if defined __LCC__ || defined __DMC__ || defined __linux__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,14 +1919,11 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1935,9 +1932,8 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1948,12 +1944,6 @@ typedef int (*PFN_IS_PLAYER_CONNECTING) (int /*id*/);
typedef int (*PFN_IS_PLAYER_HLTV) (int /*id*/);
typedef int (*PFN_GET_PLAYER_ARMOR) (int /*id*/);
typedef int (*PFN_GET_PLAYER_HEALTH) (int /*id*/);
#ifdef USE_METAMOD
typedef edict_t * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#else
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#endif
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
const unsigned int /*type*/, const size_t /*size*/);
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
@ -1965,7 +1955,7 @@ typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*in
typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/);
typedef int (*PFN_AMX_FINDPUBLIC) (AMX* /*amx*/, char* /*func name*/, int* /*index*/);
typedef int (*PFN_AMX_FINDNATIVE) (AMX* /*amx*/, char* /*func name*/, int* /*index*/);
typedef int (*PFN_LOAD_AMXSCRIPT) (AMX* /*amx*/, void** /*code*/, const char* /*path*/, char[64] /*error info*/, int /* debug */);
typedef int (*PFN_LOAD_AMXSCRIPT) (AMX* /*amx*/, void** /*code*/, const char* /*path*/, char[64] /*error info*/);
typedef int (*PFN_UNLOAD_AMXSCRIPT) (AMX* /*amx*/,void** /*code*/);
typedef cell (*PFN_REAL_TO_CELL) (REAL /*x*/);
typedef REAL (*PFN_CELL_TO_REAL) (cell /*x*/);
@ -1973,7 +1963,6 @@ typedef int (*PFN_REGISTER_SPFORWARD) (AMX * /*amx*/, int /*func*/, ... /*pa
typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*funcName*/, ... /*params*/);
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
@ -1990,14 +1979,11 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2031,9 +2017,6 @@ extern PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
extern PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File;
extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2053,14 +2036,11 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2070,7 +2050,6 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2087,8 +2066,6 @@ int MF_RegisterSPForwardByName (AMX * amx, const char *str, ...) { }
int MF_RegisterSPForward (AMX * amx, int func, ...) { }
void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { }
#endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives
@ -2106,14 +2083,11 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2123,7 +2097,6 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2148,8 +2121,6 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RegisterSPForward g_fn_RegisterSPForward
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -105,7 +105,10 @@ static cell AMX_NATIVE_CALL VelocityByAim(AMX *amx, cell *params)
cell *vRet = MF_GetAmxAddr(amx, params[3]);
Vector vVector = Vector(0, 0, 0);
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
@ -326,8 +329,8 @@ static cell AMX_NATIVE_CALL set_speak(AMX *amx, cell *params) {
int iIndex = params[1];
int iNewSpeakFlags = params[2];
if (iIndex > gpGlobals->maxClients || !MF_IsPlayerIngame(iIndex)) {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", iIndex);
if (iIndex> gpGlobals->maxClients || !is_ent_valid(iIndex)) {
EngineError(amx, "Invalid player %d", iIndex);
return 0;
}
@ -339,8 +342,8 @@ static cell AMX_NATIVE_CALL set_speak(AMX *amx, cell *params) {
static cell AMX_NATIVE_CALL get_speak(AMX *amx, cell *params) {
int iIndex = params[1];
if (iIndex > gpGlobals->maxClients || !MF_IsPlayerIngame(iIndex)) {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", iIndex);
if (!is_ent_valid(iIndex) || iIndex > gpGlobals->maxClients) {
EngineError(amx, "Invalid player %d", iIndex);
return 0;
}
@ -366,7 +369,10 @@ static cell AMX_NATIVE_CALL get_info_keybuffer(AMX *amx, cell *params)
{
int iEnt = params[1];
CHECK_ENTITY(iEnt);
if (FNullEnt(iEnt) || iEnt < 1 || iEnt > gpGlobals->maxClients) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *e = INDEXENT2(iEnt);
@ -381,7 +387,10 @@ static cell AMX_NATIVE_CALL drop_to_floor(AMX *amx, cell *params)
{
int iEnt = params[1];
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *e = INDEXENT2(iEnt);
@ -404,12 +413,15 @@ static cell AMX_NATIVE_CALL attach_view(AMX *amx, cell *params)
int iIndex = params[1];
int iTargetIndex = params[2];
if (iIndex > gpGlobals->maxClients || !MF_IsPlayerIngame(iIndex)) {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", iIndex);
if (iIndex > gpGlobals->maxClients || !is_ent_valid(iIndex)) {
EngineError(amx, "Invalid player %d", iIndex);
return 0;
}
CHECK_ENTITY(iIndex);
if (!is_ent_valid(iTargetIndex)) {
EngineError(amx, "Invalid Entity %d", iIndex);
return 0;
}
SET_VIEW(INDEXENT2(iIndex), INDEXENT2(iTargetIndex));
@ -423,8 +435,8 @@ static cell AMX_NATIVE_CALL set_view(AMX *amx, cell *params) {
int iIndex = params[1];
int iCameraType = params[2];
if (iIndex > gpGlobals->maxClients || !MF_IsPlayerIngame(iIndex)) {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", iIndex);
if (iIndex > gpGlobals->maxClients || !is_ent_valid(iIndex)) {
EngineError(amx, "Invalid player %d", iIndex);
return 0;
}

View File

@ -13,6 +13,8 @@
#include "entity.h"
#include "gpglobals.h"
//#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(INDEXENT2(x)) || x < 0 || x > gpGlobals->maxEntities)) { MF_RaiseAmxError(amx,AMX_ERR_NATIVE); return 0; }
extern DLL_FUNCTIONS *g_pFunctionTable;
extern DLL_FUNCTIONS *g_pFunctionTable_Post;
extern enginefuncs_t *g_pengfuncsTable;
@ -168,6 +170,8 @@ inline edict_t* INDEXENT2( int iEdictNum )
return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum);
}
void EngineError(AMX *amx, char *fmt, ...);
int Spawn(edict_t *pEntity);
void ChangeLevel(char* s1, char* s2);
void PlaybackEvent(int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2);
@ -180,23 +184,7 @@ void PlayerPostThink_Post(edict_t *pEntity);
void pfnTouch(edict_t *pToucher, edict_t *pTouched);
void Think(edict_t *pent);
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(INDEXENT2(x)) || x < 0 || x > gpGlobals->maxEntities)) { EngineError(amx, "Invalid entity %d", x); return 0; }
extern bool g_inKeyValue;
extern KeyValueData *g_pkvd;

View File

@ -5,18 +5,14 @@ int is_ent_valid(int iEnt)
if (iEnt < 1 || iEnt > gpGlobals->maxEntities)
return 0;
if (iEnt <= gpGlobals->maxClients)
{
if (iEnt >= 1 && iEnt <= gpGlobals->maxClients)
if (!MF_IsPlayerIngame(iEnt))
{
return 0;
}
} else {
if (FNullEnt(INDEXENT(iEnt)))
{
return 0;
}
}
edict_t *pEnt = INDEXENT2(iEnt);
if (FNullEnt(pEnt))
return 0;
return 1;
}
@ -30,8 +26,10 @@ static cell AMX_NATIVE_CALL entity_range(AMX *amx, cell *params)
int idxa = params[1];
int idxb = params[2];
CHECK_ENTITY(idxa);
CHECK_ENTITY(idxb);
if (!is_ent_valid(idxa) || !is_ent_valid(idxb)) {
EngineError(amx, "Invalid Entity");
return 0;
}
edict_t *pEntA = INDEXENT2(idxa);
edict_t *pEntB = INDEXENT2(idxb);
@ -49,7 +47,10 @@ static cell AMX_NATIVE_CALL call_think(AMX *amx, cell *params)
{
int iEnt = params[1];
CHECK_ENTITY(iEnt);
if (is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
@ -64,8 +65,10 @@ static cell AMX_NATIVE_CALL fake_touch(AMX *amx, cell *params)
int iPtr = params[1];
int iPtd = params[2];
CHECK_ENTITY(iPtr);
CHECK_ENTITY(iPtd);
if (!is_ent_valid(iPtr) || !is_ent_valid(iPtd)) {
EngineError(amx, "Invalid Entity");
return 0;
}
edict_t *pToucher = INDEXENT2(iPtr);
edict_t *pTouched = INDEXENT2(iPtd);
@ -80,8 +83,10 @@ static cell AMX_NATIVE_CALL force_use(AMX *amx, cell *params)
int iPtr = params[1];
int iPtd = params[2];
CHECK_ENTITY(iPtr);
CHECK_ENTITY(iPtd);
if (!is_ent_valid(iPtr) || !is_ent_valid(iPtd)) {
EngineError(amx, "Invalid Entity");
return 0;
}
edict_t *pUser = INDEXENT2(iPtr);
edict_t *pUsed = INDEXENT2(iPtd);
@ -134,7 +139,10 @@ static cell AMX_NATIVE_CALL DispatchKeyValue(AMX *amx, cell *params)
if (count == 3) {
cell *cVal = MF_GetAmxAddr(amx, params[1]);
int iValue = *cVal;
CHECK_ENTITY(iValue);
if (!is_ent_valid(iValue)) {
EngineError(amx, "Invalid Entity %d", iValue);
return 0;
}
edict_t *pEntity = INDEXENT2(iValue);
KeyValueData kvd;
int iLength=0;
@ -164,7 +172,10 @@ static cell AMX_NATIVE_CALL DispatchKeyValue(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_keyvalue(AMX *amx, cell *params)
{
int idx = params[1];
CHECK_ENTITY(idx);
if (!is_ent_valid(idx)) {
EngineError(amx, "Invalid Entity %d", idx);
return 0;
}
edict_t *pEntity = INDEXENT2(idx);
char *test = INFO_KEY_BUFFER(pEntity);
int iLength=0;
@ -191,7 +202,10 @@ static cell AMX_NATIVE_CALL DispatchSpawn(AMX *amx, cell *params)
{
int iEnt = params[1];
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
@ -210,7 +224,10 @@ static cell AMX_NATIVE_CALL entity_get_float(AMX *amx, cell *params)
int idx = params[2];
REAL fVal = 0;
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
@ -341,7 +358,10 @@ static cell AMX_NATIVE_CALL entity_set_float(AMX *amx, cell *params)
int idx = params[2];
REAL fVal = amx_ctof(params[3]);
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
@ -472,7 +492,10 @@ static cell AMX_NATIVE_CALL entity_get_int(AMX *amx, cell *params)
int idx = params[2];
int iRetValue = 0;
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
@ -590,7 +613,7 @@ static cell AMX_NATIVE_CALL entity_get_int(AMX *amx, cell *params)
iRetValue = pEnt->v.deadflag;
break;
default:
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid property %d", idx);
EngineError(amx, "Invalid property %d", iEnt);
return 0;
break;
}
@ -604,7 +627,10 @@ static cell AMX_NATIVE_CALL entity_set_int(AMX *amx, cell *params)
int idx = params[2];
int iNewValue = params[3];
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
@ -736,7 +762,10 @@ static cell AMX_NATIVE_CALL entity_get_vector(AMX *amx, cell *params)
cell *vRet = MF_GetAmxAddr(amx, params[3]);
Vector vRetValue = Vector(0, 0, 0);
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
@ -829,7 +858,10 @@ static cell AMX_NATIVE_CALL entity_set_vector(AMX *amx, cell *params)
int idx = params[2];
cell *vAmx = MF_GetAmxAddr(amx, params[3]);
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
REAL fX = amx_ctof(vAmx[0]);
REAL fY = amx_ctof(vAmx[1]);
@ -923,7 +955,10 @@ static cell AMX_NATIVE_CALL entity_get_string(AMX *amx, cell *params)
int iszString = 0;
const char *szRet = NULL;
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
@ -985,7 +1020,10 @@ static cell AMX_NATIVE_CALL entity_set_string(AMX *amx, cell *params)
int iLen;
int iszString = AmxStringToEngine(amx, params[3], iLen);
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
@ -1044,7 +1082,10 @@ static cell AMX_NATIVE_CALL entity_get_edict(AMX *amx, cell *params)
int idx = params[2];
edict_t *pRet;
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
@ -1100,9 +1141,10 @@ static cell AMX_NATIVE_CALL entity_set_edict(AMX *amx, cell *params)
int idx = params[2];
int iSetEnt = params[3];
CHECK_ENTITY(iEnt);
if (iSetEnt != 0)
CHECK_ENTITY(iSetEnt);
if (!is_ent_valid(iEnt) || !is_ent_valid(iSetEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
edict_t *pSetEnt = INDEXENT2(iSetEnt);
@ -1156,7 +1198,10 @@ static cell AMX_NATIVE_CALL entity_get_byte(AMX *amx, cell *params)
int idx = params[2];
int iRetValue = 0;
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
@ -1194,7 +1239,10 @@ static cell AMX_NATIVE_CALL entity_set_byte(AMX *amx, cell *params)
int idx = params[2];
int iNewValue = params[3];
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
if(iNewValue > 255)
iNewValue = 255;
@ -1206,22 +1254,22 @@ static cell AMX_NATIVE_CALL entity_set_byte(AMX *amx, cell *params)
switch (idx)
{
case controller1:
pEnt->v.controller[0] = iNewValue;
break;
case controller2:
pEnt->v.controller[1] = iNewValue;
break;
case controller3:
case controller2:
pEnt->v.controller[2] = iNewValue;
break;
case controller4:
case controller3:
pEnt->v.controller[3] = iNewValue;
break;
case controller4:
pEnt->v.controller[4] = iNewValue;
break;
case blending1:
pEnt->v.blending[0] = iNewValue;
pEnt->v.blending[1] = iNewValue;
break;
case blending2:
pEnt->v.blending[1] = iNewValue;
pEnt->v.blending[2] = iNewValue;
break;
default:
return 0;
@ -1235,7 +1283,10 @@ static cell AMX_NATIVE_CALL entity_set_origin(AMX *amx, cell *params)
{
int iEnt = params[1];
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
cell *vVector = MF_GetAmxAddr(amx, params[2]);
@ -1254,7 +1305,10 @@ static cell AMX_NATIVE_CALL entity_set_model(AMX *amx, cell *params)
{
int iEnt = params[1];
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
int iLen;
@ -1273,7 +1327,10 @@ static cell AMX_NATIVE_CALL entity_set_size(AMX *amx, cell *params)
{
int iEnt = params[1];
CHECK_ENTITY(iEnt);
if (!is_ent_valid(iEnt)) {
EngineError(amx, "Invalid Entity %d", iEnt);
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
@ -1354,7 +1411,10 @@ static cell AMX_NATIVE_CALL find_sphere_class(AMX *amx, cell *params) // find_sp
vec3_t vecOrigin;
if (params[1] > 0) {
CHECK_ENTITY(params[1]);
if (!is_ent_valid(params[1])) {
EngineError(amx, "Invalid Entity %d", params[1]);
return 0;
}
edict_t* pEntity = INDEXENT2(params[1]);
vecOrigin = pEntity->v.origin;
@ -1462,7 +1522,10 @@ static cell AMX_NATIVE_CALL find_ent_by_owner(AMX *amx, cell *params) // native
int iEnt = params[1];
int oEnt = params[3];
// Check index to start searching at, 0 must be possible for iEnt.
CHECK_ENTITY(oEnt);
if (!is_ent_valid(oEnt)) {
EngineError(amx, "Invalid Entity");
return 0;
}
edict_t *pEnt = INDEXENT2(iEnt);
edict_t *entOwner = INDEXENT2(oEnt);
@ -1497,7 +1560,10 @@ static cell AMX_NATIVE_CALL get_grenade_id(AMX *amx, cell *params) /* 4 param *
int index = params[1];
char* szModel;
CHECK_ENTITY(index);
if (!is_ent_valid(index)) {
EngineError(amx, "Invalid Entity %d", index);
return 0;
}
edict_t* pentFind = INDEXENT2(params[4]);
edict_t* pentOwner = INDEXENT2(index);

View File

@ -20,7 +20,6 @@ CVector<EntClass *> Thinks;
CVector<Touch *> Touches;
KeyValueData *g_pkvd;
bool g_inKeyValue=false;
bool g_precachedStuff = false;
int fstrcmp(const char *s1, const char *s2)
{
@ -38,11 +37,6 @@ int fstrcmp(const char *s1, const char *s2)
}
int Spawn(edict_t *pEntity) {
if (!g_precachedStuff) {
// Used for SetView, added by JGHG
int returnValue = PRECACHE_MODEL("models/rpgrocket.mdl");
g_precachedStuff = true;
}
if (SpawnForward != -1) {
int retVal = 0;
int id = ENTINDEX(pEntity);

View File

@ -2,6 +2,7 @@
CVector<argMsg*> Msg;
CVector<int> msgHooks[256];
//int msgHooks[256] = {0};
int msgBlocks[256] = {0};
int msgDest;
int msgType;
@ -93,7 +94,6 @@ void MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed)
{
if (msgBlocks[msg_type]) {
inblock = true;
msgType = msg_type;
RETURN_META(MRES_SUPERCEDE);
} else if (msgHooks[msg_type].size()) {
inhook = true;
@ -458,20 +458,12 @@ static cell AMX_NATIVE_CALL get_msg_origin(AMX *amx, cell *params)
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
vec3_t vRet = (Vector)msgOrigin;
cell *cAddr = MF_GetAmxAddr(amx, params[1]);
if (msgDest >= MSG_PVS && msgDest <= MSG_PAS_R)
{
vec3_t vRet = (Vector)msgOrigin;
cAddr[0] = amx_ftoc(vRet.x);
cAddr[1] = amx_ftoc(vRet.y);
cAddr[2] = amx_ftoc(vRet.z);
} else {
cAddr[0] = 0;
cAddr[1] = 0;
cAddr[2] = 0;
}
cAddr[0] = amx_ftoc(vRet.x);
cAddr[1] = amx_ftoc(vRet.y);
cAddr[2] = amx_ftoc(vRet.z);
return 1;
}

View File

@ -5,7 +5,7 @@
// Module info
#define MODULE_NAME "Engine"
#define MODULE_VERSION "1.00"
#define MODULE_VERSION "0.20"
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org"
#define MODULE_LOGTAG "ENGINE"

View File

@ -219,7 +219,8 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
default:
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown dllfunc entry %d", type);
MF_Log("Unknown dllfunc entry.");
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
}

View File

@ -11,7 +11,6 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
int len;
char *temp;
char *temp2;
char *temp3;
cell *cRet;
vec3_t Vec1;
vec3_t Vec2;
@ -948,12 +947,13 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
return 1;
case EngFunc_SetKeyValue: // void ) (char *infobuffer, char *key, char *value);
temp3 = MF_GetAmxString(amx, params[2], 0, &len);
temp = MF_GetAmxString(amx, params[3], 1, &len);
temp2 = MF_GetAmxString(amx, params[4], 2, &len);
(*g_engfuncs.pfnSetKeyValue)(temp3, temp, temp2);
cRet = MF_GetAmxAddr(amx,params[2]);
index = cRet[0];
CHECK_ENTITY(index);
temp = MF_GetAmxString(amx,params[3],0,&len);
temp2 = MF_GetAmxString(amx,params[4],1,&len);
(*g_engfuncs.pfnSetKeyValue)((*g_engfuncs.pfnGetInfoKeyBuffer)(INDEXENT2(index)),temp,temp2);
return 1;
case EngFunc_SetClientKeyValue: // void ) (int clientIndex, char *infobuffer, char *key, char *value);
cRet = MF_GetAmxAddr(amx,params[2]);
index = cRet[0];
@ -963,7 +963,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
(*g_engfuncs.pfnSetClientKeyValue)(index,(*g_engfuncs.pfnGetInfoKeyBuffer)(INDEXENT2(index)),temp,temp2);
return 1;
default:
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown engfunc type %d", type);
LOG_CONSOLE(PLID,"[NS2AMX] Unknown engfunc type provided.");
return 0;
}
}

View File

@ -19,27 +19,8 @@ inline edict_t* INDEXENT2( int iEdictNum )
else
return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum);
}
#ifdef DONT_TOUCH_THIS_AGAIN_BAIL
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#endif
#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(INDEXENT2(x)) || x < 0 || x > gpGlobals->maxEntities)) { MF_RaiseAmxError(amx,AMX_ERR_NATIVE); return 0; }
extern AMX_NATIVE_INFO engfunc_natives[];
extern AMX_NATIVE_INFO dllfunc_natives[];
extern AMX_NATIVE_INFO pev_natives[];

View File

@ -111,28 +111,6 @@ void TraceLine_post(const float *v1, const float *v2, int fNoMonsters, edict_t *
RETURN_META(MRES_IGNORED);
}
void AlertMessage(ALERT_TYPE atype, char *szFmt, ...)
{
static char buf[2048];
va_list ap;
va_start(ap, szFmt);
vsprintf(buf, szFmt, ap);
va_end(ap);
FM_ENG_HANDLE(FM_AlertMessage, (Engine[FM_AlertMessage].at(i), atype, buf));
RETURN_META(mswi(lastFmRes));
}
void AlertMessage_post(ALERT_TYPE atype, char *szFmt, ...)
{
static char buf[2048];
va_list ap;
va_start(ap, szFmt);
vsprintf(buf, szFmt, ap);
va_end(ap);
FM_ENG_HANDLE(FM_AlertMessage, (Engine[FM_AlertMessage].at(i), atype, buf));
RETURN_META(MRES_IGNORED);
}
// pfnModelIndex
SIMPLE_INT_HOOK_CONSTSTRING(ModelIndex);
@ -470,7 +448,7 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
int func = params[1];
// You originally had both post coming from params[2] AND the function name. I've moved post to 3.
int post = params[3];
if (func >= FM_LAST_DONT_USE_ME || func < 1)
if (func > FM_AllowLagCompensation || func < 1)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
@ -894,10 +872,7 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
ENGHOOK(IsMapValid);
break;
case FM_AlertMessage:
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_STRING, FP_DONE);
ENGHOOK(AlertMessage);
break;
/*
* Begin of DLLFuncs

View File

@ -1,7 +1,7 @@
#ifndef _INCLUDE_FORWARD_H
#define _INCLUDE_FORWARD_H
#define ENGFUNC_NUM 118
#define ENGFUNC_NUM 108
#define FMV_STRING 1
#define FMV_FLOAT 2
@ -13,7 +13,6 @@
#define FMRES_OVERRIDE 3
enum {
FM_FIRST_DONT_USE_ME = 0,
FM_PrecacheModel = 1, // done
FM_PrecacheSound, // done
FM_SetModel, // done
@ -149,8 +148,6 @@ enum {
// Create baselines for certain "unplaced" items.
FM_CreateInstancedBaselines, // done
FM_AllowLagCompensation, // done
FM_AlertMessage,
FM_LAST_DONT_USE_ME,
};
extern CVector<int> Engine[];

View File

@ -650,26 +650,14 @@
#define SIMPLE_VOID_HOOK_INT_INT_CONSTVECT_EDICT(call) \
void call (int v, int vb, const float *vec, edict_t *e) \
{ \
if (vec) { \
PREPARE_VECTOR(vec); \
FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i), v, vb, p_vec, ENTINDEX(e))); \
} else { \
const float b[3]={0.0,0.0,0.0}; \
PREPARE_VECTOR(b); \
FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i), v, vb, p_b, ENTINDEX(e))); \
} \
PREPARE_VECTOR(vec); \
FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i), v, vb, p_vec, ENTINDEX(e))); \
RETURN_META(mswi(lastFmRes)); \
} \
void call##_post (int v, int vb, const float *vec, edict_t *e) \
{ \
if (vec) { \
PREPARE_VECTOR(vec); \
FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i), v, vb, p_vec, ENTINDEX(e))); \
} else { \
const float b[3]={0.0,0.0,0.0}; \
PREPARE_VECTOR(b); \
FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i), v, vb, p_b, ENTINDEX(e))); \
} \
PREPARE_VECTOR(vec); \
FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i), v, vb, p_vec, ENTINDEX(e))); \
RETURN_META(MRES_IGNORED); \
}
#define SIMPLE_BOOL_HOOK_EDICT_CONSTSTRING_CONSTSTRING_STRING128(call) \

View File

@ -4,23 +4,20 @@
static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params)
{
int index=params[1];
#ifdef DONT_TOUCH_THIS_AGAIN_BAIL
if (index >= 1 && index <= gpGlobals->maxClients)
{
if (!MF_IsPlayerIngame(index))
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not in game", index);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
} else {
if (index > gpGlobals->maxEntities || index < 1)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", index);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
}
#endif
CHECK_ENTITY(index);
edict_t *pPlayer = INDEXENT2(index);
int returntype = *params/sizeof(cell);
int valuetype=0;
@ -39,8 +36,6 @@ static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params)
valuetype=VALUETYPE_BYTE;
else if (iSwitch > pev_string_start && iSwitch < pev_string_end)
valuetype=VALUETYPE_STRING;
else if (iSwitch > pev_edict_start && iSwitch < pev_edict_end)
valuetype=VALUETYPE_EDICT;
if (iSwitch > pev_int_start && iSwitch < pev_int_end)
{
valuetype=VALUETYPE_INT;
@ -506,7 +501,8 @@ static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params)
{
return (int)fReturn;
}
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid return valuetype for pev().");
MF_Log("Invalid return valuetype for pev().");
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
else if (returntype == RETURNTYPE_FLOAT)
@ -556,7 +552,8 @@ static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params)
return 1;
}
}
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid return valuetype for pev().");
MF_Log("Invalid return valuetype for pev().");
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
}
else if (returntype == RETURNTYPE_STRING)
{
@ -613,7 +610,8 @@ static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params)
return 1;
}
}
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid return valuetype for pev().");
MF_Log("Invalid return valuetype for pev().");
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
}
return 0;
}
@ -625,6 +623,7 @@ static cell AMX_NATIVE_CALL amx_set_pev(AMX *amx, cell *params)
CHECK_ENTITY(index);
edict_t *pPlayer = INDEXENT2(index);
int iSwitch = params[2];
cell *blah = MF_GetAmxAddr(amx,params[3]);
if (iSwitch > pev_int_start && iSwitch < pev_int_end)
{
@ -919,38 +918,37 @@ static cell AMX_NATIVE_CALL amx_set_pev(AMX *amx, cell *params)
}
else if (iSwitch > pev_edict_start && iSwitch < pev_edict_end)
{
int iValue = blah[0];
switch (iSwitch)
{
case chain:
pPlayer->v.chain = INDEXENT2(iValue);
pPlayer->v.chain = INDEXENT2(params[3]);
return 1;
case dmg_inflictor:
pPlayer->v.dmg_inflictor = INDEXENT2(iValue);
pPlayer->v.dmg_inflictor = INDEXENT2(params[3]);
return 1;
case enemy:
pPlayer->v.enemy = INDEXENT2(iValue);
pPlayer->v.enemy = INDEXENT2(params[3]);
return 1;
case aiment:
pPlayer->v.aiment = INDEXENT2(iValue);
pPlayer->v.aiment = INDEXENT2(params[3]);
return 1;
case owner:
pPlayer->v.owner = INDEXENT2(iValue);
pPlayer->v.owner = INDEXENT2(params[3]);
return 1;
case groundentity:
pPlayer->v.groundentity = INDEXENT2(iValue);
pPlayer->v.groundentity = INDEXENT2(params[3]);
return 1;
case euser1:
pPlayer->v.euser1 = INDEXENT2(iValue);
pPlayer->v.euser1 = INDEXENT2(params[3]);
return 1;
case euser2:
pPlayer->v.euser2 = INDEXENT2(iValue);
pPlayer->v.euser2 = INDEXENT2(params[3]);
return 1;
case euser3:
pPlayer->v.euser3 = INDEXENT2(iValue);
pPlayer->v.euser3 = INDEXENT2(params[3]);
return 1;
case euser4:
pPlayer->v.euser4 = INDEXENT2(iValue);
pPlayer->v.euser4 = INDEXENT2(params[3]);
return 1;
default:
return 0;

View File

@ -39,22 +39,20 @@
#include <stdio.h>
#include "amxxmodule.h"
/************* METAMOD SUPPORT *************/
#ifdef USE_METAMOD
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
/************* METAMOD SUPPORT *************/
#ifdef USE_METAMOD
enginefuncs_t g_engfuncs;
DLL_FUNCTIONS *gameDLLFunc;
globalvars_t *gpGlobals;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2124,6 +2122,7 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
// Mark down the pointer to this mod's function tables...
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2142,6 +2141,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
// Mark down the pointer to this mod's function tables...
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2165,6 +2165,7 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
// Mark down the pointer to this mod's function tables...
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2183,6 +2184,7 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
// Mark down the pointer to this mod's function tables...
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
@ -2208,7 +2210,6 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2226,7 +2227,6 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2454,14 +2454,11 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2471,7 +2468,6 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2496,11 +2492,6 @@ PFN_CELL_TO_REAL g_fn_CellToReal;
PFN_REGISTER_SPFORWARD g_fn_RegisterSPForward;
PFN_REGISTER_SPFORWARD_BYNAME g_fn_RegisterSPForwardByName;
PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File;
PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format;
// *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2544,9 +2535,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
// Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2554,7 +2542,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("FindAmxScriptByName", g_fn_FindAmxScriptByName, PFN_FIND_AMXSCRIPT_BYNAME);
REQFUNC("LoadAmxScript", g_fn_LoadAmxScript, PFN_LOAD_AMXSCRIPT);
REQFUNC("UnloadAmxScript", g_fn_UnloadAmxScript, PFN_UNLOAD_AMXSCRIPT);
REQFUNC("GetAmxScriptName", g_fn_GetAmxScriptName, PFN_GET_AMXSCRIPTNAME);
// String / mem in amx scripts support
REQFUNC("SetAmxString", g_fn_SetAmxString, PFN_SET_AMXSTRING);
@ -2568,7 +2555,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("amx_Execv", g_fn_AmxExecv, PFN_AMX_EXECV);
REQFUNC("amx_FindPublic", g_fn_AmxFindPublic, PFN_AMX_FINDPUBLIC);
REQFUNC("amx_Allot", g_fn_AmxAllot, PFN_AMX_ALLOT);
REQFUNC("amx_FindNative", g_fn_AmxFindNative, PFN_AMX_FINDNATIVE);
// Natives / Forwards
REQFUNC("AddNatives", g_fn_AddNatives, PFN_ADD_NATIVES);
@ -2580,8 +2566,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2593,7 +2578,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2603,8 +2587,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("IsPlayerHLTV", g_fn_IsPlayerHLTV, PFN_IS_PLAYER_HLTV);
REQFUNC("GetPlayerArmor", g_fn_GetPlayerArmor, PFN_GET_PLAYER_ARMOR);
REQFUNC("GetPlayerHealth", g_fn_GetPlayerHealth, PFN_GET_PLAYER_HEALTH);
REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS);
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
// Memory
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
@ -2651,18 +2633,6 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2683,14 +2653,11 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2701,7 +2668,6 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);
@ -2720,9 +2686,6 @@ void ValidateMacros_DontCallThis_Smiley()
MF_RegisterSPForward(0, 0, 0, 0, 0, 0);
MF_RegisterSPForwardByName(0, 0, 0, 0, 0, 0);
MF_UnregisterSPForward(0);
MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0);
MF_Format("", 4, "str");
}
#endif
@ -2839,7 +2802,7 @@ void *operator new(size_t reportedSize)
return ptr;
// allocation failed
return NULL;
}
void *operator new[](size_t reportedSize)
@ -2852,7 +2815,7 @@ void *operator new[](size_t reportedSize)
return ptr;
// allocation failed
return NULL;
}
// Microsoft memory tracking operators
@ -2866,7 +2829,7 @@ void *operator new(size_t reportedSize, const char *sourceFile, int sourceLine)
return ptr;
// allocation failed
return NULL;
}
void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine)
{
@ -2878,7 +2841,7 @@ void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine
return ptr;
// allocation failed
return NULL;
}
void operator delete(void *reportedAddress)
@ -2930,7 +2893,6 @@ void operator delete[](void *reportedAddress)
#include <extdll.h>
#include "sdk_util.h"
#include <cbase.h>
#include <string.h> // for strncpy(), etc
@ -2967,76 +2929,4 @@ void UTIL_LogPrintf( char *fmt, ... )
}
void UTIL_HudMessage(CBaseEntity *pEntity, const hudtextparms_t &textparms,
const char *pMessage)
{
if ( !pEntity )
return;
MESSAGE_BEGIN( MSG_ONE, SVC_TEMPENTITY, NULL, ENT(pEntity->pev) );
WRITE_BYTE( TE_TEXTMESSAGE );
WRITE_BYTE( textparms.channel & 0xFF );
WRITE_SHORT( FixedSigned16( textparms.x, 1<<13 ) );
WRITE_SHORT( FixedSigned16( textparms.y, 1<<13 ) );
WRITE_BYTE( textparms.effect );
WRITE_BYTE( textparms.r1 );
WRITE_BYTE( textparms.g1 );
WRITE_BYTE( textparms.b1 );
WRITE_BYTE( textparms.a1 );
WRITE_BYTE( textparms.r2 );
WRITE_BYTE( textparms.g2 );
WRITE_BYTE( textparms.b2 );
WRITE_BYTE( textparms.a2 );
WRITE_SHORT( FixedUnsigned16( textparms.fadeinTime, 1<<8 ) );
WRITE_SHORT( FixedUnsigned16( textparms.fadeoutTime, 1<<8 ) );
WRITE_SHORT( FixedUnsigned16( textparms.holdTime, 1<<8 ) );
if ( textparms.effect == 2 )
WRITE_SHORT( FixedUnsigned16( textparms.fxTime, 1<<8 ) );
if ( strlen( pMessage ) < 512 )
{
WRITE_STRING( pMessage );
}
else
{
char tmp[512];
strncpy( tmp, pMessage, 511 );
tmp[511] = 0;
WRITE_STRING( tmp );
}
MESSAGE_END();
}
short FixedSigned16( float value, float scale )
{
int output;
output = (int) (value * scale);
if ( output > 32767 )
output = 32767;
if ( output < -32768 )
output = -32768;
return (short)output;
}
unsigned short FixedUnsigned16( float value, float scale )
{
int output;
output = (int) (value * scale);
if ( output < 0 )
output = 0;
if ( output > 0xFFFF )
output = 0xFFFF;
return (unsigned short)output;
}
#endif // USE_METAMOD

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#if defined __LCC__ || defined __DMC__ || defined __linux__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,14 +1919,11 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1935,9 +1932,8 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1948,12 +1944,6 @@ typedef int (*PFN_IS_PLAYER_CONNECTING) (int /*id*/);
typedef int (*PFN_IS_PLAYER_HLTV) (int /*id*/);
typedef int (*PFN_GET_PLAYER_ARMOR) (int /*id*/);
typedef int (*PFN_GET_PLAYER_HEALTH) (int /*id*/);
#ifdef USE_METAMOD
typedef edict_t * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#else
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#endif
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
const unsigned int /*type*/, const size_t /*size*/);
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
@ -1973,7 +1963,6 @@ typedef int (*PFN_REGISTER_SPFORWARD) (AMX * /*amx*/, int /*func*/, ... /*pa
typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*funcName*/, ... /*params*/);
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
@ -1990,14 +1979,11 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2031,9 +2017,6 @@ extern PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
extern PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File;
extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2053,14 +2036,11 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2070,7 +2050,6 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2087,8 +2066,6 @@ int MF_RegisterSPForwardByName (AMX * amx, const char *str, ...) { }
int MF_RegisterSPForward (AMX * amx, int func, ...) { }
void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { }
#endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives
@ -2106,14 +2083,11 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2123,7 +2097,6 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2148,8 +2121,6 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RegisterSPForward g_fn_RegisterSPForward
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -5,7 +5,7 @@
// Module info
#define MODULE_NAME "FakeMeta"
#define MODULE_VERSION "1.00"
#define MODULE_VERSION "0.20"
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org"
#define MODULE_LOGTAG "FAKEMETA"

View File

@ -45,16 +45,6 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2124,7 +2114,6 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2142,7 +2131,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2165,7 +2154,6 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2183,7 +2171,6 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2208,7 +2195,6 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2226,7 +2212,6 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2454,14 +2439,11 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2471,7 +2453,6 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2544,7 +2525,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2580,8 +2560,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2593,7 +2572,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2651,18 +2629,6 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2683,14 +2649,11 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2701,7 +2664,6 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#if defined __LCC__ || defined __DMC__ || defined __linux__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,14 +1919,11 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1935,9 +1932,8 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1990,14 +1986,11 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2033,7 +2026,6 @@ extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2053,14 +2045,11 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2070,7 +2059,6 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2106,14 +2094,11 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2123,7 +2108,6 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2149,7 +2133,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format
#define MF_Format g_fn_Format;
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -47,11 +47,20 @@
// params[2] = argument2 <--- use the ones in params[n] directly, to save some time.
// Check receiver and sender validity. <--- Check ents, maybe need to do this better and more proper later?
CHECK_PLAYER(params[1])
CHECK_PLAYER(params[2])
if (params[1] < 1 || params[1] > gpGlobals->maxClients
|| params[2] < 1 || params[2] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE); <--- Call this, it will end up as RUN TIME ERROR 10 in server console.
return 0; <--- Standard return 0 with run time errors? (note in small only 0 returns false, everything else returns true)
}
// Get * pointer.
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); <--- Players require a different function than INDEXENT because of an HLSDK bug
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) { <--- Test this pointer this way, return 0...
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
return 1 <--- If native succeeded, return 1, if the native isn't supposed to return a specific value.
Note: Should be able to do: if (thenative()) and it should return false when it fails, and true when succeeds... is -1 treated as false, or is 0 a must?
@ -89,8 +98,12 @@ static cell AMX_NATIVE_CALL get_client_listening(AMX *amx, cell *params) // get_
// params[2] = sender
// Check receiver and sender validity.
CHECK_PLAYER(params[1]);
CHECK_PLAYER(params[2]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients
|| params[2] < 1 || params[2] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// GET- AND SETCLIENTLISTENING returns "qboolean", an int, probably 0 or 1...
return GETCLIENTLISTENING(params[1], params[2]);
@ -104,8 +117,12 @@ static cell AMX_NATIVE_CALL set_client_listening(AMX *amx, cell *params) // set_
// params[3] = listen
// Check receiver and sender validity.
CHECK_PLAYER(params[1]);
CHECK_PLAYER(params[2]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients
|| params[2] < 1 || params[2] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Make a check on params[3] here later, and call run time error when it's wrong.
// To do: find out the possible values to set (0, 1?)
@ -121,10 +138,19 @@ static cell AMX_NATIVE_CALL set_user_godmode(AMX *amx, cell *params) // set_user
// params[2] = godmode = 0
// Check index.
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Get player pointer.
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
if (params[2] == 1) {
// Enable godmode
@ -144,10 +170,19 @@ static cell AMX_NATIVE_CALL get_user_godmode(AMX *amx, cell *params) // get_user
// params[1] = index
// Check index.
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Get player pointer.
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
int godmode = 0;
@ -168,10 +203,20 @@ static cell AMX_NATIVE_CALL give_item(AMX *amx, cell *params) // native give_ite
// params[2] = item...
// Check index.
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Get player pointer.
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check entity validity
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Create item entity pointer
edict_t *pItemEntity;
@ -194,8 +239,8 @@ static cell AMX_NATIVE_CALL give_item(AMX *amx, cell *params) // native give_ite
// Create the entity, returns to pointer
pItemEntity = CREATE_NAMED_ENTITY(item);
if (FNullEnt(pItemEntity)) {
MF_LogError(amx, AMX_ERR_NATIVE, "Item \"%s\" failed to create", szItem);
if(FNullEnt(pItemEntity)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -233,9 +278,18 @@ static cell AMX_NATIVE_CALL spawn(AMX *amx, cell *params) // spawn(id) = 1 param
// Spawns an entity, this can be a user/player -> spawns at spawnpoints, or created entities seems to need this as a final "kick" into the game? :-)
// params[1] = entity to spawn
CHECK_ENTITY(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxEntities)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t *pEnt = INDEXENT(params[1]);
edict_t *pEnt = GETEDICT(params[1]);
// Check entity validity
if (FNullEnt(pEnt)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
MDLL_Spawn(pEnt);
@ -249,10 +303,19 @@ static cell AMX_NATIVE_CALL set_user_health(AMX *amx, cell *params) // set_user_
// params[2] = health
// Check index
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Kill if health too low.
if (params[2] > 0)
@ -270,10 +333,19 @@ static cell AMX_NATIVE_CALL set_user_frags(AMX *amx, cell *params) // set_user_f
// params[2] = frags
// Check index
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
pPlayer->v.frags = params[2];
@ -287,10 +359,19 @@ static cell AMX_NATIVE_CALL set_user_armor(AMX *amx, cell *params) // set_user_a
// params[2] = armor
// Check index
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
pPlayer->v.armorvalue = params[2];
@ -304,10 +385,19 @@ static cell AMX_NATIVE_CALL set_user_origin(AMX *amx, cell *params) // set_user_
// params[2] = origin
// Check index
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
cell *newVectorCell = MF_GetAmxAddr(amx, params[2]);
@ -329,10 +419,19 @@ static cell AMX_NATIVE_CALL set_user_rendering(AMX *amx, cell *params) // set_us
// params[7] = amount
// Check index
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
pPlayer->v.renderfx = params[2];
Vector newVector = Vector(float(params[3]), float(params[4]), float(params[5]));
@ -353,10 +452,19 @@ static cell AMX_NATIVE_CALL set_user_maxspeed(AMX *amx, cell *params) // set_use
REAL fNewSpeed = amx_ctof(params[2]);
// Check index
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
SETCLIENTMAXSPEED(pPlayer, fNewSpeed);
pPlayer->v.maxspeed = fNewSpeed;
@ -370,10 +478,19 @@ static cell AMX_NATIVE_CALL get_user_maxspeed(AMX *amx, cell *params) // Float:g
// params[1] = index
// Check index
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
return amx_ftoc(pPlayer->v.maxspeed);
}
@ -384,10 +501,19 @@ static cell AMX_NATIVE_CALL set_user_gravity(AMX *amx, cell *params) // set_user
// params[1] = index
// params[2] = gravity (=-1.0)
// Check index
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
pPlayer->v.gravity = amx_ctof(params[2]);
@ -400,10 +526,19 @@ static cell AMX_NATIVE_CALL get_user_gravity(AMX *amx, cell *params) // Float:ge
// params[1] = index
// Check index
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
return amx_ftoc(pPlayer->v.gravity);
}
@ -413,12 +548,16 @@ static cell AMX_NATIVE_CALL set_user_hitzones(AMX *amx, cell *params) // set_use
// Sets user hitzones.
// params[1] = the one(s) who shoot(s), shooter
int shooter = params[1];
if (shooter == -1)
shooter = 0;
// params[2] = the one getting hit
int gettingHit = params[2];
if (gettingHit == -1)
gettingHit = 0;
// params[3] = specified hit zones
int hitzones = params[3];
if (hitzones == -1)
hitzones = 255;
//set_user_hitzones(id, 0, 0) // Makes ID not able to shoot EVERYONE - id can shoot on 0 (all) at 0
//set_user_hitzones(0, id, 0) // Makes EVERYONE not able to shoot ID - 0 (all) can shoot id at 0
@ -432,7 +571,10 @@ static cell AMX_NATIVE_CALL set_user_hitzones(AMX *amx, cell *params) // set_use
else {
if (shooter == 0) {
// "All" shooters, target (gettingHit) should be existing player id
CHECK_PLAYER(gettingHit);
if (gettingHit < 1 || gettingHit > gpGlobals->maxClients) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Where can gettingHit get hit by all?
g_zones_getHit[gettingHit] = hitzones;
}
@ -454,16 +596,27 @@ static cell AMX_NATIVE_CALL get_user_hitzones(AMX *amx, cell *params) // get_use
int gettingHit = params[2];
if (shooter) {
if (shooter < 1 || shooter > gpGlobals->maxClients) {
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", shooter);
if (FNullEnt(shooter)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
return g_zones_toHit[shooter];
}
else {
CHECK_PLAYER(gettingHit);
return g_zones_getHit[gettingHit];
if (!gettingHit) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
else {
if (FNullEnt(gettingHit)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
else {
return g_zones_getHit[gettingHit];
}
}
}
}
@ -474,10 +627,20 @@ static cell AMX_NATIVE_CALL set_user_noclip(AMX *amx, cell *params) // set_user_
// params[2] = no clip or not...
// Check index
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check validity.
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
if (params[2] == 1)
pPlayer->v.movetype = MOVETYPE_NOCLIP;
@ -493,10 +656,20 @@ static cell AMX_NATIVE_CALL get_user_noclip(AMX *amx, cell *params) // get_user_
// params[1] = index
// Check index
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check validity.
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
return pPlayer->v.movetype == MOVETYPE_NOCLIP;
}
@ -510,10 +683,20 @@ static cell AMX_NATIVE_CALL set_user_footsteps(AMX *amx, cell *params) // set_us
// params[2] = 0 = normal footstep sound, 1 = silent slippers
// Check index
CHECK_PLAYER(params[1]);
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
// Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
edict_t *pPlayer = INDEXENT(params[1]);
// Check validity.
if (FNullEnt(pPlayer)) {
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
if (params[2]) {
pPlayer->v.flTimeStepSound = 999;
@ -529,9 +712,13 @@ static cell AMX_NATIVE_CALL set_user_footsteps(AMX *amx, cell *params) // set_us
// SidLuke
static cell AMX_NATIVE_CALL strip_user_weapons(AMX *amx, cell *params) { // index
CHECK_PLAYER(params[1]);
if (!MF_IsPlayerIngame(params[1]))
{
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
edict_t* pPlayer = MF_GetPlayerEdict(params[1]);
edict_t* pPlayer = INDEXENT(params[1]);
string_t item = MAKE_STRING("trigger_once");
edict_t *pent = CREATE_NAMED_ENTITY( item );

View File

@ -60,35 +60,3 @@ bool g_ResetHUDbool;
edict_t* g_edict;
//bool g_bot[33]; // is user bot? <--- removed, only needed with akimbot
// Globals above
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#define CHECK_PLAYER(x) \
if (x < 1 || x > gpGlobals->maxClients) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
} else { \
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
return 0; \
} \
}
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))

View File

@ -5,7 +5,7 @@
// Module info
#define MODULE_NAME "Fun"
#define MODULE_VERSION "1.00"
#define MODULE_VERSION "0.20"
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org"
#define MODULE_LOGTAG "FUN"

Binary file not shown.

View File

@ -5,9 +5,9 @@
// Module info
#define MODULE_NAME "GeoIP"
#define MODULE_VERSION "1.00"
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org/"
#define MODULE_VERSION "1.1"
#define MODULE_AUTHOR "BAILOPAN"
#define MODULE_URL "http://www.bailopan.com/"
#define MODULE_LOGTAG "GEOIP"
// If you want the module not to be reloaded on mapchange, remove / comment out the next line
//#define MODULE_RELOAD_ON_MAPCHANGE
@ -29,7 +29,7 @@
// Do native functions init here (MF_AddNatives)
#define FN_AMXX_ATTACH OnAmxxAttach
// AMXX dettach
#define FN_AMXX_DETACH OnAmxxDetach
#define FN_AMXX_DETTACH OnAmxxDettach
// All plugins loaded
// Do forward functions init here (MF_RegisterForward)
// #define FN_AMXX_PLUGINSLOADED OnPluginsLoaded

View File

@ -45,16 +45,6 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2124,7 +2114,6 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2142,7 +2131,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2165,7 +2154,6 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2183,7 +2171,6 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2208,7 +2195,6 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2226,7 +2212,6 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2454,14 +2439,11 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2471,7 +2453,6 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2498,9 +2479,7 @@ PFN_REGISTER_SPFORWARD_BYNAME g_fn_RegisterSPForwardByName;
PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File;
PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
// *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2544,9 +2523,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
// Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2580,8 +2557,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2593,7 +2569,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2604,7 +2579,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerArmor", g_fn_GetPlayerArmor, PFN_GET_PLAYER_ARMOR);
REQFUNC("GetPlayerHealth", g_fn_GetPlayerHealth, PFN_GET_PLAYER_HEALTH);
REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS);
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
// Memory
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
@ -2651,18 +2625,6 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2683,14 +2645,11 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2701,7 +2660,6 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);
@ -2715,17 +2673,16 @@ void ValidateMacros_DontCallThis_Smiley()
MF_AmxExecv(0, 0, 0, 0, 0);
MF_AmxFindPublic(0, 0, 0);
MF_AmxAllot(0, 0, 0, 0);
MF_LoadAmxScript(0, 0, 0, 0, 0);
MF_LoadAmxScript(0, 0, 0, 0);
MF_UnloadAmxScript(0, 0);
MF_RegisterSPForward(0, 0, 0, 0, 0, 0);
MF_RegisterSPForwardByName(0, 0, 0, 0, 0, 0);
MF_UnregisterSPForward(0);
MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0);
MF_Format("", 4, "str");
}
#endif
#ifdef MEMORY_TEST
/************* MEMORY *************/
// undef all defined macros
#undef new
@ -2839,7 +2796,7 @@ void *operator new(size_t reportedSize)
return ptr;
// allocation failed
return NULL;
throw std::bad_alloc();
}
void *operator new[](size_t reportedSize)
@ -2852,7 +2809,7 @@ void *operator new[](size_t reportedSize)
return ptr;
// allocation failed
return NULL;
throw std::bad_alloc();
}
// Microsoft memory tracking operators
@ -2866,7 +2823,7 @@ void *operator new(size_t reportedSize, const char *sourceFile, int sourceLine)
return ptr;
// allocation failed
return NULL;
throw std::bad_alloc();
}
void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine)
{
@ -2878,7 +2835,7 @@ void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine
return ptr;
// allocation failed
return NULL;
throw std::bad_alloc();
}
void operator delete(void *reportedAddress)
@ -2897,6 +2854,8 @@ void operator delete[](void *reportedAddress)
Mem_Deallocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_delete_array, reportedAddress);
}
#endif //MEMORY_TEST
/************* stuff from dlls/util.cpp *************/
// must come here because cbase.h declares it's own operator new

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#if defined __LCC__ || defined __DMC__ || defined __linux__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,14 +1919,11 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1935,9 +1932,8 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1948,12 +1944,6 @@ typedef int (*PFN_IS_PLAYER_CONNECTING) (int /*id*/);
typedef int (*PFN_IS_PLAYER_HLTV) (int /*id*/);
typedef int (*PFN_GET_PLAYER_ARMOR) (int /*id*/);
typedef int (*PFN_GET_PLAYER_HEALTH) (int /*id*/);
#ifdef USE_METAMOD
typedef edict_t * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#else
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#endif
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
const unsigned int /*type*/, const size_t /*size*/);
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
@ -1973,7 +1963,6 @@ typedef int (*PFN_REGISTER_SPFORWARD) (AMX * /*amx*/, int /*func*/, ... /*pa
typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*funcName*/, ... /*params*/);
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
@ -1990,14 +1979,11 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2031,9 +2017,6 @@ extern PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
extern PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File;
extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2053,14 +2036,11 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2070,7 +2050,6 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2087,8 +2066,6 @@ int MF_RegisterSPForwardByName (AMX * amx, const char *str, ...) { }
int MF_RegisterSPForward (AMX * amx, int func, ...) { }
void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { }
#endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives
@ -2106,14 +2083,11 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2123,7 +2097,6 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2148,8 +2121,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RegisterSPForward g_fn_RegisterSPForward
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format
#ifdef MEMORY_TEST
/*** Memory ***/
void *operator new(size_t reportedSize);
@ -2194,4 +2167,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
#define realloc(ptr,sz) Mem_Reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr)
#define free(ptr) Mem_Deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr)
#endif //MEMORY_TEST
#endif // #ifndef __AMXXMODULE_H__

View File

@ -6,8 +6,8 @@
// Module info
#define MODULE_NAME "MSSQL"
#define MODULE_VERSION "1.0"
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org/"
#define MODULE_AUTHOR "BAILOPAN"
#define MODULE_URL "http://www.bailopan.com/"
#define MODULE_LOGTAG "MSSQL"
// If you want the module not to be reloaded on mapchange, remove / comment out the next line
#define MODULE_RELOAD_ON_MAPCHANGE

View File

@ -72,7 +72,7 @@ static cell AMX_NATIVE_CALL sql_connect(AMX *amx, cell *params) // 6 param
i = 0;
if (!strlen(host) || !strlen(user) || !strlen(dbname)) {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter supplied");
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return -1;
}
@ -116,7 +116,7 @@ static cell AMX_NATIVE_CALL sql_error(AMX *amx, cell *params) // 3 params
unsigned int id = params[1]-1;
if (id >= DBList.size() || DBList[id]->isFree)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid connection %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -146,7 +146,8 @@ static cell AMX_NATIVE_CALL sql_query(AMX *amx, cell *params) // 2 params
unsigned int id = params[1]-1;
if (id >= DBList.size() || DBList[id]->isFree) {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid Database Handle %d", id);
MF_Log("Invalid Database Handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return -1;
}
@ -169,7 +170,8 @@ static cell AMX_NATIVE_CALL sql_nextrow(AMX *amx, cell *params) // 1 param
if (id >= Results.size() || Results[id]->isFree)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
MF_Log("Invalid result handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -186,7 +188,8 @@ static cell AMX_NATIVE_CALL sql_close(AMX *amx, cell *params) // 1 param
{
unsigned int id = params[1]-1;
if (id >= DBList.size() || DBList[id]->isFree) {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid Database Handle %d", id);
MF_Log("Invalid Database Handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -207,7 +210,8 @@ static cell AMX_NATIVE_CALL sql_getfield(AMX *amx, cell *params) // 2-4 params
if (id >= Results.size() || Results[id]->isFree)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
MF_Log("Invalid result handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -217,7 +221,7 @@ static cell AMX_NATIVE_CALL sql_getfield(AMX *amx, cell *params) // 2-4 params
const char *field = Result->GetField(id);
if (field == NULL)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -251,7 +255,8 @@ static cell AMX_NATIVE_CALL sql_getresult(AMX *amx, cell *params) // 4 params
if (id >= Results.size() || Results[id]->isFree)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
MF_Log("Invalid result handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -263,7 +268,7 @@ static cell AMX_NATIVE_CALL sql_getresult(AMX *amx, cell *params) // 4 params
const char *field = Result->GetField(id);
if (field == NULL)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column \"%s\"", column);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -293,7 +298,8 @@ static cell AMX_NATIVE_CALL sql_free_result(AMX *amx, cell *params)
if (id >= Results.size() || Results[id]->isFree)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
MF_Log("Invalid result handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -310,7 +316,8 @@ static cell AMX_NATIVE_CALL sql_num_rows(AMX *amx, cell *params)
if (id >= Results.size() || Results[id]->isFree)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid result handle %d", id);
MF_Log("Invalid result handle %d", id);
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
return 0;
}

View File

@ -318,7 +318,7 @@ static cell AMX_NATIVE_CALL ns_giveitem(AMX *amx, cell *params)
gpGamedllFuncs->dllapi_table->pfnSpawn(object); // emulate spawn
object->v.flags |= FL_ONGROUND; // make it think it's touched the ground
gpGamedllFuncs->dllapi_table->pfnThink(object); //
gpGamedllFuncs->dllapi_table->pfnTouch(object,player); // give it to the player
gpGamedllFuncs->dllapi_table->pfnTouch(player,object); // give it to the player
return 1;
}
@ -370,93 +370,10 @@ static cell AMX_NATIVE_CALL ns_user_kill(AMX *amx, cell *params)
return 0;
}
#define ANGLEVECTORS (*g_engfuncs.pfnAngleVectors)
static cell AMX_NATIVE_CALL ns_user_slap(AMX *amx, cell *params) /* 2 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients)
return 0;
int power = abs((int)params[2]);
edict_t *e=INDEXENT2(index);
if (e->v.iuser3 == 2 /* Commander class*/)
return 0;
if (MF_IsPlayerIngame(index) && MF_IsPlayerAlive(index)) {
if (e->v.health <= power) {
float bef = e->v.frags;
/*MDLL_ClientKill(pPlayer->pEdict);*/
edict_t *pEntity = CREATE_NAMED_ENTITY(MAKE_STRING("trigger_hurt"));
if (pEntity)
{
KeyValueData kvd;
kvd.szClassName="trigger_hurt";
kvd.szKeyName="classname";
kvd.szValue="trigger_hurt";
kvd.fHandled=0;
MDLL_KeyValue(pEntity,&kvd);
kvd.szClassName="trigger_hurt";
kvd.szKeyName="dmg";
kvd.szValue="20000.0";
kvd.fHandled=0;
MDLL_KeyValue(pEntity,&kvd);
kvd.szClassName="trigger_hurt";
kvd.szKeyName="damagetype";
kvd.szValue="1";
kvd.fHandled=0;
MDLL_KeyValue(pEntity,&kvd);
kvd.szClassName="trigger_hurt";
kvd.szKeyName="origin";
kvd.szValue="8192 8192 8192";
kvd.fHandled=0;
MDLL_KeyValue(pEntity,&kvd);
MDLL_Spawn(pEntity);
pEntity->v.classname=MAKE_STRING("slap");
MDLL_Touch(pEntity,e);
REMOVE_ENTITY(pEntity);
}
e->v.frags = bef;
}
else {
edict_t *pEdict = e;
int numparam = *params/sizeof(cell);
if (numparam<3 || params[3]) {
pEdict->v.velocity.x += RANDOM_LONG(-600,600);
pEdict->v.velocity.y += RANDOM_LONG(-180,180);
pEdict->v.velocity.z += RANDOM_LONG(100,200);
}
else {
vec3_t v_forward, v_right;
vec3_t vang = pEdict->v.angles;
float fang[3];
fang[0] = vang.x;
fang[1] = vang.y;
fang[2] = vang.z;
ANGLEVECTORS( fang, v_forward, v_right, NULL );
pEdict->v.velocity = pEdict->v.velocity + v_forward * 220 + Vector(0,0,200);
}
pEdict->v.punchangle.x = RANDOM_LONG(-10,10);
pEdict->v.punchangle.y = RANDOM_LONG(-10,10);
pEdict->v.health -= power;
int armor = (int)pEdict->v.armorvalue;
armor -= power;
if (armor < 0) armor = 0;
pEdict->v.armorvalue = armor;
pEdict->v.dmg_inflictor = pEdict;
static const char *bit_sound[3] = {
"weapons/cbar_hitbod1.wav",
"weapons/cbar_hitbod2.wav",
"weapons/cbar_hitbod3.wav" };
EMIT_SOUND_DYN2(pEdict, CHAN_VOICE, bit_sound[RANDOM_LONG(0,2)], 1.0, ATTN_NORM, 0, PITCH_NORM);
}
return 1;
}
return 0;
}
AMX_NATIVE_INFO ns_misc_natives[] = {
///////////////////
{ "user_kill", ns_user_kill },
{ "user_slap", ns_user_slap },
{ "ns_get_build", ns_get_build },

View File

@ -45,16 +45,6 @@
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable;
enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table =
{
@ -2124,7 +2114,6 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
return(FALSE);
}
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
g_pFunctionTable=pFunctionTable;
return(TRUE);
}
@ -2142,7 +2131,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
return(FALSE);
}
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
g_pFunctionTable_Post=pFunctionTable;
return(TRUE);
}
@ -2165,7 +2154,6 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
g_pengfuncsTable=pengfuncsFromEngine;
return TRUE;
}
@ -2183,7 +2171,6 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
return(FALSE);
}
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
g_pengfuncsTable_Post=pengfuncsFromEngine;
return TRUE;
}
@ -2208,7 +2195,6 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable=pNewFunctionTable;
return TRUE;
}
@ -2226,7 +2212,6 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
return(FALSE);
}
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
g_pNewFunctionsTable_Post=pNewFunctionTable;
return TRUE;
}
@ -2454,14 +2439,11 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2471,7 +2453,6 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
@ -2544,7 +2525,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2580,8 +2560,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A);
REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A);
// Player
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
@ -2593,7 +2572,6 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM);
REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
@ -2651,18 +2629,6 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg);
}
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG
// validate macros
@ -2683,14 +2649,11 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetAmxStringLen(NULL);
MF_CopyAmxMemory(NULL, NULL, 0);
MF_Log("str", "str", 0);
MF_LogError(NULL, 0, NULL);
MF_RaiseAmxError(NULL, 0);
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
MF_ExecuteForward(0, 0, 0);
MF_PrepareCellArray(NULL, 0);
MF_PrepareCharArray(NULL, 0);
MF_PrepareCellArrayA(NULL, 0, true);
MF_PrepareCharArrayA(NULL, 0, true);
MF_IsPlayerValid(0);
MF_GetPlayerName(0);
MF_GetPlayerIP(0);
@ -2701,7 +2664,6 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerPlayTime(0);
MF_GetPlayerCurweapon(0);
MF_GetPlayerTeamID(0);
MF_GetPlayerTeam(0);
MF_GetPlayerDeaths(0);
MF_GetPlayerMenu(0);
MF_GetPlayerKeys(0);

View File

@ -55,7 +55,7 @@ struct amxx_module_info_s
// The next section is copied from the amx.h file
// Copyright (c) ITB CompuPhase, 1997-2004
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
#if defined __LCC__ || defined __DMC__ || defined __linux__
#include <stdint.h>
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
@ -929,7 +929,7 @@ void FN_EngineFprintf(FILE *pfile, char *szFmt, ...);
#endif // FN_EngineFprintf
#ifdef FN_PvAllocEntPrivateData
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
#endif // FN_PvAllocEntPrivateData
#ifdef FN_PvEntPrivateData
@ -1919,14 +1919,11 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...);
typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/);
typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/);
typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
@ -1935,9 +1932,8 @@ typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/);
typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/);
typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/);
typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/);
typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/);
typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/);
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
@ -1990,14 +1986,11 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA;
extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA;
extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid;
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
@ -2033,7 +2026,6 @@ extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
#ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems
@ -2053,14 +2045,11 @@ int MF_GetAmxStringLen (const cell *ptr) { }
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
void MF_Log (const char * fmt, ...) { }
void MF_LogError (AMX * amx, int err, const char *fmt, ...) { }
int MF_RaiseAmxError (AMX * amx, int error) { }
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
int MF_ExecuteForward (int id, ...) { }
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
cell MF_PrepareCharArray (char * ptr, unsigned int size) { }
cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { }
cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { }
int MF_IsPlayerValid (int id) { }
const char * MF_GetPlayerName (int id) { }
const char * MF_GetPlayerIP (int id) { }
@ -2070,7 +2059,6 @@ int MF_IsPlayerAuthorized (int id) { }
float MF_GetPlayerTime (int id) { }
float MF_GetPlayerPlayTime (int id) { }
int MF_GetPlayerCurweapon (int id) { }
const char * MF_GetPlayerTeam (int id) { }
int MF_GetPlayerTeamID (int id) { }
int MF_GetPlayerDeaths (int id) { }
int MF_GetPlayerMenu (int id) { }
@ -2106,14 +2094,11 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...);
void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward
#define MF_PrepareCellArray g_fn_PrepareCellArray
#define MF_PrepareCharArray g_fn_PrepareCharArray
#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA
#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA
#define MF_IsPlayerValid g_fn_IsPlayerValid
#define MF_GetPlayerName g_fn_GetPlayerName
#define MF_GetPlayerIP g_fn_GetPlayerIP
@ -2123,7 +2108,6 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerTime g_fn_GetPlayerTime
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
@ -2149,7 +2133,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format
#define MF_Format g_fn_Format;
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -9,8 +9,6 @@ CSpawn ns_spawnpoints;
CPlayer g_player[33];
edict_t *player_edicts[33];
BOOL CheckForPublic(const char *publicname);
int gmsgHudText2=0;
int ChangeclassForward = -1;
int BuiltForward = -1;
@ -37,25 +35,13 @@ void OnPluginsLoaded()
iscombat=FALSE;
char mapname[255];
strcpy(mapname,STRING(gpGlobals->mapname));
if ((mapname[0]=='c' || mapname[0]=='C') && (mapname[1]=='o' || mapname[1]=='O') && mapname[2]=='_')
if ((mapname[0]=='c' || mapname[0]=='C') && (mapname[1]=='o' || mapname[0]=='O') && mapname[2]=='_')
iscombat=TRUE;
ChangeclassForward = MF_RegisterForward("client_changeclass", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
// No sense in this if it's combat..
if (!iscombat) {
if (CheckForPublic("client_built")) {
BuiltForward = MF_RegisterForward("client_built", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
g_pengfuncsTable_Post->pfnAlertMessage=AlertMessage_Post;
g_pengfuncsTable->pfnCreateNamedEntity=CreateNamedEntity;
} else {
g_pengfuncsTable_Post->pfnAlertMessage=NULL;
g_pengfuncsTable->pfnCreateNamedEntity=NULL;
}
} else {
// no need for these hooks in co
g_pengfuncsTable_Post->pfnAlertMessage=NULL;
g_pengfuncsTable->pfnCreateNamedEntity=NULL;
}
if (!iscombat)
BuiltForward = MF_RegisterForward("client_built", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
SpawnForward = MF_RegisterForward("client_spawn",ET_IGNORE,FP_CELL/*id*/,FP_DONE);
TeamForward = MF_RegisterForward("client_changeteam",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*new team*/,FP_CELL/*old team*/,FP_DONE);
}
@ -134,7 +120,7 @@ void PlayerPostThink_Post(edict_t *pEntity)
// name<CID><AUTHID><TEAM> changed role to "class" -- client_changeclass
void AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...)
{
if (atype != at_logged)
if (atype != at_logged || iscombat)
RETURN_META(MRES_IGNORED);
va_list LogArg;
char *sz, *message;
@ -289,9 +275,8 @@ void AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...)
iForward = 1;
}
// ns2amx_built.execute(index,iCreateEntityIndex,iForward,iType);
if (BuiltForward != -1) {
MF_ExecuteForward(BuiltForward, index, FStrEq((const char *)szParm[3],"type \"weapon_mine\"") ? 0 : iCreateEntityIndex, iForward, iType);
}
if (BuiltForward != -1)
MF_ExecuteForward(BuiltForward, index, iCreateEntityIndex, iForward, iType);
iCreateEntityIndex=0;
}
}
@ -465,24 +450,3 @@ edict_t *UTIL_FindEntityByString(edict_t *pentStart, const char *szKeyword, cons
return pentEntity;
return NULL;
}
BOOL CheckForPublic(const char *publicname)
{
AMX* amx;
char blah[64];
strncpy(blah,publicname,63);
int iFunctionIndex;
int i=0;
// Loop through all running scripts
while((amx=MF_GetScriptAmx(i++))!=NULL)
{
// Scan for public
if (MF_AmxFindPublic(amx, blah, &iFunctionIndex) == AMX_ERR_NONE)
{
// Public was found.
return TRUE;
}
}
return FALSE; // no public found in any loaded script
}

Some files were not shown because too many files have changed in this diff Show More