GDK 4.6.3
Write SA-MP gamemodes in C/C++
Functions
Interop

Functions

cell sampgdk::CallNative (AMX_NATIVE native, cell *params)
 C++ wrapper around sampgdk_CallNative()
 
AMX_NATIVE sampgdk::FindNative (const char *name)
 C++ wrapper around sampgdk_FindNative()
 
const AMX_NATIVE_INFO * sampgdk::GetNatives ()
 C++ wrapper around sampgdk_GetNatives()
 
const AMX_NATIVE_INFO * sampgdk::GetNatives (int &number)
 C++ wrapper around sampgdk_GetNatives()
 
cell sampgdk::InvokeNative (AMX_NATIVE native, const char *format,...)
 C++ wrapper around sampgdk_InvokeNative()
 
cell sampgdk::InvokeNativeArray (AMX_NATIVE native, const char *format, void **args)
 C++ wrapper around sampgdk_InvokeNativeArray()
 
cell sampgdk::InvokeNativeV (AMX_NATIVE native, const char *format, va_list args)
 C++ wrapper around sampgdk_InvokeNativeV()
 
bool OnPublicCall (AMX *amx, const char *name, cell *params, cell *retval)
 A generic catch-all callback that gets called whenever some AMX public function is executed. More...
 
bool OnPublicCall2 (AMX *amx, const char *name, cell *params, cell *retval, bool *stop)
 A generic catch-all callback that gets called whenever some AMX public function is executed. More...
 
cell sampgdk_CallNative (AMX_NATIVE native, cell *params)
 Calls a native function. More...
 
AMX_NATIVE sampgdk_FindNative (const char *name)
 Finds a native function by name. More...
 
const AMX_NATIVE_INFO * sampgdk_GetNatives (int *number)
 Returns all currently registered native functions. More...
 
cell sampgdk_InvokeNative (AMX_NATIVE native, const char *format,...)
 Calls a native function with arguments. More...
 
cell sampgdk_InvokeNativeArray (AMX_NATIVE native, const char *format, void **args)
 Calls a native function with an array of arguments. More...
 
cell sampgdk_InvokeNativeV (AMX_NATIVE native, const char *format, va_list args)
 Calls a native function with arguments. More...
 

Detailed Description

Function Documentation

◆ OnPublicCall()

bool OnPublicCall ( AMX *  amx,
const char *  name,
cell *  params,
cell *  retval 
)

A generic catch-all callback that gets called whenever some AMX public function is executed.

This is the publics "filter" callback. It is called whenever the server calls amx_Exec(), which practically means that you can use it to hook any callback, even those that are called by other plugins.

Parameters
amxAMX on which the function is called
namefunction name
paramsfunction arguments as stored on the AMX stack, with params[0] being set to the number of arguments multiplied by sizeof(cell)
retvalwhere to store the return value (can be NULL)
Returns
true if the public is allowed to execute

◆ OnPublicCall2()

bool OnPublicCall2 ( AMX *  amx,
const char *  name,
cell *  params,
cell *  retval,
bool *  stop 
)

A generic catch-all callback that gets called whenever some AMX public function is executed.

This callback is similar to OnPublicCall but also allows you to stop the call from being propagated to other plugins or the gamemode by setting the stop parameter to true.

Parameters
amxAMX on which the function is called
namefunction name
paramsfunction arguments as stored on the AMX stack, with params[0] being set to the number of arguments multiplied by sizeof(cell)
retvalwhere to store the return value (can be NULL)
stopwhether to stop public call propagation (false by default)
Returns
true if the public is allowed to execute

◆ sampgdk_CallNative()

cell sampgdk_CallNative ( AMX_NATIVE  native,
cell *  params 
)

Calls a native function.

This function is suitable for calling simple natives that either have only value parameters or don't have any parameters at all. If you have to pass a reference or a string use sampgdk_InvokeNative() instead.

Note
The first element of params must contain the number of arguments multiplied by sizeof(cell).
Parameters
nativepointer to the native function
paramsparameters to be passed to the function as its second argument
Returns
function's return value
See also
sampgdk_GetNatives()
sampgdk_FindNative()
sampgdk_InvokeNative()

◆ sampgdk_FindNative()

AMX_NATIVE sampgdk_FindNative ( const char *  name)

Finds a native function by name.

Searches for a native function with the specified name and returns its address. In order to be found the function must be registered with amx_Register() prior to the call.

Parameters
namename of the native function
Returns
function's address or NULL if not found
See also
sampgdk_GetNatives()
sampgdk_CallNative()
sampgdk_InvokeNative()

◆ sampgdk_GetNatives()

const AMX_NATIVE_INFO * sampgdk_GetNatives ( int *  number)

Returns all currently registered native functions.

This function can be used to get the names and addresses of all native functions that have been registered with amx_Register(), by both the server and plugins.

Note
The returned array is NULL-terminated.
Parameters
numberwhere to store the number of natives (optional).
Returns
pointer to array of registered native functions
See also
sampgdk_FindNative()
sampgdk_CallNative()
sampgdk_InvokeNative()

◆ sampgdk_InvokeNative()

cell sampgdk_InvokeNative ( AMX_NATIVE  native,
const char *  format,
  ... 
)

Calls a native function with arguments.

Argument types are specified via format where each character, or specifier, corresponds to a single argument. The following format specifiers are supported:

Specifier C/C++ type Description
i int integer value
d int integer value (same as 'i')
b bool boolean value
f double floating-point value
r const cell * const reference (input only)
R cell * non-const reference (both input and output)
s const char * const string (input only)
S char * non-const string (both input and output)
a const cell * const array (input only)
A cell * non-const array (both input and output)
Remarks
For the 'S', 'a' and 'A' specifiers you have to specify the size of the string/array in square brackets, e.g. "a[100]" (fixed size) or s[*2] (size passed via 2nd argument).
Note
In Pawn variadic functions always take their variable arguments (those represented by "...") by reference. This means that for such functions you have to use the 'r' specifier where you would normally use 'b', 'i' 'd' or 'f'.
Parameters
nativepointer to the native function.
formatargument types
...arguments themselves
Returns
function's return value
See also
sampgdk_GetNatives()
sampgdk_FindNative()
sampgdk_InvokeNativeV()
sampgdk_InvokeNativeArray()

◆ sampgdk_InvokeNativeArray()

cell sampgdk_InvokeNativeArray ( AMX_NATIVE  native,
const char *  format,
void **  args 
)

Calls a native function with an array of arguments.

This function is similar to sampgdk_InvokeNative() but the arguments are passed as an array where each element is a pointer pointing to the actual value.

Argument types are specified via format where each character, or specifier, corresponds to a single argument. See sampgdk_InvokeNative() for the list of supported format specifiers.

Parameters
nativepointer to the native function.
formatargument types
argsarguments themselves
Returns
function's return value
See also
sampgdk_GetNatives()
sampgdk_FindNative()
sampgdk_InvokeNative()

◆ sampgdk_InvokeNativeV()

cell sampgdk_InvokeNativeV ( AMX_NATIVE  native,
const char *  format,
va_list  args 
)

Calls a native function with arguments.

This function is identical to sampgdk_InvokeNative() except it takes va_list instead of variable arguments.

See also
sampgdk_GetNatives()
sampgdk_FindNative()
sampgdk_InvokeNative()
sampgdk_InvokeNativeArray()