amx_ctof

1
REAL amx_ctof( cell x );

Converts a cell to a REAL (float or double) value.

常用于module与small之间的传参

amx_ftoc

1
REAL amx_ftoc( float x );

Converts a REAL (float or double) to a cell value.

常用于module与small之间的传参

MF_AddNatives

1
int MF_AddNatives( const AMX_NATIVE_INFO *list );

Adds an array of natives to the AMX Mod X core. Returns 1 for success and 0 for failure.

官方建议是在OnAmxxAttach()调用来注册native函数

MF_AmxAllot

1
int MF_AmxAllot( AMX *amx, int cells, cell *amxAddr, cell **physAddr );`

Allocates memory in an AMX plugin, returning AMX_ERR_NONE on success. AmxAddr will contain the AMX offset and physAddr will contain the physical address.

MF_AmxExec

1
int MF_AmxExec( AMX *amx, cell *retval, int index );

Executes a public function by index on a specific plugin. The return code for the machine state is returned, and the actual plugin return value is stored in the cell pointed to by retval.

MF_AmxExecv

1
int MF_AmxExecv( AMX *amx, cell *retval, int index, int numparams, cell params[] );

This function is deprecated and is no longer usable.

MF_AmxFindNative

1
int MF_AmxFindNative( AMX *amx, const char *name, int *index );

Same as MF_AmxFindPublic, except returns the index of a native instead of a public function.

MF_AmxFindPublic

1
int MF_AmxFindPublic( AMX *amx, const char *name, int *index );

Finds a public function by name in a specific plugin. The function index is stored in the integer pointed to by index. On success, AMX_ERR_NONE is returned, otherwise AMX_ERR_NOTFOUND is returned.

MF_BuildPathname

1
char* MF_BuildPathname( const char *format, ... );

Formats a series of strings in the style of sprintf(), converting the path tokens for the current operating system. The return pointer is a static buffer, currently set to 256 bytes.

MF_BuildPathnameR

1
char* MF_BuildPathnameR( char *buffer, size_t maxlength, const char *format, ... );

Same as MF_BuildPathname, but re-entrant. Recommended usage over its predecessor.

MF_CopyAmxMemory

1
void MF_CopyAmxMemory( cell *dest, const cell *src, int len);

Copies a segment of memory from src to dest. Length is in cells, not bytes.

MF_ExecuteForward

1
int MF_ExecuteForward( int id, ... );

Executes a given forward (valid IDs are > -1). Each variable argument parameter must match the constructs used with MF_RegisterForward style functions.

用MF_ExecuteForward来执行在MF_RegisterForward、MF_RegisterSPForward或者MF_RegisterSPForwardByName注册的forward函数。

MF_FindScriptByAmx

1
int MF_FindScriptByAmx( const AMX *amx );

Returns the integer id of an AMX Mod X loaded plugin matching the given AMX pointer.

MF_FindScriptByName

1
int MF_FindScriptByName( const char *name );

Returns the integer id of an AMX Mod X loaded plugin matching the given file name.

MF_Format

1
const char * MF_Format( const char *format, ... );

Formats a string using the Language Translator in the AMX Mod X core.

MF_FormatAmxString

1
char* MF_FormatAmxString( AMX *amx, cell *params, int bufferId, int *len);

Formats a string using the parameters of a native call. You should always pass the params array directly, because the function expects the first cell to contain the parameter count. This function contains two buffer slots, 0 and 1. The return value is a pointer from one of these static buffers. The length of the final string is stored in the integer pointed to by “len”.

MF_GetAmxAddr

1
cell* MF_GetAmxAddr( AMX *amx, cell offset );

Returns the cell address of a parameter passed by reference, such as a variable argument, byref parameter, string, or array.

常用于module与small之间的传参

MF_GetAmxString

1
char* MF_GetAmxString( AMX *amx, cell amxAddr, int bufferId, int *len );

Returns a null-terminated string constructed from an amx by-reference address. The pointer is to one of four buffer slots, 0-3. The length of the string is stored in the integer pointed to by “len”.

常用于module与small之间的传参

MF_GetAmxStringLen

1
int MF_GetAmxStringLen( const cell *ptr );

Returns the length of a string stored as an array of cells (for example, a result from MF_GetAmxAddr()).

常用于module与small之间的传参

MF_GetModname

1
const char* MF_GetModname();

Returns a string containing the mod name.

MF_GetPlayerArmor

1
int MF_GetPlayerArmor( int playerId );

Returns the armorvalue of a player by id.

MF_GetPlayerCurweapon

1
int MF_GetPlayerCurweapon( int playerId );

Returns the id of the current weapon of a player by id.

MF_GetPlayerDeaths

1
int MF_GetPlayerDeaths( int playerId );

Returns the death count of a player by id.

MF_GetPlayerEdict

1
int MF_GetPlayerEdict( int playerId );

Returns the edict_t pointer of a player by id.

int MF_GetPlayerFlags( int playerId );

Returns the flags set on player flag slot 0 by id.

MF_GetPlayerFrags

1
int MF_GetPlayerFrags( int playerId );

Returns the amount of frags of a player by id.

MF_GetPlayerHealth

1
int MF_GetPlayerHealth( int playerId );

Returns the health of a player by id.

MF_GetPlayerIP

1
const char * MF_GetPlayerIP( int playerId );

Returns a string containing a player’s IP address by id.

MF_GetPlayerKeys

1
int MF_GetPlayerKeys( int playerId );

Returns a player’s keys by id.

MF_GetPlayerMenu

1
int MF_GetPlayerMenu( int playerId );

Returns a player’s current menu by id.

MF_GetPlayerName

1
const char * MF_GetPlayerName( int playerId );

Returns a player’s name by id.

MF_GetPlayerPlayTime

1
float MF_GetPlayerPlayTime( int playerId );

Returns a player’s playtime by id.

MF_GetPlayerTeam

1
const char * MF_GetPlayerTeam( int playerId );

Returns a player’s team name by id.

MF_GetPlayerTeamID

1
int	MF_GetPlayerTeamID( int playerId );

Returns a player’s team id by id.

MF_GetPlayerTime

1
float MF_GetPlayerTime( int playerId );

Returns a player’s total time by id.

MF_GetScriptAmx

1
AMX* MF_GetScriptAmx( int id );

Returns a plugin’s AMX structure by id.

MF_GetScriptName

1
AMX* MF_GetScriptName( const char *name );

Returns a plugin’s AMX structure by name.

MF_IsPlayerAlive

1
int MF_IsPlayerAlive( int id );

Returns 1 if a player is alive, 0 otherwise.

MF_IsPlayerAuthorized

1
int MF_IsPlayerAuthorized( int id );

Returns 1 if a player is Steam authorized, 0 otherwise.

MF_IsPlayerBot

1
int MF_IsPlayerBot( int id );

Returns 1 if a player is a bot/fakeclient, 0 otherwise.

MF_IsPlayerConnecting

1
int MF_IsPlayerConnecting( int id );

Returns 1 if a player is still connecting, 0 otherwise.

MF_IsPlayerHLTV

1
int MF_IsPlayerHLTV( int id );

Returns 1 if a player is an HLTV, 0 otherwise.

MF_IsPlayerIngame

1
int MF_IsPlayerIngame( int id );

Returns 1 if a player is in-game, 0 otherwise.

MF_IsPlayerValid

1
int MF_IsPlayerValid( int id );

Returns 1 if a player id is a valid id, 0 otherwise.

MF_Log

1
void MF_Log( const char *format, ... );

Logs a message in the style of sprintf() to Half-Life. The module’s name is prepended in the style of Metamod.

MF_LogError

1
void MF_LogError( AMX *amx, int err, const char *format, ... );

Logs a message using the generic error messenger (debug tracer). The error code should usually be AMX_ERR_NATIVE, and format is in the style of sprintf(). If you use this, you should not use MF_RaiseAmxError().

MF_PrepareCellArray

1
cell MF_PrepareCellArray( cell *ptr, unsigned int size );

MF_PrepareCellArrayA

1
cell MF_PrepareCellArrayA( cell *ptr, unsigned int size, bool copyBack);

Allocates memory for a cell array for a forward. The AMX address offset is returned as a cell. If copyBack is true, any data changed in the array after the forward is executed is copied back to the original AMX address.

MF_PrepareCharArray

1
cell MF_PrepareCharArray( char *ptr, unsigned int size );

MF_PrepareCharArrayA

1
cell MF_PrepareCharArrayA( char *ptr, unsigned int size, bool copyBack );

Same as PrepareCellArray, except the source is a null terminated string instead of a cell array.

MF_PrintSrvConsole

1
void MF_PrintSrvConsole( char *format, ... );

Prints text in the style of sprintf() to the server console.

MF_RaiseAmxError

1
int MF_RaiseAmxError( AMX *amx, int error );

Obsolete - use MF_LogError() instead. Sets the error state in an AMX instance which will halt the machine and invoke a generic error message.

MF_RegisterFunction

1
void MF_RegisterFunction( void *pfn, const char *name );

Registers a function in the module funciton table, for use with MF_RequestFunction.

MF_RegisterForward

1
int MF_RegisterForward( const char *funcname, ForwardExecType exectype, ... );

Registers a global forward throughout all plugins. “funcname” is the name of the function which must be public. ForwardExecType is either ET_STOP (halt on PLUGIN_HANDLED) or ET_IGNORE (ignore return value). The rest of the parameters should be an FP_DONE terminated list of parameter types, which are: FP_CELL (normal), FP_FLOAT (float), FP_STRING (null terminated string), FP_STRINGEX (copy back string), FP_ARRAY (use the return value of PrepareCellArray). The return value is the identifier which should be used with MF_ExecuteForward.

注册全局的forward函数,官方建议是在OnPluginsLoaded()中注册全局的forward函数

MF_RegisterSPForward

1
int MF_RegisterSPForward( AMX *amx, int func, ... );

MF_RegisterSPForwardByName

1
int MF_RegisterSPForwardByName( AMX *amx, const char *func, ... );

Registers a forward to a public function in a single plugin. Note that there is no ExecType value, as it is unnecessary. The return value is the identifier which should be used with MF_ExecuteForward. The integer func should be the value of MF_AmxFindPublic(), or use the function which registers by function name.

单独给某个插件注册forward函数,官方建议是把注册代码写到native中,由small插件脚本调用,结合传入的AMX *amx参数,来完成本地局部forward的注册。

其中,SP是single plugin的英文缩写,单一插件的意思。

MF_RequestFunction

1
void * MF_RequestFunction( const char *name );

Requests a function from the module function table.

MF_SetAmxString

1
int	MF_SetAmxString( AMX *amx, cell amxAddr, const char *src, int max );

Sets an AMX string. amxAddr should be an AMX offset that points to an array. Max is the maximum number of cells to copy.

常用于module与small之间的传参

MF_UnregisterSPForward

1
void MF_UnregisterSPForward( int id );

Unregisters a previously registered forward.

参考文献

More MF_ Function In amxxmodule.h
AMX Mod X Documentation