https://wiki.alliedmods.net/api.php?action=feedcontributions&user=Suicid3&feedformat=atomAlliedModders Wiki - User contributions [en]2024-03-29T08:17:52ZUser contributionsMediaWiki 1.31.6https://wiki.alliedmods.net/index.php?title=Module_Writing_(AMX_Mod_X)&diff=3439Module Writing (AMX Mod X)2006-10-17T13:44:56Z<p>Suicid3: </p>
<hr />
<div>AMX Mod X Modules are written in C or C++ (the API is C compatible).<br />
<br />
For more information, look in: [http://svn.tcwonline.org/viewvc.cgi/trunk/amxmodx/sdk/?root=amxmodx /svn.tcwonline.org/viewvc.cgi/trunk/amxmodx/sdk/?root=amxmodx] or [http://svn.tcwonline.org/viewvc.cgi/trunk/amxmodx/sdk.tar.gz?root=amxmodx&view=tar click here] to download a tarball of that directory.<br />
<br />
Copy these files into a new folder. The amxxmodule.h/cpp files are the Module SDK backend. You only need to edit the moduleconfig.h file to customize your module. <br />
<br />
You can read howto.txt for some brief information.<br />
<br />
{{Template:Stub}}<br />
<br />
[[Category:AMX_Mod_X]]</div>Suicid3https://wiki.alliedmods.net/index.php?title=Module_Writing_(AMX_Mod_X)&diff=3438Module Writing (AMX Mod X)2006-10-17T13:43:30Z<p>Suicid3: </p>
<hr />
<div>AMX Mod X Modules are written in C or C++ (the API is C compatible).<br />
<br />
For more information, look in: [http://svn.tcwonline.org/viewvc.cgi/trunk/amxmodx/sdk/?root=amxmodx /svn.tcwonline.org/viewvc.cgi/trunk/amxmodx/sdk/?root=amxmodx]<br />
<br />
Copy these files into a new folder. The amxxmodule.h/cpp files are the Module SDK backend. You only need to edit the moduleconfig.h file to customize your module. <br />
<br />
You can read howto.txt for some brief information.<br />
<br />
{{Template:Stub}}<br />
<br />
[[Category:AMX_Mod_X]]</div>Suicid3https://wiki.alliedmods.net/index.php?title=AMX_Mod_Compatibility_Layer_(AMX_Mod_X)&diff=3426AMX Mod Compatibility Layer (AMX Mod X)2006-09-27T04:58:22Z<p>Suicid3: /* User List */</p>
<hr />
<div>As of 1.76, AMX Mod X has an AMX Mod backward compatibility layer. This layer has two goals. The first goal is API compatibility: AMX Mod plugins should compile without modification and subsequently run normally on AMX Mod X. The second goal is ABI compatibility: AMX Mod plugins should run as raw '.amx' files, ''without recompilation'', on AMX Mod X.<br />
<br />
This current status of this side project is experimental. While it will work for most plugins, there may be niches or obscure details yet unresolved. <br />
<br />
=How to Use/Enable=<br />
Simply make sure '<tt>amxmod_compat.amxx</tt>' is in your plugins folder and enabled in <tt>configs/plugins.ini</tt>. It comes with AMX Mod X but is disabled by default.<br />
<br />
<br />
=List of Tested Plugins=<br />
The following is a list of plugins that have been verified as working. (D) denotes a default plugin shipped with AMX Mod.<br />
<br />
==Dev Team List==<br />
*Source+Binary Compatible<br />
**admin (D)<br />
**admin SQL (D)<br />
**adminchat (D)<br />
**adminhelp (D)<br />
**adminslots (D)<br />
**adminvote (D)<br />
**antiflood (D)<br />
**[http://djeyl.net/forum/index.php?showtopic=40627 hackmod]<br />
**[http://djeyl.net/forum/index.php?showtopic=44605 sentryguns]<br />
**[http://djeyl.net/forum/index.php?showtopic=51679 shoot_at_nades]<br />
**[http://djeyl.net/forum/index.php?showtopic=39972 ultimate_c4]<br />
*Source Compatible Only<br />
**admincmd (D)<br />
**cmdmenu (D)<br />
**statscfg (D)<br />
*No Compatibility<br />
**--<br />
<br />
==User List==<br />
*Source+Binary Compatible<br />
**--<br />
*Source Compatible Only<br />
**--<br />
*No Compatibility<br />
**[http://djeyl.net/forum/index.php?showtopic=42303 Change_Models]<br />
<br />
=Makeshift Features/Tracker=<br />
*VexdUM Port<br />
**Natives<br />
***Engine's entity_[g|s]_*() natives should no longer bail out if the player is not ingame.<br />
***radius_damage replacement ('''NOTE''' port done in Engine)<br />
***traceresult and its related natives<br />
***get/set offset functions<br />
***'''TODO:''' Port the TFC natives.<br />
**Forwards<br />
***All done but monster_hurt.<br />
*MySQL Port<br />
**Entirely done.<br />
*Fun Port<br />
**Unknown<br />
*Core Port<br />
**Translator functionality nearly complete. Helper functions not done yet.<br />
**Added detection for AMX Mod's localinfo keys.<br />
**Math functions ported.<br />
<br />
<br />
=Userland Information=<br />
==Language Files==<br />
AMX Mod language files, if needed, can be used. They are marshalled by the bcompat plugin and it must be loaded. Simply place the files in <tt>amxmodx/data/amxmod-lang/</tt>. You do not need to modify or rename them.<br />
<br />
==localinfo/core.ini==<br />
Localinfo support is marshalled by core. If you have copied your core.ini from AMX Mod, you will want to change the paths to match your AMX Mod X installation.<br />
<br />
<br />
=Technical/Coding Details=<br />
The AMX Mod compatibility layer (codenamed 'bcompat') is largely done through a plugin called amxmod_bcompat. Our goal was to keep C++ editing to a minimum. Unfortunately, there are a few limited things that could only be done in C++. However, keeping the majority of code in a plugin reduces the amount of work ordinary plugin developers need to add features or fix problems. It also makes it easy to centralize the system rather than adding spidery code across modules.<br />
<br />
==Internal Compatibility (Core)==<br />
Core adds specific backwards compatibility for plugins detected as AMX Mod plugins. It has two methods of detection. On detection, the plugin is flagged with <tt>AMX_FLAG_OLDFILE</tt>.<br />
*Any plugin being loaded with a '.amx' extension is flagged as a bcompat plugin. Although this extension was used with AMX Mod X 0.16, the core version was similar enough to AMX Mod 0.9.7 that the time gap should be about the same. <br />
*Plugins recompiled while including 'amxmod.inc' automatically get a special identifier added to their public variable table. Core identifies any plugin carrying this identifier and flags it as a bcompat plugin.<br />
<br />
Plugins flagged as bcompat act almost entirely the same. The two major differences are in which natives they are allowed to use and how they format strings.<br />
<br />
===Translator===<br />
AMX Mod's translator can be broken into two pieces. The first is the file format, which must be loaded and added to a database. The second is the actual translation API itself and how plugins use it.<br />
<br />
====File Format====<br />
The file format is completely loaded and parsed by the bcompat plugin. The translation key pairs are added to the internal AMX Mod X storage engine through the <tt>CreateLangKey()</tt> and <tt>AddTranslation()</tt> natives. As noted earlier, the files are loaded from <tt><i>amxx_datadir</i>/amxmod-lang/</tt>.<br />
<br />
====Backend Translation====<br />
The backend is provided through Core. The <tt>_T()</tt> stock remains and the <tt>translate()</tt> is provided to all plugins (whether having <tt>AMX_FLAG_OLDFILE</tt> or not). The translate native takes in the translation info and creates a unique translation identifier returned to the plugin for use with the '%s' format specifier. If the <tt>get_amxstring()</tt>, <tt>get_amxstring_r()</tt>, or <tt>format()</tt> routines are used from a flagged plugin, and one of these unique identifiers is used for '%s', the identifier is decoded and translated.<br />
<br />
'''Note:''' The current implementation has restrictions, which are in-place due to the way the AMX Mod translation system is written. The backwards compatibility layer will fail to translate any translation key past the <tt>4,095</tt>th entry. Furthermore, it will fail to translate any language with a language id of above 30.<br />
<br />
===Native Restrictions===<br />
There are some natives for which backwards compatibility cannot be added easily. An example of this is <tt>DispatchKeyValue()</tt>, which has completely different calling conventions between mods. A new module function exported from Core, <tt>MF_AddNewNatives()</tt>, lets modules add lists of natives that can only be used by non-AMX Mod compatibility flagged plugins. This lets Engine specify that its version of <tt>DispatchKeyValue()</tt> should only be used with newer plugins, so the bcompat plugin can provide its own version.<br />
<br />
==ABI/API Compatibility==<br />
There are two major sides to plugin compatibility: Source, and Binary. Binary compatible deals with making sure compiled plugins have all of their natives and forwards available. Source compatible means making sure plugins can compile and work as-is. The bcompat layer deals with both.<br />
<br />
For source compatibility, all stocks are mimicked from their original includes into the AMX Mod compatibility includes. Natives that can be wrapped around original AMX Mod X natives are implemented as stocks. This means that recompiling plugins from AMX Mod has relatively low overhead, as most natives are simply stock wrappers.<br />
<br />
For binary compatibility, both forwards and natives must be considered. Natives are implemented as dynamic natives. If they already exist as an AMX Mod compatibility stock, they simply wrap the stock. For example, <tt>get_offset_int()</tt> is implemented as a stock. However, the name <tt>get_offset_int</tt> is also registered as a dynamic native. Internally, it simply calls the <tt>get_offset_int()</tt> stock. For natives which require more complexity, there are no stocks, and they are implemented entirely as dynamic natives. For example, traceresult is implemented this way.<br />
<br />
Forwards are implemented as calls to <tt>CreateMultiForward()</tt> and <tt>ExecuteForward()</tt>.<br />
<br />
In short, the majority of functions are implemented "twice" - as stocks, for recompiling plugins, and as natives, for not recompiling plugins. The duality lets you have flexibility. You can recompile for extra speed (dynamic natives are considered expensive) or run straight binaries for ease of use.<br />
<br />
==Compiling/Editing==<br />
The amxmod_compat.sma file is the main file to compile when compiling the compatibility plugin. You should not attempt to compile core.sma, vexdum.sma, mysql.sma, or anything else that may be there. <br />
<br />
When editing the compatibility layer, it is organized into separate .sma files, which are included into the main amxmod_compat.sma file. They are named .sma rather than .inc for two reasons: they're technically not include files, and some editors have syntax highlighting for .sma but not .inc.<br />
<br />
The include files are located in include/amxmod_compat. The 1.76 compiler automatically searches the amxmod_compat include folder, so you do not need to move files around.</div>Suicid3https://wiki.alliedmods.net/index.php?title=Advanced_Scripting_(AMX_Mod_X)&diff=3223Advanced Scripting (AMX Mod X)2006-08-16T16:42:13Z<p>Suicid3: /* SQL Support */</p>
<hr />
<div>This article will briefly summarize some of the more advanced topics of [[:Category:Scripting (AMX Mod X)|AMX Mod X Scripting]].<br />
<br />
=Tasks=<br />
<br />
Tasks are timers that let you run code at an interval, either once or repeated. They are useful for things like waiting a few seconds, setting objects to destroy themselves, or just repeating a task over and over.<br />
<br />
A task can be set in a number of different ways. The actual function is set_task():<br />
<pawn>set_task(Float:time,const function[],id = 0,parameter[]="",len = 0,flags[]="", repeat = 0)</pawn><br />
<br />
The parameters break down as such:<br />
<br />
* Float:time - Interval of timer in seconds (minimum 0.1 seconds)<br />
* function[] - A string that contains the public function to run on the timer<br />
* id - A unique id to assign to the task<br />
* parameter - An array contain data to send to the timer function<br />
* len - Size of the array to send to the timer function<br />
* flags - One of the following:<br />
** "a" - Repeat task a specified number of times<br />
** "b" - Loop task infinitely<br />
** "c" - do task on time after a map timeleft<br />
** "d" - do task on time before a map timeleft<br />
* repeat - If flags is "a", specifies the number of times to repeat the task<br />
<br />
An example of a task is below. It will slap a specified player 5 times, once per second.<br />
<br />
<pawn>//the timed function receives the parameter array and its task id<br />
public slapTask(params[], id)<br />
{<br />
new player = params[0]<br />
user_slap(player, 5)<br />
}<br />
<br />
public start_slapping(id)<br />
{<br />
new params[1]<br />
params[0] = id<br />
//we don't need a specific id<br />
set_task(1.0, "slapTask", 0, params, 1, "a", 5)<br />
}<br />
</pawn><br />
<br />
Note that if you specify 0 for parameter length, then the task function should look like:<br />
<br />
<pawn>public slapTask(id)</pawn><br />
<br />
<br />
=Menus=<br />
<br />
Menus are HUD messages that give a player a choice of options to select. They are quite messy to deal with but can be very useful for things like voting and command selection.<br />
<br />
Menus must be registered by two things - a set of "keys" that tells how many options to register and a string which identifies the menu as unique. This string must appear in the beginning of every menu you want to trigger your function. When you display a menu, you can show it to one or more players. Once they hit a key, the result of their key press will be sent to the function you registered the menu to.<br />
<br />
For our example, we'll make a menu that displays a list of guns: AK47, M4A1, or AWP, to a player. Whichever he selects, he will be given.<br />
<br />
<pawn>#include <amxmodx><br />
#include <amxmisc><br />
#include <fun><br />
public plugin_init()<br />
{<br />
register_plugin("Menu Demo", "1.0", "BAILOPAN")<br />
new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2<br />
register_menucmd(register_menuid("Which Weapon?"), keys, "giveWeapon")<br />
}<br />
</pawn><br />
<br />
Two commands are apparent here - register_menuid and register_menucmd. register_menuid registers a short phrase that will appear at the beginning of the menu, then returns an id. This id is the first parameter to register_menucmd. The second parameter to register_menucmd is the key configuration. Our menu will have three options, so we've added three menu keys in. In actuality, these are bitwise flags totalling "7", but that's not important. The last parameter is the public function that will handle the menu results.<br />
<br />
Next, how do we show the menu? Let's make a quick console command: "giveme".<br />
<br />
<pawn>public plugin_init()<br />
{<br />
register_plugin("Menu Demo", "1.0", "BAILOPAN")<br />
new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2<br />
register_menucmd(register_menuid("Which Weapon?"), keys, "giveWeapon")<br />
register_clcmd("giveme", "showWeaponMenu")<br />
}<br />
</pawn><br />
<br />
register_clcmd is similar to register_concmd, except it only takes two parameters. It's used to register any command a client can use (except for special ones, like +attack).<br />
<br />
<pawn>//The clcmd function will just give us the player id<br />
public showWeaponMenu(id)<br />
{<br />
new menu[192]<br />
new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2<br />
<br />
format(menu, 191, "Which Weapon?^n^n1. AK47^n2. M4A1^n3. AWP")<br />
show_menu(id, keys, menu)<br />
return PLUGIN_HANDLED<br />
}<br />
<br />
//Our menu function will get the player id and the key they pressed<br />
public giveWeapon(id, key)<br />
{<br />
//key will start at zero<br />
if (key == 0)<br />
{<br />
give_item(id, "weapon_ak47")<br />
} else if (key == 1) {<br />
give_item(id, "weapon_m4a1")<br />
} else if (key == 2) {<br />
give_item(id, "weapon_awp")<br />
}<br />
}<br />
</pawn><br />
<br />
And we're done! The format line may be a little confusing. The "^n" means "new line", so the menu looks nicely formatted. You can use other modifiers in VGUI2 mods, such as "\w" for white text, "\r" for red text, and "\y" for yellow text. When a player types the command, he will see the menu. When he hits a key, the giveWeapon function will receive his id and the key number he pressed. Then he will get a gun corresponding to what he chose.<br />
<br />
=Events/Messages=<br />
<br />
For this demonstration, we're going to extend the above example. Every time a player respawns, he will be shown the menu to choose a weapon (note - we're ignoring other things like blocking buying and removing buyzones, this is just a demonstration).<br />
<br />
Messages are a way for Half-Life clients to talk to servers, and vice versa. They are specially formatted lists of parameters. For example, the message "DeathMsg" (message id 83) has three parameters: Attacker (byte), Victim (byte), and Weapon (string). You can either capture messages or send them. Here, we'll do a simple demonstration of both. First let's make it so a user gets their gun menu when they spawn.<br />
<br />
<pawn>public plugin_init()<br />
{<br />
register_plugin("Menu Demo", "1.0", "BAILOPAN")<br />
new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2<br />
register_menucmd(register_menuid("Which Weapon?"), keys, "giveWeapon")<br />
//flags - b means "sent to one target", e means "target is alive"<br />
//this event is sent when a player spawns<br />
register_event("ResetHUD", "hook_hud", "be")<br />
}<br />
<br />
public hook_hud(id)<br />
{<br />
//since we specify no parameters to the task,<br />
//the task id will be given to the function<br />
//this is useful because we can reuse our old<br />
//show menu function which takes an id<br />
set_task(0.2, "showWeaponMenu", id)<br />
}<br />
</pawn><br />
<br />
Note that we've set a small delay when we receive the message - this is to make sure that the user has had time to respawn. register_event can take more parameters in order to help restrict the event you catch - for example only matching certain parameters. You can read more about this in the function reference.<br />
<br />
Now, let's say we want to figure out when a player has died...<br />
<br />
<pawn>public plugin_init()<br />
{<br />
register_plugin("Message Demo", "1.0", "BAILOPAN")<br />
//this message informs everyone of a death, so we use<br />
// flag "a" - global event<br />
register_event("DeathMsg", "hook_death", "a")<br />
}<br />
<br />
public hook_death()<br />
{<br />
new Killer = read_data(1) //get the first message parameter<br />
new Victim = read_data(2) //get the second message parameter<br />
new headshot = read_data(3) //was this a headshot?<br />
new weapon[32]<br />
read_data(4, weapon, 31) //get the weapon name<br />
}<br />
</pawn><br />
<br />
Or, let's say we want to make a simple function for generating a death message:<br />
<br />
<pawn>stock make_deathMsg(Killer, Victim, const weapon[])<br />
{<br />
//message_begin starts a message. NEVER start two messages at once.<br />
//MSG_ALL means send the message to everyone<br />
//get_user_msgid returns the id of a message name<br />
//{0,0,0} is the origin vector - not used here<br />
//0 is the target - no specific target here<br />
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0) <br />
write_byte(Killer)<br />
write_byte(Victim)<br />
write_string(weapon)<br />
message_end()<br />
}<br />
</pawn><br />
<br />
To find more about messages, consult the HLSDK, AMX Mod X forums, HL-related programming sites, or other plugins. To list the messages a mod has, type "meta game" in the server console (with metamod loaded). You can also use register_message, the more advanced message disection method found in the Engine module.<br />
<br />
=Catching Log Messages=<br />
<br />
Catching log messages is not used heavily any more, but it's still good to know how to do it. As log messages are sent by the mod, AMX Mod X will be able to catch them and let you hook them. For our example, let's give everyone $16,000 on round start.<br />
<br />
The log messages for rounds are sent like this: World triggered "Round_Start". AMX Mod X will consider "World_triggered" as the first parameter and "Round_Start" as the second parameter. So:<br />
<br />
<pawn>#include <amxmodx><br />
<br />
public plugin_init()<br />
{<br />
register_plugin("Log Demo", "1.0", "BAILOPAN")<br />
//this will filter for two parameters<br />
//roundstart is the public function<br />
register_logevent("roundstart", 2, "0=World triggered", "1=Round_Start")<br />
}<br />
<br />
public roundstart()<br />
{<br />
//set a small delay to make sure everyone spawns<br />
set_task(1.0, "roundDelay")<br />
}<br />
<br />
public roundDelay(taskId)<br />
{<br />
new players[32], num<br />
get_players(players, num)<br />
new i<br />
for (i=0; i<num; i++)<br />
{<br />
cs_set_user_money(players[i], 16000)<br />
}<br />
}<br />
</pawn><br />
<br />
You can also read specific log parameters with read_logdata(), which can only be used inside the "plugin_log()" forward:<br />
<br />
<pawn>//receives all log messages<br />
public plugin_log()<br />
{<br />
new data[32]<br />
read_logdata(data, 31)<br />
}<br />
</pawn><br />
<br />
<br />
=Multi-Lingual Support=<br />
<br />
Adding multi-lingual support to a plugin can be difficult, but it's usually worth it if you have clients who are willing to translate your strings into their native language.<br />
<br />
The first step is to identify what needs to be translated. Say you have a call like this:<br />
<br />
<pawn>new score = get_score()<br />
client_print(id, print_chat, "[AMXX] Your score is %d", score)<br />
</pawn><br />
<br />
This is a good candidate for being multi-lingual. First, create a .txt file (preferrably named after your plugin) and store it in addons\amxmodx\data\lang\. Let's use "myplugin.txt" for the example. For each language, add an entry to the file. Entries are set up as 'keys', which are matched to 'translation strings'. Observe:<br />
<br />
<pre>(addons\amxmodx\data\lang\myplugin.txt)<br />
<br />
[en]<br />
SCORE_MSG = Your score is %d<br />
<br />
[de]<br />
SCORE_MSG = Ihr Spielergebnis ist %d<br />
<br />
[es]<br />
SCORE_MSG = Su cuenta es %d<br />
<br />
[fr]<br />
SCORE_MSG = Votre score est %d<br />
</pre><br />
<br />
Then, in plugin_init(), you must register the language keys:<br />
<br />
<pawn>public plugin_init()<br />
{<br />
...<br />
//assumes placed in amxmodx\data\lang<br />
register_dictionary("myplugin.txt")<br />
}<br />
</pawn><br />
<br />
Now, here comes the hard part. AMX Mod X's Multi-Lingual API is built into the format() style routines. For anything that looks like or uses format()-style strings, you can use the ML API.<br />
<br />
<pawn> client_print(id, print_chat, "[AMXX] %L", id, "SCORE_MSG", get_score())<br />
</pawn><br />
<br />
Let's break this down. For each %L that appears, we need at least two parameters. The first parameter is the TARGET. This must be a player id, LANG_SERVER (meaning show in the server's native language), or LANG_PLAYER. LANG_PLAYER is a special modifier that should only be used when sending a message to all players - it means "show in every player's native language". The second parameter is the key string that identifies the language phrase to translate. Lastly, if the translated string requires any parameters itself (ours needs %d, one integer), that must be added as well.<br />
<br />
You can get very complicated designs with this, but it's recommended that you keep things simple for clarity. Here is a final example using a global message to all players, assuming the key HELLO is properly translated in all the languages available:<br />
<br />
<pawn> client_print(0, print_chat, "[AMXX] %L", LANG_PLAYER, "HELLO")<br />
</pawn><br />
<br />
=SQL Support=<br />
<br />
SQL support has greatly improved in AMX Mod X. There is a common set of natives that work with a single driver, so as long as one (and only one) SQL module is loaded, the SQL (or DBI) natives will work. Here is a short primer on how to use the DBI natives:<br />
<br />
<pawn>//Create a connection<br />
new Sql:mysql = dbi_connect("localhost", "dvander", "pass", "dbase")<br />
<br />
//If the connection is less than 1, it is bad <br />
if (mysql < SQL_OK) {<br />
new err[255]<br />
new errNum = dbi_error(mysql, err, 254)<br />
server_print("error1: %s|%d", err, errNum)<br />
return 1<br />
}<br />
<br />
server_print("Connection handle: %d", mysql)<br />
//Run a query<br />
new Result:ret = dbi_query(mysql, "INSERT INTO config (keyname, val) VALUES ('amx', 'yes')")<br />
<br />
//If the query is less than RESULT_NONE, it failed <br />
if (ret < RESULT_NONE) {<br />
new err[255]<br />
new errNum = dbi_error(mysql, err, 254)<br />
server_print("error2: %s|%d", err, errNum)<br />
return 1<br />
}<br />
<br />
//Do a select query <br />
new Result:res = dbi_query(mysql, "SELECT * FROM config")<br />
<br />
//If the query is less than or equal to RESULT_FAILED, you got an invalid result and can't do anything with it.<br />
if (res <= RESULT_FAILED) {<br />
new err[255]<br />
new errNum = dbi_error(mysql, err, 254)<br />
server_print("error3: %s|%d", err, errNum)<br />
return 1<br />
}<br />
<br />
server_print("Result handle: %d", res)<br />
<br />
//Loop through the result set <br />
while (res && dbi_nextrow(res)>0) {<br />
new qry[32]<br />
//Get the column/field called "keyname" from the result set<br />
dbi_result(res, "keyname", qry, 32)<br />
server_print("result: %s", qry)<br />
}<br />
<br />
//Free the result set <br />
dbi_free_result(res)<br />
<br />
//Close the connection <br />
ret = dbi_close(mysql)<br />
if (ret <= RESULT_NONE) {<br />
new err[255]<br />
new errNum = dbi_error(mysql, err, 254)<br />
server_print("error4: %s|%d", err, errNum)<br />
return 1<br />
}<br />
</pawn><br />
<br />
=Regular Expressions=<br />
<br />
Regular Expressions let you describe ways in which to break down strings. They are extremely powerful. AMX Mod X uses the Perl Compatible RE library, you can read the specifics at their site. AMX Mod X offers regular expressions with the regex_amxx module. Here is a short example:<br />
<br />
<pawn>#include <amxmodx><br />
#include <regex><br />
<br />
public plugin_init()<br />
{<br />
register_plugin("Regex", "1.0", "BAILOPAN")<br />
register_srvcmd("amx_regex", "cmdtest")<br />
}<br />
<br />
public cmdtest()<br />
{<br />
new str[] = "It's Walky!"<br />
//this pattern will match any string which contains<br />
// two groupings of characters separated by a space<br />
// the two groupings are substrings 1 and 2<br />
new pattern[] = "(.+) (.+)"<br />
<br />
new num, error[128]<br />
//str = string<br />
//pattern = pattern to use<br />
//num = special return case code<br />
//error = if there's an error, it will go here<br />
//127 - error's max length<br />
new Regex:re = regex_match(str, pattern, num, error, 127)<br />
<br />
server_print("Result=%d, num=%d, error=%s", re, num, error) <br />
<br />
//REGEX_OK means there was a match<br />
if (re >= REGEX_OK)<br />
{<br />
new str2[64]<br />
new i<br />
//since it returned REGEX_OK, num has<br />
// the number of substrings matched by the pattern.<br />
//the first substring (0) seems to match the whole string.<br />
for (i=0; i<num; i++)<br />
{<br />
regex_substr(re, i, str2, 63)<br />
server_print("Substring %d: %s", i, str2)<br />
}<br />
//the regular expression matcher uses memory.<br />
//you must free it if you get REGEX_OK<br />
//This will also set re to 0.<br />
regex_free(re)<br />
}<br />
<br />
//note the invalid regular expression pattern<br />
//this will return REGEX_PATTERN_FAIL, -1<br />
re = regex_match("Bruno the Bandit", ".+(]", num, error, 127)<br />
<br />
server_print("Result=%d, num=%d, error=%s", re, num, error)<br />
} <br />
</pawn><br />
<br />
If you compile and run this script (amx_regex in server console) you will see the following output:<br />
<br />
<pre><br />
Result=1, num=3, error=<br />
Substring 0: It's Walky!<br />
Substring 1: It's<br />
Substring 2: Walky!<br />
Result=-1, num=4, error=missing ) <br />
</pre><br />
<br />
Note that the third parameter to "regex_match()" is special. It's either the number of substrings, a match error code, or a pattern error position (depending on the return value).<br />
<br />
=Entities=<br />
<br />
Entities are basically any dynamic structure in Half-Life. Players, weapons, grenades, and other little objects laying around are entities. They have a unique "entity id" which you can use to change their values.<br />
<br />
I won't go into this too deeply as it's a complicated subject, but the Engine module features natives that let you modify the properties of entities, or search for entities in game by their class/owner (class is the type of entity, such as "player").<br />
<br />
For this example, we'll make an entity that looks like a fake player holding a gun.<br />
<br />
<pawn> //create a basic entity<br />
entid = create_entity("info_target")<br />
//set its classname<br />
entity_set_string(entid, EV_SZ_classname, "some_guy")<br />
//set its model<br />
entity_set_model(entid, "models/w_suit.mdl")<br />
new Float:Vec[3] = {0.0,0.0,0.0}<br />
//set its origin <br />
entity_set_origin(entid, Vec)<br />
//set some basic properties<br />
entity_set_int(entid, EV_INT_solid, 1)<br />
entity_set_int(entid, EV_INT_movetype, 6)<br />
//create the weapon - thanks to pimp_daddy!<br />
entWeapon = create_entity("info_target")<br />
entity_set_string(entWeapon, EV_SZ_classname, weapString)<br />
//set to follow<br />
entity_set_int(entWeapon, EV_INT_movetype, MOVETYPE_FOLLOW)<br />
entity_set_int(entWeapon, EV_INT_solid, SOLID_NOT)<br />
entity_set_edict(entWeapon, EV_ENT_aiment, entid)<br />
entity_set_model(entWeapon, "models/p_m4a1.mdl") <br />
</pawn><br />
<br />
You can also change other basic things, such as:<br />
<br />
<pawn>//how set_user_armor() works in the fun module<br />
stock set_armor(player, Float:value)<br />
{<br />
entity_set_int(player, EV_FL_armorvalue, value)<br />
}<br />
</pawn><br />
<br />
<br />
=FakeMeta=<br />
<br />
FakeMeta is the next generation of Half-Life scripting. It essentially lets you write MetaMod plugins in Pawn. It is extremely powerful, and for this reason, it won't really be covered here. This is just to tell you what it is capable of.<br />
<br />
* Engine/DLL Calls<br />
**There are two types of functions in the HL namespace - Engine functions and DLL functions (DLL functions are ones the game/mod library must export). Both of these can be called using the FakeMeta module using the dllfunc() and engfunc() natives. The parameters are directly passed on to MetaMod, so be careful! You could easily crash a server doing the wrong thing.<br />
* Engine/DLL Hooks<br />
**As stated above, HL provides Engine and DLL functions. You can also hook/supercede these calls using register_forward. You can supercede these calls using fm_return() and return PLUGIN_HANDLED. Again, make sure you know what you are doing. Malformed hooks will cause crashes.<br />
* Easy entity manipulation<br />
**FakeMeta replaces Engine's entity__() function with a natives called "pev()" and "set_pev()". They are a bit easier to use. For more information see the fakemeta includes.<br />
* Private Offset Hacking<br />
**Private offsets are offsets into a block of memory called "pvPrivateData". The right offsets can often modify game-specific features, such as money in Counter-Strike, or resources in Natural-Selection. However, the wrong offsets can cause game crashes.<br />
<br />
[[Category:Scripting (AMX Mod X)]]</div>Suicid3https://wiki.alliedmods.net/index.php?title=Configuring_AMX_Mod_X&diff=3183Configuring AMX Mod X2006-07-22T06:03:04Z<p>Suicid3: /* SQL */</p>
<hr />
<div>=Admins=<br />
See the section on [[Adding Admins (AMX Mod X)|Adding Admins]] for more information.<br />
<br />
=Plugins=<br />
==Installing==<br />
Often, plugins will have their own directions if they need special installation requirements. However, this will instruct you on the basics of adding a plugin.<br />
#Follow any directions the plugin author has given you. If the plugin requires extra steps or special files, make sure you have them in the proper place and order.<br />
#If you are given a .sma source file instead of a .amxx, you must compile the plugin yourself. For more information, see [[Compiling Plugins (AMX Mod X)]].<br />
#Place the plugin's .amxx file in the addons/amxmodx/plugins folder.<br />
#Add the plugin's name to addons\configs\plugins.ini. Example: <pre>myplugin.amxx</pre><br />
#Restart the server or change maps. If the plugin has any load errors, see [[Troubleshooting AMX Mod X#Plugins]].<br />
<br />
==Removing==<br />
#Remove the entry from addons\amxmodx\configs\plugins.ini by deleting it or prepending a semi-colon to comment it out.<br />
#Delete any associated files.<br />
<br />
==Default Plugins==<br />
:{|<br />
|- class="t2th"<br />
| Plugin<br />
| Purpose<br />
|- class="t2td"<br />
| admin.amxx<br />
| Administration Base<br />
|- class="t2td"<br />
| admin_sql.amxx <br />
| Administration Base for SQL. Use only one base.<br />
|- class="t2td"<br />
| admincmd.amxx <br />
| Basic administration commands (such as kick/slap).<br />
|- class="t2td"<br />
| adminhelp.amxx <br />
| Help for admin commands.<br />
|- class="t2td"<br />
| adminslots.amxx <br />
| Slot reservation.<br />
|- class="t2td"<br />
| multilingual.amxx <br />
| Multi-Lingual client configuration.<br />
|- class="t2td"<br />
| menufront.amxx <br />
| Front-end for admin menus.<br />
|- class="t2td"<br />
| cmdmenu.amxx <br />
| Command menu for settings.<br />
|- class="t2td"<br />
| plmenu.amxx <br />
| Player menu commands (kick, ban, etc).<br />
|- class="t2td"<br />
| telemenu.amxx <br />
| Teleport Menu (fun module required).<br />
|- class="t2td"<br />
| mapsmenu.amxx <br />
| Maps menu (vote, changeleve, etc).<br />
|- class="t2td"<br />
| adminchat.amxx <br />
| Console-based chat commands.<br />
|- class="t2td"<br />
| antiflood.amxx <br />
| Prevents clients from flooding the say chat.<br />
|- class="t2td"<br />
| scrollmsg.amxx <br />
| Displays a scrolling message.<br />
|- class="t2td"<br />
| imessage.amxx <br />
| Displays a centered, timed information message.<br />
|- class="t2td"<br />
| adminvote.amxx <br />
| Voting commands.<br />
|- class="t2td"<br />
| nextmap.amxx <br />
| Displays next map in the mapcycle.<br />
|- class="t2td"<br />
| mapchooser.amxx <br />
| Allows players to vote for the next map.<br />
|- class="t2td"<br />
| timeleft.amxx <br />
| Displays time left on the current map.<br />
|- class="t2td"<br />
| pausecfg.amxx <br />
| Allows pausing/unpausing of plugins.<br />
|- class="t2td"<br />
| statscfg.amxx <br />
| Configuration of statistical plugins.<br />
|}<br />
<br />
=Modules=<br />
Modules add additional functionality for plugins to use.<br />
==Installing==<br />
#Figure out what operating system your server is: Windows, Linux, or Linux using AMD64 (64bit).<br />
#If the module is 3rd party, download the module corresponding to your OS. It will end in .dll for Windows, _i386.so for Linux, or _amd64.so for AMD64.<br />
#Place the file in addons/amxmodx/modules/ and follow any additional instructions.<br />
#If the module is already in addons/amxmodx/configs/modules.ini, remove the ';' next to its name to enable it.<br />
#Otherwise, add the module's name to modules.ini. [[AMX Mod X]] supports generic notation, for example: <pre>mysql_amxx</pre> ... will automatically detect the correct module to use.<br />
#To see if the module is working, you can type <tt>amxx modules</tt> in your [[server console]].<br />
<br />
==Removing==<br />
#Remove the entry from addons\amxmodx\configs\modules.ini by deleting it or prepending a semi-colon to comment it out.<br />
#Delete any associated files if you don't need them.<br />
<br />
==Default Modules==<br />
:{|<br />
|- class="t2th"<br />
| Module<br />
| Purpose<br />
|- class="t2td"<br />
| fun_amxx<br />
| General functions for changing game values.<br />
|- class="t2td"<br />
| engine_amxx<br />
| More advanced functions for getting and setting values in the HL engine.<br />
|- class="t2td"<br />
| fakemeta_amxx<br />
| Expert/advanced functions for manipulating, hooking, and calling functions in the HL engine.<br />
|- class="t2td"<br />
| *sql_amxx<br />
| SQL/Database scripting functions.<br />
|- class="t2td"<br />
| geoip_amxx<br />
| Functions for finding countries by IP address.<br />
|- class="t2td"<br />
| array_amxx<br />
| Functions for somewhat-dynamic arrays.<br />
|- class="t2td"<br />
| sockets_amxx<br />
| Functions for socket (TCP/UDP) control and manipulation.<br />
|- class="t2td"<br />
| regex_amxx<br />
| Functions for regular expression support.<br />
|}<br />
<br />
<br />
=CVARs=<br />
The base [[CVAR]]s AMX Mod X defines are located in amxmodx/configs/amxx.cfg. You can edit these the same way you edit the server.cfg file:<br />
:{|<br />
|- class="t2th"<br />
| CVAR<br />
| Default Setting<br />
| Purpose<br />
|- class="t2td"<br />
| amx_default_access<br />
| "z"<br />
| Sets the default access level for non-admin players.<br />
|- class="t2td"<br />
| amx_password_field<br />
| "_pw"<br />
| Name of the setinfo key which a user should store their password in.<br />
|- class="t2td"<br />
| amx_mode<br />
| 1<br />
| Changes the mode of logging into a server:<br /><br />
0 - Disable logging, players won't be checked and no access will be given.<br /><br />
1 - Normal mode which obeys flags set in accounts.<br /><br />
2 - Kick all players not on the users list.<br />
|- class="t2td"<br />
| amx_show_activity<br />
| 2<br />
| Sets the mode of admin activity on the server:<br /><br />
0 - Disabled<br /><br />
1 - Show action anonymously<br /><br />
2 - Show action with the admin's name<br />
|- class="t2td"<br />
| amx_scrollmsg<br />
| "Welcome to %hostname% -- This server is using AMX Mod X" 600<br />
| Sets the parameters (message and frequency) for a scrolling message.<br />
|- class="t2td"<br />
| amx_imessage<br />
| "Welcome to %hostname" "000255100" <br />"This server is using AMX Mod X\nVisit http://www.amxmodx.org" "00010025"<br />
| Adds a center-typed colored message. The last parameter is in RRRGGGBBB format (red, green, blue).<br />
|- class="t2td"<br />
| amx_freq_imessage<br />
| 180<br />
| Frequency, in seconds, of the colored center messages.<br />
|- class="t2td"<br />
| amx_flood_time<br />
| 0.75<br />
| Chat flood prevention. Sets how fast a player can chat (in seconds).<br />
|- class="t2td"<br />
| amx_reservation<br />
| 0<br />
| Sets the amount of reserved slots.<br />
|- class="t2td"<br />
| amx_time_display<br />
| "ab 1200" "ab 600" "ab 300" "ab 180" "ab 60" "bcde 11"<br />
| Sets flags for remaining time display:<br /><br />
a - Display white text on bottom<br /><br />
b - Use voice<br /><br />
c - Don't add "remaining" in voice<br /><br />
d - Don't add "hours/minutes/seconds" in voice<br /><br />
e - Show/speak if current time is less than set in parameter<br />
|- class="t2td"<br />
| amx_time_voice<br />
| 1<br />
| Sets whether to announce "say thetime" and "say timeleft" with voice.<br />
|- class="t2td"<br />
| amx_vote_delay<br />
| 10<br />
| Sets the minimum delay in seconds between two voting sessions.<br />
|- class="t2td"<br />
| amx_vote_time<br />
| 10<br />
| Sets how long a voting sessions lasts for.<br />
|- class="t2td"<br />
| amx_vote_answers<br />
| 1<br />
| Displays who votes for which options, publically.<br />
|- class="t2td"<br />
| amx_voteban_ratio<br />
| 0.40<br />
| Ratio for a ban vote to be successful.<br />
|- class="t2td"<br />
| amx_votekick_ratio<br />
| 0.40<br />
| Ratio for a kick vote to be successful.<br />
|- class="t2td"<br />
| amx_votemap_ratio<br />
| 0.40<br />
| Ratio for a map vote to be successful.<br />
|- class="t2td"<br />
| amx_vote_ratio<br />
| 0.40<br />
| Ratio for a general vote to be successful.<br />
|- class="t2td"<br />
| amx_extendmap_max<br />
| 90<br />
| Maximum time a mapvote can be extended.<br />
|- class="t2td"<br />
| amx_extendmap_step<br />
| 15<br />
| Amount of time a map extensions adds.<br />
|- class="t2td"<br />
| amx_client_languages<br />
| 1<br />
| Enables or disables the ability for clients to choose their own language.<br />
|- class="t2td"<br />
| amx_debug<br />
| 1<br />
| Sets the debug mode for plugins:<br /><br />
0 - No debugging (warning messages for plugin errors)<br /><br />
1 - Plugins with "debug" option in plugins.ini are put into debug mode.<br /><br />
2 - All plugins are put into debug mode (full backtraces for errors).<br /><br />
Note that debug mode greatly decreases JIT performance.<br />
|- class="t2td"<br />
| amx_mldebug<br />
| 0<br />
| Logs multi-lingual translation problems.<br />
|}<br />
<br />
<br />
=SQL=<br />
Make sure you have mysql_amxx enabled in AMX Mod X's amxmodx/configs/modules.ini file. <br />
<br />
Then, open amxmodx/configs/sql.cfg and edit the cvars accordingly:<br />
<br />
:{|<br />
|- class="t2th" <br />
| CVAR<br />
| Default Setting<br />
| Purpose<br />
|- class="t2td"<br />
| amx_sql_host<br />
| "127.0.0.1"<br />
| IP address of SQL server.<br />
|- class="t2td"<br />
| amx_sql_user<br />
| "root"<br />
| Username to connect to the SQL server.<br />
|- class="t2td"<br />
| amx_sql_pass<br />
| ""<br />
| Password to connect to the SQL server.<br />
|- class="t2td"<br />
| amx_sql_db<br />
| "amx"<br />
| Database to use on the SQL server.<br />
|- class="t2td"<br />
| amx_sql_table<br />
| "admins"<br />
| The table to use for the admin_sql plugin.<br />
|- class="t2td"<br />
| amx_sql_type<br />
| "mysql"<br />
| The database type to connect to.<br />
|}<br />
*Note: amx_sql_type as of AMXX 1.75<br />
<br />
=Maps=<br />
If you use the mapsmenu plugin, you can either use "maps.ini" or "mapcycle.txt" to manage map rotations.<br />
<br />
Delete "maps.ini" to use mapcycle.txt, otherwise, simply add a list of map names to maps.ini like so:<br />
<pre>de_dust<br />
cs_assault<br />
de_aztec</pre><br />
<br />
Et cetera. For each map, you can also add a configuration file that will execute when the map loads. This is useful to set certain settings for 3rd party maps, say, removing the freeze time on fy_iceworld.<br />
<br />
To do this, simply create a folder in amxmodx/configs called "maps" and place a .cfg file named after the map with the settings in it, for example, you might have amxmodx/configs/maps/fy_iceworld.cfg:<br />
<br />
<pre><br />
mp_startmoney 16000<br />
mp_freezetime 0<br />
mp_timelimit 20<br />
</pre><br />
<br />
=Menus=<br />
==Client Commands==<br />
:{|<br />
|-<br />
| class="t2th" | File:<br />
| class="t2td" | addons\amxmodx\configs\clcmds.ini<br />
|-<br />
| class="t2th" | Format: <br />
| class="t2td" | "Name" "Command" "Flags" "Access Level"<br />
|-<br />
| class="t2th" | Options:<br />
| class="t2td" | Name is the name that will appear on the menu.<br /><br />
Command is the format for the console command - you can use %userid% to insert the user's id.<br /><br />
Flags are one of the following:<br /><br />
a - execute from server console.<br /><br />
b - execute from admin console.<br /><br />
c - execute on selected player.<br /><br />
d - display menu again once done<br />
|-<br />
| class="t2th" | Example: <br />
| class="t2td" | "Slay player" "amx_slay #%userid%" "bd" "u"<br />
|}<br />
<br />
==Commands==<br />
:{|<br />
|-<br />
| class="t2th" | File:<br />
| class="t2td" | addons\amxmodx\configs\cmds.ini<br />
|-<br />
| class="t2th" | Format: <br />
| class="t2td" | "Name" "Command" "Flags" "Access Level"<br />
|-<br />
| class="t2th" | Options:<br />
| class="t2td" | Name is the name that will appear on the menu.<br /><br />
Command is the format for the console command - you can use %userid% to insert the user's id.<br /><br />
Flags are one of the following:<br /><br />
a - execute from server console.<br /><br />
b - execute from admin console.<br /><br />
c - execute on selected player.<br /><br />
d - display menu again once done<br />
|-<br />
| class="t2th" | Example: <br />
| class="t2td" | "Pause" "amx_pause" "bd" "u"<br />
|}<br />
<br />
==Configs==<br />
:{|<br />
|-<br />
| class="t2th" | File:<br />
| class="t2td" | addons\amxmodx\configs\configs.ini<br />
|-<br />
| class="t2th" | Format: <br />
| class="t2td" | "Name" "Command" "Flags" "Access Level"<br />
|-<br />
| class="t2th" | Options:<br />
| class="t2td" | Name is the name that will appear on the menu.<br /><br />
Command is the format for the console command.<br />
Flags are one of the following:<br /><br />
a - execute from server console.<br /><br />
b - execute from admin console.<br /><br />
d - display menu again once done<br />
|-<br />
| class="t2th" | Example: <br />
| class="t2td" | "PUBLIC Settings" "servercfgfile server.cfg;exec server.cfg" "a" "u"<br />
|}<br />
<br />
==CVARs==<br />
:{|<br />
|-<br />
| class="t2th" | File:<br />
| class="t2td" | addons\amxmodx\configs\cvars.ini<br />
|-<br />
| class="t2th" | Format: <br />
| class="t2td" | "CVAR" "Values" ... "Access Level"<br />
|-<br />
| class="t2th" | Options:<br />
| class="t2td" | CVAR - the CVAR's name<br /><br />
Values - list of space delimited, quotation enclosed values<br />
|-<br />
| class="t2th" | Example: <br />
| class="t2td" | "mp_autoteambalance" "0" "1" "@" "u"<br />
|}<br />
<br />
==Speech==<br />
:{|<br />
|-<br />
| class="t2th" | File:<br />
| class="t2td" | addons\amxmodx\configs\speech.ini<br />
|-<br />
| class="t2th" | Format: <br />
| class="t2td" | "Name" "Command" "Flags" "Access Level"<br />
|-<br />
| class="t2th" | Options:<br />
| class="t2td" | Name is the name that will appear on the menu.<br /><br />
Command is the format for the console command - you can use %userid% to insert the user's id.<br /><br />
Flags are one of the following:<br /><br />
a - execute from server console<br /><br />
b - execute from admin console<br /><br />
c - execute on selected player<br /><br />
d - display menu again once done<br />
|-<br />
| class="t2th" | Example: <br />
| class="t2td" | "Hello!" "spk \'vox/hello\'" "cd" "u"<br />
|}<br />
<br />
[[Category:Documentation (AMX Mod X)]]</div>Suicid3https://wiki.alliedmods.net/index.php?title=Configuring_AMX_Mod_X&diff=3182Configuring AMX Mod X2006-07-22T06:02:20Z<p>Suicid3: /* SQL */</p>
<hr />
<div>=Admins=<br />
See the section on [[Adding Admins (AMX Mod X)|Adding Admins]] for more information.<br />
<br />
=Plugins=<br />
==Installing==<br />
Often, plugins will have their own directions if they need special installation requirements. However, this will instruct you on the basics of adding a plugin.<br />
#Follow any directions the plugin author has given you. If the plugin requires extra steps or special files, make sure you have them in the proper place and order.<br />
#If you are given a .sma source file instead of a .amxx, you must compile the plugin yourself. For more information, see [[Compiling Plugins (AMX Mod X)]].<br />
#Place the plugin's .amxx file in the addons/amxmodx/plugins folder.<br />
#Add the plugin's name to addons\configs\plugins.ini. Example: <pre>myplugin.amxx</pre><br />
#Restart the server or change maps. If the plugin has any load errors, see [[Troubleshooting AMX Mod X#Plugins]].<br />
<br />
==Removing==<br />
#Remove the entry from addons\amxmodx\configs\plugins.ini by deleting it or prepending a semi-colon to comment it out.<br />
#Delete any associated files.<br />
<br />
==Default Plugins==<br />
:{|<br />
|- class="t2th"<br />
| Plugin<br />
| Purpose<br />
|- class="t2td"<br />
| admin.amxx<br />
| Administration Base<br />
|- class="t2td"<br />
| admin_sql.amxx <br />
| Administration Base for SQL. Use only one base.<br />
|- class="t2td"<br />
| admincmd.amxx <br />
| Basic administration commands (such as kick/slap).<br />
|- class="t2td"<br />
| adminhelp.amxx <br />
| Help for admin commands.<br />
|- class="t2td"<br />
| adminslots.amxx <br />
| Slot reservation.<br />
|- class="t2td"<br />
| multilingual.amxx <br />
| Multi-Lingual client configuration.<br />
|- class="t2td"<br />
| menufront.amxx <br />
| Front-end for admin menus.<br />
|- class="t2td"<br />
| cmdmenu.amxx <br />
| Command menu for settings.<br />
|- class="t2td"<br />
| plmenu.amxx <br />
| Player menu commands (kick, ban, etc).<br />
|- class="t2td"<br />
| telemenu.amxx <br />
| Teleport Menu (fun module required).<br />
|- class="t2td"<br />
| mapsmenu.amxx <br />
| Maps menu (vote, changeleve, etc).<br />
|- class="t2td"<br />
| adminchat.amxx <br />
| Console-based chat commands.<br />
|- class="t2td"<br />
| antiflood.amxx <br />
| Prevents clients from flooding the say chat.<br />
|- class="t2td"<br />
| scrollmsg.amxx <br />
| Displays a scrolling message.<br />
|- class="t2td"<br />
| imessage.amxx <br />
| Displays a centered, timed information message.<br />
|- class="t2td"<br />
| adminvote.amxx <br />
| Voting commands.<br />
|- class="t2td"<br />
| nextmap.amxx <br />
| Displays next map in the mapcycle.<br />
|- class="t2td"<br />
| mapchooser.amxx <br />
| Allows players to vote for the next map.<br />
|- class="t2td"<br />
| timeleft.amxx <br />
| Displays time left on the current map.<br />
|- class="t2td"<br />
| pausecfg.amxx <br />
| Allows pausing/unpausing of plugins.<br />
|- class="t2td"<br />
| statscfg.amxx <br />
| Configuration of statistical plugins.<br />
|}<br />
<br />
=Modules=<br />
Modules add additional functionality for plugins to use.<br />
==Installing==<br />
#Figure out what operating system your server is: Windows, Linux, or Linux using AMD64 (64bit).<br />
#If the module is 3rd party, download the module corresponding to your OS. It will end in .dll for Windows, _i386.so for Linux, or _amd64.so for AMD64.<br />
#Place the file in addons/amxmodx/modules/ and follow any additional instructions.<br />
#If the module is already in addons/amxmodx/configs/modules.ini, remove the ';' next to its name to enable it.<br />
#Otherwise, add the module's name to modules.ini. [[AMX Mod X]] supports generic notation, for example: <pre>mysql_amxx</pre> ... will automatically detect the correct module to use.<br />
#To see if the module is working, you can type <tt>amxx modules</tt> in your [[server console]].<br />
<br />
==Removing==<br />
#Remove the entry from addons\amxmodx\configs\modules.ini by deleting it or prepending a semi-colon to comment it out.<br />
#Delete any associated files if you don't need them.<br />
<br />
==Default Modules==<br />
:{|<br />
|- class="t2th"<br />
| Module<br />
| Purpose<br />
|- class="t2td"<br />
| fun_amxx<br />
| General functions for changing game values.<br />
|- class="t2td"<br />
| engine_amxx<br />
| More advanced functions for getting and setting values in the HL engine.<br />
|- class="t2td"<br />
| fakemeta_amxx<br />
| Expert/advanced functions for manipulating, hooking, and calling functions in the HL engine.<br />
|- class="t2td"<br />
| *sql_amxx<br />
| SQL/Database scripting functions.<br />
|- class="t2td"<br />
| geoip_amxx<br />
| Functions for finding countries by IP address.<br />
|- class="t2td"<br />
| array_amxx<br />
| Functions for somewhat-dynamic arrays.<br />
|- class="t2td"<br />
| sockets_amxx<br />
| Functions for socket (TCP/UDP) control and manipulation.<br />
|- class="t2td"<br />
| regex_amxx<br />
| Functions for regular expression support.<br />
|}<br />
<br />
<br />
=CVARs=<br />
The base [[CVAR]]s AMX Mod X defines are located in amxmodx/configs/amxx.cfg. You can edit these the same way you edit the server.cfg file:<br />
:{|<br />
|- class="t2th"<br />
| CVAR<br />
| Default Setting<br />
| Purpose<br />
|- class="t2td"<br />
| amx_default_access<br />
| "z"<br />
| Sets the default access level for non-admin players.<br />
|- class="t2td"<br />
| amx_password_field<br />
| "_pw"<br />
| Name of the setinfo key which a user should store their password in.<br />
|- class="t2td"<br />
| amx_mode<br />
| 1<br />
| Changes the mode of logging into a server:<br /><br />
0 - Disable logging, players won't be checked and no access will be given.<br /><br />
1 - Normal mode which obeys flags set in accounts.<br /><br />
2 - Kick all players not on the users list.<br />
|- class="t2td"<br />
| amx_show_activity<br />
| 2<br />
| Sets the mode of admin activity on the server:<br /><br />
0 - Disabled<br /><br />
1 - Show action anonymously<br /><br />
2 - Show action with the admin's name<br />
|- class="t2td"<br />
| amx_scrollmsg<br />
| "Welcome to %hostname% -- This server is using AMX Mod X" 600<br />
| Sets the parameters (message and frequency) for a scrolling message.<br />
|- class="t2td"<br />
| amx_imessage<br />
| "Welcome to %hostname" "000255100" <br />"This server is using AMX Mod X\nVisit http://www.amxmodx.org" "00010025"<br />
| Adds a center-typed colored message. The last parameter is in RRRGGGBBB format (red, green, blue).<br />
|- class="t2td"<br />
| amx_freq_imessage<br />
| 180<br />
| Frequency, in seconds, of the colored center messages.<br />
|- class="t2td"<br />
| amx_flood_time<br />
| 0.75<br />
| Chat flood prevention. Sets how fast a player can chat (in seconds).<br />
|- class="t2td"<br />
| amx_reservation<br />
| 0<br />
| Sets the amount of reserved slots.<br />
|- class="t2td"<br />
| amx_time_display<br />
| "ab 1200" "ab 600" "ab 300" "ab 180" "ab 60" "bcde 11"<br />
| Sets flags for remaining time display:<br /><br />
a - Display white text on bottom<br /><br />
b - Use voice<br /><br />
c - Don't add "remaining" in voice<br /><br />
d - Don't add "hours/minutes/seconds" in voice<br /><br />
e - Show/speak if current time is less than set in parameter<br />
|- class="t2td"<br />
| amx_time_voice<br />
| 1<br />
| Sets whether to announce "say thetime" and "say timeleft" with voice.<br />
|- class="t2td"<br />
| amx_vote_delay<br />
| 10<br />
| Sets the minimum delay in seconds between two voting sessions.<br />
|- class="t2td"<br />
| amx_vote_time<br />
| 10<br />
| Sets how long a voting sessions lasts for.<br />
|- class="t2td"<br />
| amx_vote_answers<br />
| 1<br />
| Displays who votes for which options, publically.<br />
|- class="t2td"<br />
| amx_voteban_ratio<br />
| 0.40<br />
| Ratio for a ban vote to be successful.<br />
|- class="t2td"<br />
| amx_votekick_ratio<br />
| 0.40<br />
| Ratio for a kick vote to be successful.<br />
|- class="t2td"<br />
| amx_votemap_ratio<br />
| 0.40<br />
| Ratio for a map vote to be successful.<br />
|- class="t2td"<br />
| amx_vote_ratio<br />
| 0.40<br />
| Ratio for a general vote to be successful.<br />
|- class="t2td"<br />
| amx_extendmap_max<br />
| 90<br />
| Maximum time a mapvote can be extended.<br />
|- class="t2td"<br />
| amx_extendmap_step<br />
| 15<br />
| Amount of time a map extensions adds.<br />
|- class="t2td"<br />
| amx_client_languages<br />
| 1<br />
| Enables or disables the ability for clients to choose their own language.<br />
|- class="t2td"<br />
| amx_debug<br />
| 1<br />
| Sets the debug mode for plugins:<br /><br />
0 - No debugging (warning messages for plugin errors)<br /><br />
1 - Plugins with "debug" option in plugins.ini are put into debug mode.<br /><br />
2 - All plugins are put into debug mode (full backtraces for errors).<br /><br />
Note that debug mode greatly decreases JIT performance.<br />
|- class="t2td"<br />
| amx_mldebug<br />
| 0<br />
| Logs multi-lingual translation problems.<br />
|}<br />
<br />
<br />
=SQL=<br />
Make sure you have mysql_amxx enabled in AMX Mod X's amxmodx/configs/modules.ini file. <br />
<br />
Then, open amxmodx/configs/sql.cfg and edit the cvars accordingly:<br />
<br />
:{|<br />
|- class="t2th" <br />
| CVAR<br />
| Default Setting<br />
| Purpose<br />
|- class="t2td"<br />
| amx_sql_host<br />
| "127.0.0.1"<br />
| IP address of SQL server.<br />
|- class="t2td"<br />
| amx_sql_user<br />
| "root"<br />
| Username to connect to the SQL server.<br />
|- class="t2td"<br />
| amx_sql_pass<br />
| ""<br />
| Password to connect to the SQL server.<br />
|- class="t2td"<br />
| amx_sql_db<br />
| "amx"<br />
| Database to use on the SQL server.<br />
|- class="t2td"<br />
| amx_sql_table<br />
| "admins"<br />
| The table to use for the admin_sql plugin.<br />
|- class="t2td"<br />
| amx_sql_type<br />
| "mysql"<br />
| The database type to connect to.<br />
|}<br />
<br />
=Maps=<br />
If you use the mapsmenu plugin, you can either use "maps.ini" or "mapcycle.txt" to manage map rotations.<br />
<br />
Delete "maps.ini" to use mapcycle.txt, otherwise, simply add a list of map names to maps.ini like so:<br />
<pre>de_dust<br />
cs_assault<br />
de_aztec</pre><br />
<br />
Et cetera. For each map, you can also add a configuration file that will execute when the map loads. This is useful to set certain settings for 3rd party maps, say, removing the freeze time on fy_iceworld.<br />
<br />
To do this, simply create a folder in amxmodx/configs called "maps" and place a .cfg file named after the map with the settings in it, for example, you might have amxmodx/configs/maps/fy_iceworld.cfg:<br />
<br />
<pre><br />
mp_startmoney 16000<br />
mp_freezetime 0<br />
mp_timelimit 20<br />
</pre><br />
<br />
=Menus=<br />
==Client Commands==<br />
:{|<br />
|-<br />
| class="t2th" | File:<br />
| class="t2td" | addons\amxmodx\configs\clcmds.ini<br />
|-<br />
| class="t2th" | Format: <br />
| class="t2td" | "Name" "Command" "Flags" "Access Level"<br />
|-<br />
| class="t2th" | Options:<br />
| class="t2td" | Name is the name that will appear on the menu.<br /><br />
Command is the format for the console command - you can use %userid% to insert the user's id.<br /><br />
Flags are one of the following:<br /><br />
a - execute from server console.<br /><br />
b - execute from admin console.<br /><br />
c - execute on selected player.<br /><br />
d - display menu again once done<br />
|-<br />
| class="t2th" | Example: <br />
| class="t2td" | "Slay player" "amx_slay #%userid%" "bd" "u"<br />
|}<br />
<br />
==Commands==<br />
:{|<br />
|-<br />
| class="t2th" | File:<br />
| class="t2td" | addons\amxmodx\configs\cmds.ini<br />
|-<br />
| class="t2th" | Format: <br />
| class="t2td" | "Name" "Command" "Flags" "Access Level"<br />
|-<br />
| class="t2th" | Options:<br />
| class="t2td" | Name is the name that will appear on the menu.<br /><br />
Command is the format for the console command - you can use %userid% to insert the user's id.<br /><br />
Flags are one of the following:<br /><br />
a - execute from server console.<br /><br />
b - execute from admin console.<br /><br />
c - execute on selected player.<br /><br />
d - display menu again once done<br />
|-<br />
| class="t2th" | Example: <br />
| class="t2td" | "Pause" "amx_pause" "bd" "u"<br />
|}<br />
<br />
==Configs==<br />
:{|<br />
|-<br />
| class="t2th" | File:<br />
| class="t2td" | addons\amxmodx\configs\configs.ini<br />
|-<br />
| class="t2th" | Format: <br />
| class="t2td" | "Name" "Command" "Flags" "Access Level"<br />
|-<br />
| class="t2th" | Options:<br />
| class="t2td" | Name is the name that will appear on the menu.<br /><br />
Command is the format for the console command.<br />
Flags are one of the following:<br /><br />
a - execute from server console.<br /><br />
b - execute from admin console.<br /><br />
d - display menu again once done<br />
|-<br />
| class="t2th" | Example: <br />
| class="t2td" | "PUBLIC Settings" "servercfgfile server.cfg;exec server.cfg" "a" "u"<br />
|}<br />
<br />
==CVARs==<br />
:{|<br />
|-<br />
| class="t2th" | File:<br />
| class="t2td" | addons\amxmodx\configs\cvars.ini<br />
|-<br />
| class="t2th" | Format: <br />
| class="t2td" | "CVAR" "Values" ... "Access Level"<br />
|-<br />
| class="t2th" | Options:<br />
| class="t2td" | CVAR - the CVAR's name<br /><br />
Values - list of space delimited, quotation enclosed values<br />
|-<br />
| class="t2th" | Example: <br />
| class="t2td" | "mp_autoteambalance" "0" "1" "@" "u"<br />
|}<br />
<br />
==Speech==<br />
:{|<br />
|-<br />
| class="t2th" | File:<br />
| class="t2td" | addons\amxmodx\configs\speech.ini<br />
|-<br />
| class="t2th" | Format: <br />
| class="t2td" | "Name" "Command" "Flags" "Access Level"<br />
|-<br />
| class="t2th" | Options:<br />
| class="t2td" | Name is the name that will appear on the menu.<br /><br />
Command is the format for the console command - you can use %userid% to insert the user's id.<br /><br />
Flags are one of the following:<br /><br />
a - execute from server console<br /><br />
b - execute from admin console<br /><br />
c - execute on selected player<br /><br />
d - display menu again once done<br />
|-<br />
| class="t2th" | Example: <br />
| class="t2td" | "Hello!" "spk \'vox/hello\'" "cd" "u"<br />
|}<br />
<br />
[[Category:Documentation (AMX Mod X)]]</div>Suicid3