Natural Selection Amx Module
sawce
Join Date: 2002-12-14 Member: 10787Members
<div class="IPBDescription">To help you crazy AMXers out there.</div> I've been developing an AMX module to help a few of the AMX scripters in modns.org, and I figured a few other people may find some of it's functions handy.
It's currently in a semi-beta stage (it seems stable, I've tested it and a couple others have), however there's no guarantees with it.
<a href='http://www.modns.org/forums/index.php?showtopic=117' target='_blank'>http://www.modns.org/forums/index.php?showtopic=117</a>
Here is a list of natives/forwards:
<!--c1--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
native get_ent(classname[],Value);
native get_class(index);
native get_res(index);
native get_build(classname[],Value);
native set_mask(index,mask,value);
native get_mask(index,mask);
native get_entdat_i(index,Value);
native set_entdat_i(index,Value,iValue);
native Float:get_entdat_f(index,Value);
native set_entdat_f(index,Value,Float:fValue);
native Float:get_entdat_v(index,Value,VecValue);
native set_entdat_v(index,Value,VecValue,Float:fValue);
native get_entdat_e(index,Value);
native set_entdat_e(index,Value,iValue);
native get_entdat_s(index,Value);
native set_entdat_s(index,Value,iValue);
native ns2amx_make_string(svValue[]);
native ns2amx_string(iValue,svReturnedValue[]);
native mdll_spawn(index);
native mdll_touch(Touched,Toucher);
native create_entity(classname[]);
native remove_entity(index);
native Float:gpglobals_time();
native Float:ns2amx_version();
native Float:get_range(ida,idb);
native ns2amx_supercede();
native takedamage(idVictim,idInflictor,idAttacker,Float:damage,damagetype);
forward ns2amx_touch(touchedid,toucherid);
forward ns2amx_pprethink(id);
forward ns2amx_spawn(id);
forward ns2amx_think(id);
<!--c2--></td></tr></table><span class='postcolor'><!--ec2-->
There is also a mini helper function (ns2amx_nspopup(id,svMessage[190])) included in the .inc to allow you to make the little "NS Popups" on the client's HUD.
Read "primer.txt" in the downloaded archive for a comprehensive explaination to all features/natives/helpers.
Full source, a windows and linux build are provided, along with details on each native/forward in the module and a couple examples.
Any bugs with it, please post them on the modns.org forums or email me at steved at crackdealer.com - put "mm_ns2amx" in subject or it will be deleted.
It's currently in a semi-beta stage (it seems stable, I've tested it and a couple others have), however there's no guarantees with it.
<a href='http://www.modns.org/forums/index.php?showtopic=117' target='_blank'>http://www.modns.org/forums/index.php?showtopic=117</a>
Here is a list of natives/forwards:
<!--c1--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
native get_ent(classname[],Value);
native get_class(index);
native get_res(index);
native get_build(classname[],Value);
native set_mask(index,mask,value);
native get_mask(index,mask);
native get_entdat_i(index,Value);
native set_entdat_i(index,Value,iValue);
native Float:get_entdat_f(index,Value);
native set_entdat_f(index,Value,Float:fValue);
native Float:get_entdat_v(index,Value,VecValue);
native set_entdat_v(index,Value,VecValue,Float:fValue);
native get_entdat_e(index,Value);
native set_entdat_e(index,Value,iValue);
native get_entdat_s(index,Value);
native set_entdat_s(index,Value,iValue);
native ns2amx_make_string(svValue[]);
native ns2amx_string(iValue,svReturnedValue[]);
native mdll_spawn(index);
native mdll_touch(Touched,Toucher);
native create_entity(classname[]);
native remove_entity(index);
native Float:gpglobals_time();
native Float:ns2amx_version();
native Float:get_range(ida,idb);
native ns2amx_supercede();
native takedamage(idVictim,idInflictor,idAttacker,Float:damage,damagetype);
forward ns2amx_touch(touchedid,toucherid);
forward ns2amx_pprethink(id);
forward ns2amx_spawn(id);
forward ns2amx_think(id);
<!--c2--></td></tr></table><span class='postcolor'><!--ec2-->
There is also a mini helper function (ns2amx_nspopup(id,svMessage[190])) included in the .inc to allow you to make the little "NS Popups" on the client's HUD.
Read "primer.txt" in the downloaded archive for a comprehensive explaination to all features/natives/helpers.
Full source, a windows and linux build are provided, along with details on each native/forward in the module and a couple examples.
Any bugs with it, please post them on the modns.org forums or email me at steved at crackdealer.com - put "mm_ns2amx" in subject or it will be deleted.
Comments
Changelog from 0.7 -> 0.8:
<!--c1--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
0.8 - 10/27/2003
1. Added string returns for pev data. (get/set_entdat_s)
* Half life strings are stored as integers.
* get_entdat_s(id,Value) - returns the string in int format.
* set_entdat_s(id,Value,iValue) - sets the string as the int format.
* use ns2amx_make_string to convert from string->int, and ns2amx_string to convert from int->string.
2. Added pev edict returning/setting.
* This was in the module for a while, but I forgot to add it into the include file.
* get_entdat_e(id,Value) - see the include file for specific Values.
* set_entdat_e(id,Value,id2) - see include
* This will return the edict's index, not the edict number itself.
3. Added ns2amx_make_string
* Converts a string into HL string format (int).
* Usage: variable = ns2amx_make_string("blah")
4. Added ns2amx_string
* Converts a HL string (int) into a string value.
* Usage:
new svString[32]
ns2amx_string(Value,svString)
- The above will set "svString[]" to the string value.
5. Added "ns2amx_nspopup" helper function. (Not in the module, but public is in the include).
* Displays an NS popup with the specified text (189 characters max).
* If the text is found in "titles.txt", it uses that. Otherwise it displays the text.
* May not always display text properly, thats an NS issue, nothing I can do about it.
- eg: if you send a really really long string of text to the client, it wont display.
* Make sure the text is NO MORE THAN 189 CHARACTERS. (array of 190. All characters (189) + null terminator)
* Format: ns2amx_nspopup(id,"Text to display here NO MORE THAN 189 CHARACTERS")
6. Added random teams example. (All join team portals force you to a random team, and so do jointeamone/jointeamtwo.)
* Shows examples for ns2amx_nspopup, ns2amx_touch, ns2amx_supercede, ns2amx_string, get_entdat_s.
Note: The only pev data not returned currently is the "byte" values. I see no use for them currently,
however, if somebody has a reason for them to go in, inform me and I will add them.
<!--c2--></td></tr></table><span class='postcolor'><!--ec2-->
<a href='http://www.modns.org/forums/index.php?showtopic=117' target='_blank'>http://www.modns.org/forums/index.php?showtopic=117</a>
The natives inside of the module could be called from any AMX plugin.
Right now it supports almost full PEV data setting/retrieving, various hooked functions (forwards): touch, playerprethink, think and spawn, and I just released one which allows for full edict_t->pvPrivateData editing (To allow for alien resource changing, ammunition reserve changing, and the likes.)
It's a little bit on the complex side now, my next release I intend on making some "helper" functions to make developing for it easier.