View Single Post
Author Message
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-11-2011 , 11:02   Module: Cvar Utilities (v1.6)
Reply With Quote #1



Cvar Utilities
∞ v1.6, released February 28th, 2013


Cvar Utilities provides a library of functionalities around the management of cvars.

It includes mainly :
  • Un|Hooking cvar for any value change and could be blocked ;
  • Un|Locking cvar to a specific value ;
  • Defining cvar with a minimum and maximum bound ;
  • Hooking a cvar for any value change and caching the new value in a global variable ;
The others are here to be complementary :
  • Creating a new cvar including new arguments ( description, bounds ) ;
  • Getting the default value of cvar ( value retried the first time by the module ) ;
  • Resetting a cvar to it's default value ;
  • Getting information about a hook, lock or bound ;
  • Listing cvars registered by the module and getting information ;
  • [Get|Set]ting a cvar description ;
  • Getting a cvar name from it's handle ;
  • Getting a plugin name/title from a plugin id ;
  • A command to show informations about registered cvars and module.

Contents :


HOW IT WORKS ?
∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ ∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ ∙

How the module detects when a cvar value is set ?
  • It simply hooks the engine function Cvar_DirectSet() ;
  • It's called only when a value is set, after checks and at the end of others functions.
  • In others words : that's the best way.
Code:
pfnCVarSetFloat   -> CVarSetFloat     -> Cvar_SetValue -> Cvar_Set -> Cvar_DirectSet pfnCvarSetString  -> CVarSetString    -> Cvar_Set                  -> Cvar_DirectSet pfnCvar_DirectSet -> PF_Cvar_DirectSet                             -> Cvar_DirectSet Cvar_Command                                                       -> Cvar_DirectSet

CREDITS
∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ ∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ ∙
  • Joaquim : Stolen some of his memory functions from orpheu.
  • Jim : For his way to hook a function.
  • Seta00 : For his c++ help and his patience.
  • Alka : Testing a bit v1.4 :p.

API
∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ ∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ ∙

Raw list of available natives/forwards
List

Error and return handling
List

Hooking all cvars top
Syntax

Example

[Un]Hooking a specific cvar top
Syntax

Examples

Un|Hooking all registered cvars of a plugin top
Syntax

Examples

Caching a cvar's value to a variable top
Syntax

Constants

Examples

[Un]Locking a cvar top
Syntax

Example
Registering a new cvar top
Syntax:

Spoiler

Example

[Get|Set]tting a bound top
Syntax

Example

Gettting hook infos top
Syntax

Example

Gettting lock infos top
Syntax

Example

Getting cvar status top
Syntax

Constants


Example

Getting cvar infos top
Syntax

Constants


Example

Getting cvar name top
Syntax

Example

[Get|Set]ing cvar description top
Syntax

Example

Getting plugin infos top
Syntax

Example

Getting cvar default value top
Syntax

Example

Resetting cvar top
Syntax

Example

COMMAND
∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ ∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ ∙

To retrieve useful informations or troubleshooting, a command exits to help this way : cvartutil or cu.
Usage : [cvarutil|cu] <command>

Commands :
  • version
    Display some informations about the module and where to get a support.
    example


  • status
    Display module status.
    Useful for people where the module doesn't work and they can't check the server logs. I.e :

    example


  • list
    Show a list of registered cvars which have a status.
    Can be filtered by [partial] plugin name.

    example


  • info < [cvar|index] >
    Give detailed informations about a cvar.
    example

CHANGE LOG
∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ ∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ ∙

list


INSTALLATION
∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ ∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ ∙
  1. Download cvar_util-files.zip and unzip the content directly in your $mod/ directory.
  2. Open your plugins.ini file, and add the plugin cu_amx_cvar_fix.amxx (*) before admincmds.amxx
  3. Restart and it's ready.
(*) This plugin contains the original amx_cvar command but with some modifications to check if a cvar is locked/bounded.


INSTALLATION FILES
∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ ∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ ∙

cvar_util-source-xx.zip : contains the project source code.
cvar_util-files-xx.zip : contains the binaries and configuration files.


Similar features have been integrated to latest 1.8.3-dev build, this is recommenced to not use anymore this module.
Attached Files
File Type: zip cvar_util-source-1.6.zip (76.5 KB, 2883 views)
File Type: zip cvar_util-files-1.6.zip (96.2 KB, 7560 views)
__________________

Last edited by Arkshine; 01-30-2015 at 10:41. Reason: Updated to 1.5
Arkshine is offline