Today I'd like to release a plugin which I've written a long time ago in order to test the "query client cvar value" functionality of newer AMX Mod X versions.
As the name says, the plugin lets you specify rules for client cvars.
NOTE: Requires AMXx >= 1.56 (1.60 will work, as it says >=). Also, your server has to be up-to-date (have Valve's august-engine-update), otherwise you'll probably get either a lot of runtime errors or crashes.
The plugin registers one server command: amx_cvarrules.
Every command also has a shorter alias (? for list, + for add, - for del)
lists all registered rules
amx_cvarrules add RULE
amx_cvarrules + RULE
adds a rule
amx_cvarrules del RULE ID
amx_cvarrules - RULE ID
removes a rule by its id (printed by amx_cvarrules list)
amx_cvarrules del CVAR
amx_cvarrules - CVAR
removes all rules for the specified cvar.
amx_cvarrules add accepts the rule definition in an interesting format.
amx_cvarrules add CVAR OPERATOR COMPARE_VALUE more stuff
Let's look at an example:
amx_cvarrules add ex_interp !f 0.1
Here, the CVAR is ex_interp. The OPERATOR is !f, which is "not equal; compare as float". The COMPARE_VALUE is 0.1. There is no more stuff, so the default behaviour for the !f operator is:
If the user is found with a value different than 0.1, set it to 0.1 for him, and log it to the server logs. If it happens again on that user, log it again and kick him.
You can specify after how many "failed queries" logging/kicking/"shouting" should occur:
amx_cvarrules add ex_interp !f 0.1 shout1 log1 kick3
This makes the plugin "shout" when the first query fails. This means that it informs all players in the server that the client was found with ex_interp not set to (some value). It starts logging there as well, but kicks the user on the third failed query. Setting any of these to 0 disables them. The default is shout0 log1 kick2.
There's also an other interesting flag:
amx_cvarrules add ex_interp !f 0.1 dis
dis stands for "disable". This means that when the client has the right value set, it makes the cvar unchangable for him until he restarts HL. Of course, you can mix dis, shout, log, kick, or whatever.
There are more operators.
= equal (compare as text)
=f equal (compare as number)
=c equal (compare as text, ignore case)
! not equal (compare as text)
!f not equal (compare as number)
!c not equal (compare as text, ignore case)
< less (compare as number)
> greater (compare as number)
<= less or equal (compare as number)
>= greater or equal (compare as number)
The operators !, !f, !c, < and > have default "fallback values". A fallback value is the value the plugin will try to set the cvar to if the query fails. The default fallback value for these operators is the compare value you pass (as we've seen earlier). For the other operators, you have to set a fallback value yourself (of course, you can set your own fallback value for !, !f, !c, < and > as well). Or you can disable the fallback value altogether.
Setting the fallback value works like this:
ex_interp =f 0.05 @ 0.1
I don't know why anyone would to this, but it means: If ex_interp is set to 0.05, set it to 0.1.
Disabling the fallback value works like this:
You may want to use this for whatever reason. You'd maybe set kick0 or kick1 then.
By the way, note that amx_cvarrules add checks for duplicates of the same rule, so it's safe to use it in a file like config.cfg, which may possibly be executed more than once.
Well anyway, have fun.
EDIT: Yes, the plugin won't compile, because the web-compiler doesn't have the latest includes yet. Download the .sma and compile it on your own. Mwahahahah!!AHAHAHAH1h1AHAhahQHqha.
EDIT2: BAIL has phixed the web-compiler.