Added register_native

This commit is contained in:
David Anderson 2005-08-01 02:36:09 +00:00
parent 0086b58f39
commit 0a4133b4d0
2 changed files with 73 additions and 51 deletions

View File

@ -271,3 +271,13 @@ enum {
#define ITEM_ENABLED 1 #define ITEM_ENABLED 1
#define ITEM_DISABLED 2 #define ITEM_DISABLED 2
#define AMX_ERR_NATIVE 10
#define AMX_ERR_MEMACCESS 5
#define AMX_ERR_NONE 0
#define AMX_ERR_BOUNDS 4
#define AMX_ERR_STACKERR 3
#define AMX_ERR_STACKLOW 7
#define AMX_ERR_HEAPLOW 8
#define AMX_ERR_DIVIDE 11
#define AMX_ERR_NOTFOUND 19
#define AMX_ERR_PARAMS 25

View File

@ -212,6 +212,9 @@ native get_user_deaths(index);
/* Sets player deaths. */ /* Sets player deaths. */
native set_user_deaths(index, newdeaths); native set_user_deaths(index, newdeaths);
/* Sets player frags. */
native set_user_frags(index, frags);
/* Returns player health. */ /* Returns player health. */
native get_user_health(index); native get_user_health(index);
@ -516,9 +519,6 @@ native emit_sound(index, channel, sample[], Float:vol, Float:att,flags, pitch);
/* Returns distance between two vectors. */ /* Returns distance between two vectors. */
native get_distance(origin1[3],origin2[3]); native get_distance(origin1[3],origin2[3]);
/* Floating point version */
native Float:get_distance_f(Float:origin1[3], Float:origin2[3]);
/* Registers new cvar for HL engine. */ /* Registers new cvar for HL engine. */
native register_cvar(const name[],const string[],flags = 0,Float:fvalue = 0.0); native register_cvar(const name[],const string[],flags = 0,Float:fvalue = 0.0);
@ -666,10 +666,8 @@ native md5(const szString[], md5buffer[34]);
/* Calculates the md5 keysum of a file */ /* Calculates the md5 keysum of a file */
native md5_file(const file[], md5buffer[34]); native md5_file(const file[], md5buffer[34]);
/* Returns the internal flags set on the called plugin's state /* Returns the internal flags set on the called bytecode structure - Do not use */
* If hdr is 1, it will return the pcode flags rather than state flags. native plugin_flags();
*/
native plugin_flags(hdr=0);
/* When using modules that aren't part of AMX Mod X base package, do /* When using modules that aren't part of AMX Mod X base package, do
* a require_module("modulename") for each of them within the plugin_modules() * a require_module("modulename") for each of them within the plugin_modules()
@ -684,46 +682,60 @@ native is_amd64_server();
/* Returns 0 on success, like the POSIX specification */ /* Returns 0 on success, like the POSIX specification */
native mkdir(const dirname[]); native mkdir(const dirname[]);
/* Returns plugin id searched by file/name. Returns INVALID_PLUGIN_ID on failure. */ /* This is called before plugin_init and allows you to register natives. */
native find_plugin_byfile(const filename[], ignoreCase=1); forward plugin_natives();
/** The new menu natives */ /* Registers a NATIVE. When a plugin uses your native (you should distribute a .inc),
//If you set ml to 1, everything will be preformatted * the handler will be called with two parameters: the calling plugin id, and the
// with the multi-lingual system. * number of parameters.
//NOTE: ml=1 currently is not enabled. * If you set style=1, the method of parameter passing is a tad more efficient.
//handler[] will be called when someone presses a key on your menu * Instead of "id, numParams", you label the native exactly as how the parameters
native menu_create(title[], handler[], ml=0); * should, in theory, be sent. Then for each byreference parameter, you call
* param_convert(num). This is theoretically more efficient but quite hacky.
* The method was discovered by dJeyL, props to him!
*/
native register_native(const name[], const handler[], style=0);
//Creates a menu item callback handler. /* Registers a library. You can put #pragma library <name> in your include files,
//The callback handler is passed the playerid, menuid, and itemid. * and plugins that use your include without loading your plugin will get a nice
//It can return either ITEM_IGNORE, ITEM_ENABLED, or ITEM_DISABLED. * error message.
native menu_makecallback(function[]); */
native register_library(const library[]);
//Adds an item to a menu. When displayed, the name will be shown. /* Logs an error in your native, and breaks into the debugger.
//If the player does not have the access it is disabled. * Acts as if the calling plugin had the error.
//If you set callback, the callback will be called before the item is printed on the screen. */
//this lets you change it in real time depending on conditions. native log_error(error, const fmt[], ...);
native menu_additem(menu, const name[], const command[]="", paccess=0, callback=-1);
//returns how many pages are in a menu // More Dynamic Native System Stuff
native menu_pages(menu); // Each of these natives affects one of the parameters sent to your native.
// Parameters go from 1 to n, just like in modules, and it is important to
// remember two things: The parameters are actually coming from another plugin
// (and just like modules, you must use these special natives).
// two: you CANNOT call your native from inside your native. This is very bad.
//returns how many items are in a menu // This function should only be called if you registered with style=1
native menu_items(menu); native param_convert(num);
//displays a menu to a player // Gets a string from the calling plugin
//page of the menu starts at 0. there are 7 items to a page. native get_string(param, dest[], maxlen);
//back/exit/next/more whatever are automatically added as needed.
//you cannot use this to show a menu to everyone at once!
native menu_display(id, menu, page);
//Given a page on a menu and a keypress on that page, returns the item id selected. // Sets a string in the calling plugin
//if the item is less than 0, a special option was chosen (such as MENU_EXIT) native set_string(param, dest[], maxlen);
native menu_find_id(menu, page, key);
//Gets/sets info about a menu option // Gets a normal int or float parameter
native menu_item_getinfo(menu, item, &access, command[], cmdlen, name[]="", namelen=0, &callback); native get_param(param);
native Float:get_param_f(param);
native menu_item_setname(menu, item, name[]); // Gets/Sets a float or int parameter by reference
native menu_item_setcmd(menu, item, cmd[]); native get_param_byref(param);
native menu_item_setcall(menu, item, callback=-1); native Float:get_float_byref(param);
native set_param_byref(param, value);
native set_float_byref(param, Float:value);
// Copies an array either from the calling plugin to you
// Or copies an array from you to the calling plugin
native get_array(param, dest[], size);
native get_array_f(param, Float:dest[], size);
native set_array(param, source[], size);
native set_array_f(param, Float:source[], size);