View Single Post
Plugin Info:     Modification:          Category:          Approver:   BAILOPAN (72)
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 10-01-2005 , 16:58   Client Cvar Rules
Reply With Quote #1

Hello.

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.

USAGE
Every command also has a shorter alias (? for list, + for add, - for del)

Code:
amx_cvarrules list
amx_cvarrules ?
lists all registered rules


Code:
amx_cvarrules add RULE
amx_cvarrules + RULE
adds a rule


Code:
amx_cvarrules del RULE ID
amx_cvarrules - RULE ID
removes a rule by its id (printed by amx_cvarrules list)


Code:
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.
Code:
amx_cvarrules add CVAR OPERATOR COMPARE_VALUE more stuff
Let's look at an example:
Code:
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:
Code:
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:
Code:
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.
Code:
=   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:
Code:
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:
Code:
ex_interp !f !
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.
Attached Files
File Type: sma Get Plugin or Get Source (cvarrules.sma - 6117 views - 20.2 KB)
__________________
hello, i am pm
PM is offline