mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
Added new debug mode to fun module, also cleaned up error checking code
This commit is contained in:
parent
fc15ac1f41
commit
62e4bbcfe9
@ -45,6 +45,16 @@
|
|||||||
enginefuncs_t g_engfuncs;
|
enginefuncs_t g_engfuncs;
|
||||||
globalvars_t *gpGlobals;
|
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
|
// GetEntityAPI2 functions
|
||||||
static DLL_FUNCTIONS g_EntityAPI_Table =
|
static DLL_FUNCTIONS g_EntityAPI_Table =
|
||||||
{
|
{
|
||||||
@ -2114,6 +2124,7 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
|
memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS));
|
||||||
|
g_pFunctionTable=pFunctionTable;
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2131,7 +2142,7 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
|
memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) );
|
||||||
|
g_pFunctionTable_Post=pFunctionTable;
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2154,6 +2165,7 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
|
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t));
|
||||||
|
g_pengfuncsTable=pengfuncsFromEngine;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2171,6 +2183,7 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
|
memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t));
|
||||||
|
g_pengfuncsTable_Post=pengfuncsFromEngine;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2195,6 +2208,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
|
memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS));
|
||||||
|
g_pNewFunctionsTable=pNewFunctionTable;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2212,6 +2226,7 @@ C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, i
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
|
memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS));
|
||||||
|
g_pNewFunctionsTable_Post=pNewFunctionTable;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2439,11 +2454,14 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
|
|||||||
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
|
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
|
||||||
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
|
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
|
||||||
PFN_LOG g_fn_Log;
|
PFN_LOG g_fn_Log;
|
||||||
|
PFN_LOG_ERROR g_fn_LogError;
|
||||||
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
|
PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
|
||||||
PFN_REGISTER_FORWARD g_fn_RegisterForward;
|
PFN_REGISTER_FORWARD g_fn_RegisterForward;
|
||||||
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
|
PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
|
||||||
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
|
PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
|
||||||
PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
|
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_IS_PLAYER_VALID g_fn_IsPlayerValid;
|
||||||
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
|
PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
|
||||||
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
|
PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
|
||||||
@ -2453,6 +2471,7 @@ PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized;
|
|||||||
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
|
PFN_GET_PLAYER_TIME g_fn_GetPlayerTime;
|
||||||
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
|
PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime;
|
||||||
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
|
PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon;
|
||||||
|
PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
|
||||||
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
|
PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID;
|
||||||
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
|
PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths;
|
||||||
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
|
PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu;
|
||||||
@ -2525,6 +2544,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
|||||||
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
|
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
|
||||||
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
|
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
|
||||||
REQFUNC("Log", g_fn_Log, PFN_LOG);
|
REQFUNC("Log", g_fn_Log, PFN_LOG);
|
||||||
|
REQFUNC("LogError", g_fn_LogError, PFN_LOG_ERROR);
|
||||||
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
|
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
|
||||||
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
|
REQFUNC("Format", g_fn_Format, PFN_FORMAT);
|
||||||
|
|
||||||
@ -2560,7 +2580,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
|||||||
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
|
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
|
||||||
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
|
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
|
||||||
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
|
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
|
// Player
|
||||||
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
|
REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID);
|
||||||
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
|
REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME);
|
||||||
@ -2572,6 +2593,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
|||||||
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
|
REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME);
|
||||||
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
|
REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON);
|
||||||
REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID);
|
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("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS);
|
||||||
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
|
REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU);
|
||||||
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
|
REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS);
|
||||||
@ -2649,11 +2671,14 @@ void ValidateMacros_DontCallThis_Smiley()
|
|||||||
MF_GetAmxStringLen(NULL);
|
MF_GetAmxStringLen(NULL);
|
||||||
MF_CopyAmxMemory(NULL, NULL, 0);
|
MF_CopyAmxMemory(NULL, NULL, 0);
|
||||||
MF_Log("str", "str", 0);
|
MF_Log("str", "str", 0);
|
||||||
|
MF_LogError(NULL, 0, NULL);
|
||||||
MF_RaiseAmxError(NULL, 0);
|
MF_RaiseAmxError(NULL, 0);
|
||||||
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
|
MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0);
|
||||||
MF_ExecuteForward(0, 0, 0);
|
MF_ExecuteForward(0, 0, 0);
|
||||||
MF_PrepareCellArray(NULL, 0);
|
MF_PrepareCellArray(NULL, 0);
|
||||||
MF_PrepareCharArray(NULL, 0);
|
MF_PrepareCharArray(NULL, 0);
|
||||||
|
MF_PrepareCellArrayA(NULL, 0, true);
|
||||||
|
MF_PrepareCharArrayA(NULL, 0, true);
|
||||||
MF_IsPlayerValid(0);
|
MF_IsPlayerValid(0);
|
||||||
MF_GetPlayerName(0);
|
MF_GetPlayerName(0);
|
||||||
MF_GetPlayerIP(0);
|
MF_GetPlayerIP(0);
|
||||||
@ -2664,6 +2689,7 @@ void ValidateMacros_DontCallThis_Smiley()
|
|||||||
MF_GetPlayerPlayTime(0);
|
MF_GetPlayerPlayTime(0);
|
||||||
MF_GetPlayerCurweapon(0);
|
MF_GetPlayerCurweapon(0);
|
||||||
MF_GetPlayerTeamID(0);
|
MF_GetPlayerTeamID(0);
|
||||||
|
MF_GetPlayerTeam(0);
|
||||||
MF_GetPlayerDeaths(0);
|
MF_GetPlayerDeaths(0);
|
||||||
MF_GetPlayerMenu(0);
|
MF_GetPlayerMenu(0);
|
||||||
MF_GetPlayerKeys(0);
|
MF_GetPlayerKeys(0);
|
||||||
|
@ -55,7 +55,7 @@ struct amxx_module_info_s
|
|||||||
// The next section is copied from the amx.h file
|
// The next section is copied from the amx.h file
|
||||||
// Copyright (c) ITB CompuPhase, 1997-2004
|
// Copyright (c) ITB CompuPhase, 1997-2004
|
||||||
|
|
||||||
#if defined __LCC__ || defined __DMC__ || defined __linux__
|
#if defined __LCC__ || defined __DMC__ || defined __linux__ || defined __GNUC__
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
|
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
|
||||||
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
|
/* 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
|
#endif // FN_EngineFprintf
|
||||||
|
|
||||||
#ifdef FN_PvAllocEntPrivateData
|
#ifdef FN_PvAllocEntPrivateData
|
||||||
void *FN_PvAllocEntPrivateData(edict_t *pEdict, long cb);
|
void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb);
|
||||||
#endif // FN_PvAllocEntPrivateData
|
#endif // FN_PvAllocEntPrivateData
|
||||||
|
|
||||||
#ifdef FN_PvEntPrivateData
|
#ifdef FN_PvEntPrivateData
|
||||||
@ -1919,11 +1919,14 @@ typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr);
|
|||||||
typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/);
|
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_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/);
|
||||||
typedef void (*PFN_LOG) (const char * /*fmt*/, ...);
|
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_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/);
|
||||||
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
|
typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/);
|
||||||
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
|
typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/);
|
||||||
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
|
typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/);
|
||||||
typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*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 int (*PFN_IS_PLAYER_VALID) (int /*id*/);
|
||||||
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
|
typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/);
|
||||||
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
|
typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/);
|
||||||
@ -1934,6 +1937,7 @@ typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/);
|
|||||||
typedef float (*PFN_GET_PLAYER_PLAYTIME) (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 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_TEAMID) (int /*id*/);
|
||||||
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
|
typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/);
|
||||||
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
|
typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/);
|
||||||
@ -1986,11 +1990,14 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
|
|||||||
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
|
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
|
||||||
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
|
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
|
||||||
extern PFN_LOG g_fn_Log;
|
extern PFN_LOG g_fn_Log;
|
||||||
|
extern PFN_LOG_ERROR g_fn_LogError;
|
||||||
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
|
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
|
||||||
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
|
extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
|
||||||
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
|
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
|
||||||
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
|
extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray;
|
||||||
extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray;
|
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_IS_PLAYER_VALID g_fn_IsPlayerValid;
|
||||||
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
|
extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName;
|
||||||
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
|
extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP;
|
||||||
@ -2026,6 +2033,7 @@ extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
|
|||||||
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
|
extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
|
||||||
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
|
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
|
||||||
extern PFN_FORMAT g_fn_Format;
|
extern PFN_FORMAT g_fn_Format;
|
||||||
|
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
|
||||||
|
|
||||||
#ifdef MAY_NEVER_BE_DEFINED
|
#ifdef MAY_NEVER_BE_DEFINED
|
||||||
// Function prototypes for intellisense and similar systems
|
// Function prototypes for intellisense and similar systems
|
||||||
@ -2045,11 +2053,14 @@ int MF_GetAmxStringLen (const cell *ptr) { }
|
|||||||
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
|
char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { }
|
||||||
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
|
void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { }
|
||||||
void MF_Log (const char * fmt, ...) { }
|
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_RaiseAmxError (AMX * amx, int error) { }
|
||||||
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
|
int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { }
|
||||||
int MF_ExecuteForward (int id, ...) { }
|
int MF_ExecuteForward (int id, ...) { }
|
||||||
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
|
cell MF_PrepareCellArray (cell * ptr, unsigned int size) { }
|
||||||
cell MF_PrepareCharArray (char * 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) { }
|
int MF_IsPlayerValid (int id) { }
|
||||||
const char * MF_GetPlayerName (int id) { }
|
const char * MF_GetPlayerName (int id) { }
|
||||||
const char * MF_GetPlayerIP (int id) { }
|
const char * MF_GetPlayerIP (int id) { }
|
||||||
@ -2059,6 +2070,7 @@ int MF_IsPlayerAuthorized (int id) { }
|
|||||||
float MF_GetPlayerTime (int id) { }
|
float MF_GetPlayerTime (int id) { }
|
||||||
float MF_GetPlayerPlayTime (int id) { }
|
float MF_GetPlayerPlayTime (int id) { }
|
||||||
int MF_GetPlayerCurweapon (int id) { }
|
int MF_GetPlayerCurweapon (int id) { }
|
||||||
|
const char * MF_GetPlayerTeam (int id) { }
|
||||||
int MF_GetPlayerTeamID (int id) { }
|
int MF_GetPlayerTeamID (int id) { }
|
||||||
int MF_GetPlayerDeaths (int id) { }
|
int MF_GetPlayerDeaths (int id) { }
|
||||||
int MF_GetPlayerMenu (int id) { }
|
int MF_GetPlayerMenu (int id) { }
|
||||||
@ -2094,11 +2106,14 @@ const char * MF_Format (const char *fmt, ...) { }
|
|||||||
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
|
#define MF_GetAmxStringLen g_fn_GetAmxStringLen
|
||||||
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
|
#define MF_CopyAmxMemory g_fn_CopyAmxMemory
|
||||||
void MF_Log(const char *fmt, ...);
|
void MF_Log(const char *fmt, ...);
|
||||||
|
#define MF_LogError g_fn_LogError
|
||||||
#define MF_RaiseAmxError g_fn_RaiseAmxError
|
#define MF_RaiseAmxError g_fn_RaiseAmxError
|
||||||
#define MF_RegisterForward g_fn_RegisterForward
|
#define MF_RegisterForward g_fn_RegisterForward
|
||||||
#define MF_ExecuteForward g_fn_ExecuteForward
|
#define MF_ExecuteForward g_fn_ExecuteForward
|
||||||
#define MF_PrepareCellArray g_fn_PrepareCellArray
|
#define MF_PrepareCellArray g_fn_PrepareCellArray
|
||||||
#define MF_PrepareCharArray g_fn_PrepareCharArray
|
#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_IsPlayerValid g_fn_IsPlayerValid
|
||||||
#define MF_GetPlayerName g_fn_GetPlayerName
|
#define MF_GetPlayerName g_fn_GetPlayerName
|
||||||
#define MF_GetPlayerIP g_fn_GetPlayerIP
|
#define MF_GetPlayerIP g_fn_GetPlayerIP
|
||||||
@ -2108,6 +2123,7 @@ void MF_Log(const char *fmt, ...);
|
|||||||
#define MF_GetPlayerTime g_fn_GetPlayerTime
|
#define MF_GetPlayerTime g_fn_GetPlayerTime
|
||||||
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
|
#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime
|
||||||
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
|
#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon
|
||||||
|
#define MF_GetPlayerTeam g_fn_GetPlayerTeam
|
||||||
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
|
#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID
|
||||||
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
|
#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths
|
||||||
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
|
#define MF_GetPlayerMenu g_fn_GetPlayerMenu
|
||||||
@ -2133,7 +2149,7 @@ void MF_Log(const char *fmt, ...);
|
|||||||
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
|
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
|
||||||
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
|
#define MF_GetPlayerFlags g_fn_GetPlayerFlags
|
||||||
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
|
#define MF_GetPlayerEdict g_fn_GetPlayerEdict
|
||||||
#define MF_Format g_fn_Format;
|
#define MF_Format g_fn_Format
|
||||||
|
|
||||||
/*** Memory ***/
|
/*** Memory ***/
|
||||||
void *operator new(size_t reportedSize);
|
void *operator new(size_t reportedSize);
|
||||||
|
279
dlls/fun/fun.cpp
279
dlls/fun/fun.cpp
@ -47,20 +47,11 @@
|
|||||||
// params[2] = argument2 <--- use the ones in params[n] directly, to save some time.
|
// 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 receiver and sender validity. <--- Check ents, maybe need to do this better and more proper later?
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients
|
CHECK_PLAYER(params[1])
|
||||||
|| params[2] < 1 || params[2] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[2])
|
||||||
{
|
|
||||||
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.
|
// Get * pointer.
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); <--- Players require a different function than INDEXENT because of an HLSDK bug
|
||||||
|
|
||||||
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.
|
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?
|
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?
|
||||||
@ -98,12 +89,8 @@ static cell AMX_NATIVE_CALL get_client_listening(AMX *amx, cell *params) // get_
|
|||||||
// params[2] = sender
|
// params[2] = sender
|
||||||
|
|
||||||
// Check receiver and sender validity.
|
// Check receiver and sender validity.
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients
|
CHECK_PLAYER(params[1]);
|
||||||
|| params[2] < 1 || params[2] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[2]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET- AND SETCLIENTLISTENING returns "qboolean", an int, probably 0 or 1...
|
// GET- AND SETCLIENTLISTENING returns "qboolean", an int, probably 0 or 1...
|
||||||
return GETCLIENTLISTENING(params[1], params[2]);
|
return GETCLIENTLISTENING(params[1], params[2]);
|
||||||
@ -117,12 +104,8 @@ static cell AMX_NATIVE_CALL set_client_listening(AMX *amx, cell *params) // set_
|
|||||||
// params[3] = listen
|
// params[3] = listen
|
||||||
|
|
||||||
// Check receiver and sender validity.
|
// Check receiver and sender validity.
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients
|
CHECK_PLAYER(params[1]);
|
||||||
|| params[2] < 1 || params[2] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[2]);
|
||||||
{
|
|
||||||
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.
|
// 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?)
|
// To do: find out the possible values to set (0, 1?)
|
||||||
@ -138,19 +121,10 @@ static cell AMX_NATIVE_CALL set_user_godmode(AMX *amx, cell *params) // set_user
|
|||||||
// params[2] = godmode = 0
|
// params[2] = godmode = 0
|
||||||
|
|
||||||
// Check index.
|
// Check index.
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get player pointer.
|
// Get player pointer.
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params[2] == 1) {
|
if (params[2] == 1) {
|
||||||
// Enable godmode
|
// Enable godmode
|
||||||
@ -170,19 +144,10 @@ static cell AMX_NATIVE_CALL get_user_godmode(AMX *amx, cell *params) // get_user
|
|||||||
// params[1] = index
|
// params[1] = index
|
||||||
|
|
||||||
// Check index.
|
// Check index.
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get player pointer.
|
// Get player pointer.
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int godmode = 0;
|
int godmode = 0;
|
||||||
|
|
||||||
@ -203,20 +168,10 @@ static cell AMX_NATIVE_CALL give_item(AMX *amx, cell *params) // native give_ite
|
|||||||
// params[2] = item...
|
// params[2] = item...
|
||||||
|
|
||||||
// Check index.
|
// Check index.
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get player pointer.
|
// Get player pointer.
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
// Check entity validity
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create item entity pointer
|
// Create item entity pointer
|
||||||
edict_t *pItemEntity;
|
edict_t *pItemEntity;
|
||||||
@ -239,8 +194,8 @@ static cell AMX_NATIVE_CALL give_item(AMX *amx, cell *params) // native give_ite
|
|||||||
// Create the entity, returns to pointer
|
// Create the entity, returns to pointer
|
||||||
pItemEntity = CREATE_NAMED_ENTITY(item);
|
pItemEntity = CREATE_NAMED_ENTITY(item);
|
||||||
|
|
||||||
if(FNullEnt(pItemEntity)) {
|
if (FNullEnt(pItemEntity)) {
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
MF_LogError(amx, AMX_ERR_NATIVE, "Item \"%s\" failed to create", szItem);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,18 +233,9 @@ 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? :-)
|
// 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
|
// params[1] = entity to spawn
|
||||||
|
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxEntities)
|
CHECK_ENTITY(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
edict_t *pEnt = INDEXENT(params[1]);
|
|
||||||
|
|
||||||
// Check entity validity
|
edict_t *pEnt = GETEDICT(params[1]);
|
||||||
if (FNullEnt(pEnt)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
MDLL_Spawn(pEnt);
|
MDLL_Spawn(pEnt);
|
||||||
|
|
||||||
@ -303,19 +249,10 @@ static cell AMX_NATIVE_CALL set_user_health(AMX *amx, cell *params) // set_user_
|
|||||||
// params[2] = health
|
// params[2] = health
|
||||||
|
|
||||||
// Check index
|
// Check index
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch player pointer
|
// Fetch player pointer
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Kill if health too low.
|
// Kill if health too low.
|
||||||
if (params[2] > 0)
|
if (params[2] > 0)
|
||||||
@ -333,19 +270,10 @@ static cell AMX_NATIVE_CALL set_user_frags(AMX *amx, cell *params) // set_user_f
|
|||||||
// params[2] = frags
|
// params[2] = frags
|
||||||
|
|
||||||
// Check index
|
// Check index
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch player pointer
|
// Fetch player pointer
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pPlayer->v.frags = params[2];
|
pPlayer->v.frags = params[2];
|
||||||
|
|
||||||
@ -359,19 +287,10 @@ static cell AMX_NATIVE_CALL set_user_armor(AMX *amx, cell *params) // set_user_a
|
|||||||
// params[2] = armor
|
// params[2] = armor
|
||||||
|
|
||||||
// Check index
|
// Check index
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch player pointer
|
// Fetch player pointer
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pPlayer->v.armorvalue = params[2];
|
pPlayer->v.armorvalue = params[2];
|
||||||
|
|
||||||
@ -385,19 +304,10 @@ static cell AMX_NATIVE_CALL set_user_origin(AMX *amx, cell *params) // set_user_
|
|||||||
// params[2] = origin
|
// params[2] = origin
|
||||||
|
|
||||||
// Check index
|
// Check index
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch player pointer
|
// Fetch player pointer
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cell *newVectorCell = MF_GetAmxAddr(amx, params[2]);
|
cell *newVectorCell = MF_GetAmxAddr(amx, params[2]);
|
||||||
|
|
||||||
@ -419,19 +329,10 @@ static cell AMX_NATIVE_CALL set_user_rendering(AMX *amx, cell *params) // set_us
|
|||||||
// params[7] = amount
|
// params[7] = amount
|
||||||
|
|
||||||
// Check index
|
// Check index
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch player pointer
|
// Fetch player pointer
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pPlayer->v.renderfx = params[2];
|
pPlayer->v.renderfx = params[2];
|
||||||
Vector newVector = Vector(float(params[3]), float(params[4]), float(params[5]));
|
Vector newVector = Vector(float(params[3]), float(params[4]), float(params[5]));
|
||||||
@ -452,19 +353,10 @@ static cell AMX_NATIVE_CALL set_user_maxspeed(AMX *amx, cell *params) // set_use
|
|||||||
REAL fNewSpeed = amx_ctof(params[2]);
|
REAL fNewSpeed = amx_ctof(params[2]);
|
||||||
|
|
||||||
// Check index
|
// Check index
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch player pointer
|
// Fetch player pointer
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SETCLIENTMAXSPEED(pPlayer, fNewSpeed);
|
SETCLIENTMAXSPEED(pPlayer, fNewSpeed);
|
||||||
pPlayer->v.maxspeed = fNewSpeed;
|
pPlayer->v.maxspeed = fNewSpeed;
|
||||||
@ -478,19 +370,10 @@ static cell AMX_NATIVE_CALL get_user_maxspeed(AMX *amx, cell *params) // Float:g
|
|||||||
// params[1] = index
|
// params[1] = index
|
||||||
|
|
||||||
// Check index
|
// Check index
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch player pointer
|
// Fetch player pointer
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return amx_ftoc(pPlayer->v.maxspeed);
|
return amx_ftoc(pPlayer->v.maxspeed);
|
||||||
}
|
}
|
||||||
@ -501,19 +384,10 @@ static cell AMX_NATIVE_CALL set_user_gravity(AMX *amx, cell *params) // set_user
|
|||||||
// params[1] = index
|
// params[1] = index
|
||||||
// params[2] = gravity (=-1.0)
|
// params[2] = gravity (=-1.0)
|
||||||
// Check index
|
// Check index
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch player pointer
|
// Fetch player pointer
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pPlayer->v.gravity = amx_ctof(params[2]);
|
pPlayer->v.gravity = amx_ctof(params[2]);
|
||||||
|
|
||||||
@ -526,19 +400,10 @@ static cell AMX_NATIVE_CALL get_user_gravity(AMX *amx, cell *params) // Float:ge
|
|||||||
// params[1] = index
|
// params[1] = index
|
||||||
|
|
||||||
// Check index
|
// Check index
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch player pointer
|
// Fetch player pointer
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return amx_ftoc(pPlayer->v.gravity);
|
return amx_ftoc(pPlayer->v.gravity);
|
||||||
}
|
}
|
||||||
@ -571,10 +436,7 @@ static cell AMX_NATIVE_CALL set_user_hitzones(AMX *amx, cell *params) // set_use
|
|||||||
else {
|
else {
|
||||||
if (shooter == 0) {
|
if (shooter == 0) {
|
||||||
// "All" shooters, target (gettingHit) should be existing player id
|
// "All" shooters, target (gettingHit) should be existing player id
|
||||||
if (gettingHit < 1 || gettingHit > gpGlobals->maxClients) {
|
CHECK_PLAYER(gettingHit);
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// Where can gettingHit get hit by all?
|
// Where can gettingHit get hit by all?
|
||||||
g_zones_getHit[gettingHit] = hitzones;
|
g_zones_getHit[gettingHit] = hitzones;
|
||||||
}
|
}
|
||||||
@ -596,28 +458,13 @@ static cell AMX_NATIVE_CALL get_user_hitzones(AMX *amx, cell *params) // get_use
|
|||||||
int gettingHit = params[2];
|
int gettingHit = params[2];
|
||||||
|
|
||||||
if (shooter) {
|
if (shooter) {
|
||||||
if (FNullEnt(shooter)) {
|
CHECK_PLAYER(shooter);
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return g_zones_toHit[shooter];
|
return g_zones_toHit[shooter];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!gettingHit) {
|
CHECK_PLAYER(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];
|
return g_zones_getHit[gettingHit];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL set_user_noclip(AMX *amx, cell *params) // set_user_noclip(index, noclip = 0); = 2 arguments
|
static cell AMX_NATIVE_CALL set_user_noclip(AMX *amx, cell *params) // set_user_noclip(index, noclip = 0); = 2 arguments
|
||||||
@ -627,20 +474,10 @@ static cell AMX_NATIVE_CALL set_user_noclip(AMX *amx, cell *params) // set_user_
|
|||||||
// params[2] = no clip or not...
|
// params[2] = no clip or not...
|
||||||
|
|
||||||
// Check index
|
// Check index
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch player pointer
|
// Fetch player pointer
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
// Check validity.
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params[2] == 1)
|
if (params[2] == 1)
|
||||||
pPlayer->v.movetype = MOVETYPE_NOCLIP;
|
pPlayer->v.movetype = MOVETYPE_NOCLIP;
|
||||||
@ -656,20 +493,10 @@ static cell AMX_NATIVE_CALL get_user_noclip(AMX *amx, cell *params) // get_user_
|
|||||||
// params[1] = index
|
// params[1] = index
|
||||||
|
|
||||||
// Check index
|
// Check index
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch player pointer
|
// Fetch player pointer
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
// Check validity.
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pPlayer->v.movetype == MOVETYPE_NOCLIP;
|
return pPlayer->v.movetype == MOVETYPE_NOCLIP;
|
||||||
}
|
}
|
||||||
@ -683,20 +510,10 @@ static cell AMX_NATIVE_CALL set_user_footsteps(AMX *amx, cell *params) // set_us
|
|||||||
// params[2] = 0 = normal footstep sound, 1 = silent slippers
|
// params[2] = 0 = normal footstep sound, 1 = silent slippers
|
||||||
|
|
||||||
// Check index
|
// Check index
|
||||||
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch player pointer
|
// Fetch player pointer
|
||||||
edict_t *pPlayer = INDEXENT(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
// Check validity.
|
|
||||||
if (FNullEnt(pPlayer)) {
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params[2]) {
|
if (params[2]) {
|
||||||
pPlayer->v.flTimeStepSound = 999;
|
pPlayer->v.flTimeStepSound = 999;
|
||||||
@ -712,13 +529,9 @@ static cell AMX_NATIVE_CALL set_user_footsteps(AMX *amx, cell *params) // set_us
|
|||||||
|
|
||||||
// SidLuke
|
// SidLuke
|
||||||
static cell AMX_NATIVE_CALL strip_user_weapons(AMX *amx, cell *params) { // index
|
static cell AMX_NATIVE_CALL strip_user_weapons(AMX *amx, cell *params) { // index
|
||||||
if (!MF_IsPlayerIngame(params[1]))
|
CHECK_PLAYER(params[1]);
|
||||||
{
|
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
edict_t* pPlayer = INDEXENT(params[1]);
|
edict_t* pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
string_t item = MAKE_STRING("trigger_once");
|
string_t item = MAKE_STRING("trigger_once");
|
||||||
edict_t *pent = CREATE_NAMED_ENTITY( item );
|
edict_t *pent = CREATE_NAMED_ENTITY( item );
|
||||||
|
@ -60,3 +60,30 @@ bool g_ResetHUDbool;
|
|||||||
edict_t* g_edict;
|
edict_t* g_edict;
|
||||||
//bool g_bot[33]; // is user bot? <--- removed, only needed with akimbot
|
//bool g_bot[33]; // is user bot? <--- removed, only needed with akimbot
|
||||||
// Globals above
|
// Globals above
|
||||||
|
|
||||||
|
#define CHECK_ENTITY(x) \
|
||||||
|
if (x <= 0 || x > gpGlobals->maxEntities) { \
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
|
||||||
|
} else { \
|
||||||
|
if (x <= gpGlobals->maxClients) { \
|
||||||
|
if (!MF_IsPlayerIngame(x)) { \
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
|
||||||
|
} \
|
||||||
|
} else { \
|
||||||
|
if (FNullEnt(INDEXENT(x))) { \
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CHECK_PLAYER(x) \
|
||||||
|
if (x < 1 || x > gpGlobals->maxClients) { \
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
|
||||||
|
} else { \
|
||||||
|
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GETEDICT(n) \
|
||||||
|
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))
|
||||||
|
Loading…
Reference in New Issue
Block a user