Raised This Month: $2 Target: $400
 0% 

AMXx 1.60 Scripting Changes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BAILOPAN
Join Date: Jan 2004
Old 09-11-2005 , 02:01   AMXx 1.60 Scripting Changes
Reply With Quote #1

Upcoming AMX Mod X 1.60 will have a few scripting changes which will greatly improve the power and flexibility of plugins. The Dark Ages of Small are diminishing as AMX Mod X introduces primitive exception handling, control over the module/native system, and client-cvar querying.

Error Filters
Plugins can now trap errors that occur, blocking the debugger/RTE message, and then decide how to handle it. Furthermore, they have access to their own stack traces (which include function names, line numbers, and file names). An example of this is here:

Code:
public plugin_init() {     set_error_filter("error_filter") } public error_filter(err, debugging, msg[]) {     new buffer[512]     dbg_fmt_error(buffer, 511)     if (buffer[0])         server_print("Debug msg: %s", buffer)     if (!debugging)         return PLUGIN_HANDLED     new trace = dbg_trace_begin()     if (!trace)     {         server_print("no trace found!")         return PLUGIN_HANDLED     }         new num = 0     new func[32], file[64], line     while (trace) {         dbg_trace_info(trace, line, func, 31, file, 63)         server_print(" [%d] file: %s func: %s line: %d", num++, file, func, line)         trace = dbg_trace_next(trace)     }         return PLUGIN_HANDLED }

Furthermore, debug traces are now much more informative. Especially with array bounds, error messages are extremely detailed:
Code:
] amx_test
L 09/11/2005 - 00:37:59: [AMXX] Displaying debug trace (plugin "test.amxx")
L 09/11/2005 - 00:37:59: [AMXX] Run time error 4: index out of bounds (array "mylist[2][3][4]") (indexed "[1][2][60]")
L 09/11/2005 - 00:37:59: [AMXX]    [0] test.sma::amx_test (line 24)
(Note the array bounds reporting system is a non-deterministic guess, and if it thinks it will guess incorrectly, does not attempt to report array sizes)

Native/Module Filtering System
With AMX Mod X 1.60, you have total control over the auto-module require system. The biggest usage is that you can make your plugins load even if they use natives or modules that don't exist -- or you can override the errors that occur if they don't.

The two best applications of this system are:
1. You have a plugin that supports different modules doing the same thing. For example, you have a #define between CSTRIKE/DOD or VAULT/NVAULT/MYSQL. You can eliminate the need for the #defines by using native+module filters. Your plugin will load even when a certain module doesn't exist and the natives aren't there. Or, a module could add specific enhancements that aren't required. The filtering system makes it optional without two compiled versions.

2. You have a plugin and users somehow don't understand the "check your modules.ini" message. This allows you to override that message with something somehow more informative.

This system is best seen in PLMENU. In AMX Mod X 1.55, PLMENU used #define CSTRIKE to switch in between mod versions. In 1.60, it uses the filtering system:

Code:
new g_cstrike = 0 public plugin_natives() {     set_module_filter("module_filter")     set_native_filter("native_filter") } public module_filter(const module[]) {     if (equali(module, "cstrike"))         return PLUGIN_HANDLED     return PLUGIN_CONTINUE } public native_filter(const name[], index, trap) {     if (!trap)         return PLUGIN_HANDLED             return PLUGIN_CONTINUE } public plugin_init() {     //code     if (module_exists("cstrike"))         g_cstrike = 1 } public some_event(id) {     new team     if (g_cstrike)         team = cs_get_user_team(id)     else         team = get_user_team(id) }
This plugin will load and run even if the CSTRIKE module is not loaded!

Client CVAR Querying
PM OnoTo has added a client cvar querying system to AMX Mod X! This means plugins can now find out the exact values of a cvar on a client.

For a good example of this, you can see PM's excellent CVAR Rules plugin (unreleased) that lets you define rules for the boundaries of client cvars.

An example:
Code:
public getInterp(id, const cvar[], const value[]) {     server_print("Client %d's cvar %s has value: %s", id, cvar, value) } public client_putinserver(id) {     query_client_cvar(id, "ex_interp", getInterp) }

Check out the funcwiki entry for query_client_cvar for more info.

Also two new natives have been added to string.inc: float_to_str and str_to_float.

If you have any questions, feel free to post here!
__________________
egg
BAILOPAN is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 09-11-2005 , 02:06  
Reply With Quote #2

i gave him the idea ladies and gentlmen
Freecode is offline
BAILOPAN
Join Date: Jan 2004
Old 09-11-2005 , 02:07  
Reply With Quote #3

;] no, #2 is a direct consequence of [gh]ferret asking if plugins could use modules and still load without them. The rest is random things we thought were good ideas while fixing up 1.55
__________________
egg
BAILOPAN is offline
{NM}Jason
AMX Mod X Beta Tester
Join Date: Mar 2004
Location: Texas
Old 09-11-2005 , 02:07  
Reply With Quote #4

keep up the good work ..!
__________________
http://forums.alliedmods.net/showthr...396#post451396
Quote:
Originally Posted by BAILOPAN View Post
Shortly after posting that image, Jason crushed the truck into a ball with his hands, and tossed it over his shoulder.
{NM}Jason is offline
Send a message via ICQ to {NM}Jason Send a message via AIM to {NM}Jason Send a message via MSN to {NM}Jason Send a message via Yahoo to {NM}Jason
atambo
Senior Member
Join Date: Oct 2004
Location: Pittsburgh, PA
Old 09-11-2005 , 02:10  
Reply With Quote #5

we need a super duper nvault where are you Suzuka?
__________________
atambo is offline
Send a message via AIM to atambo Send a message via MSN to atambo Send a message via Yahoo to atambo
Greentryst
WHAT MORE DO THEY WANT?!
Join Date: Mar 2004
Location: ? MAYBE SYRUP+TREES?
Old 09-11-2005 , 02:11  
Reply With Quote #6

Quote:
Originally Posted by Freecode
i gave him the idea ladies and gentlmen
HELLO LADIES!
__________________
<Bend3r> Have you waiting for new monsters? Have fix it, but I will not release it an. Gonna fix more monsters and searching after bugs. {3 screenshots attached}
<Locks> that monster looks tight.
<Bend3r> maybe it will slap me.
Greentryst is offline
Send a message via ICQ to Greentryst Send a message via AIM to Greentryst Send a message via MSN to Greentryst Send a message via Yahoo to Greentryst Send a message via Skype™ to Greentryst
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 09-11-2005 , 07:44  
Reply With Quote #7

awsome news guys!

can't await to have 1.60 on the desk as there's already a bunch of fixes
(like the ones in DoDx module) that a lot of serveradmins need
(and so stop complaining about my plugins not working correctly ).

keep up the great work!
FeuerSturm is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 09-11-2005 , 12:01  
Reply With Quote #8

Good job, I wanted those last 2 natives mentioned.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 09-11-2005 , 13:04  
Reply With Quote #9

Will 1.60 be a stable or beta release? (Since there's no other real topics about it)
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
BAILOPAN
Join Date: Jan 2004
Old 09-11-2005 , 13:13  
Reply With Quote #10

Yes, it will be stable or beta.
__________________
egg
BAILOPAN is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:50.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode