AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   Module: Cvar Utilities (v1.6) (https://forums.alliedmods.net/showthread.php?t=154642)

Arkshine 04-11-2011 11:02

Module: Cvar Utilities (v1.6)
 
2 Attachment(s)


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.

xPaw 04-11-2011 11:26

Re: Cvar Utilities
 
Amazing.

Seta00 04-11-2011 12:20

Re: Cvar Utilities
 
Nice job! Now go learn C++ the proper way.

Arkshine 04-11-2011 12:22

Re: Cvar Utilities
 
Sir, yes sir. But it's a good experience to make modules and learning from that.

bibu 04-11-2011 13:16

Re: Cvar Utilities
 
Just a small question. For what kind of plugins would be such module useful?

Arkshine 04-11-2011 13:48

Re: Cvar Utilities
 
Plugins which will need such functionalities, eh.

Look, all is fully documented with examples. You see what does the module exactly, I don't see what I could answer to such question. It's up to you, depending your need, to decide whether it will be useful for your plugins.

ConnorMcLeod 04-11-2011 14:01

Re: Cvar Utilities
 
Finally !! Gj.

wrecked_ 04-11-2011 15:38

Re: Cvar Utilities
 
http://i52.tinypic.com/zldcbb.jpg

Mind = Blown

bibu 04-11-2011 17:04

Re: Cvar Utilities
 
Quote:

] meta list
Currently loaded plugins:
description stat pend file vers src load unlod
[ 1] AMX Mod X RUN - amxmodx_mm.dll v1.8.1.3 ini Start ANY
[ 2] POD-Bot mm RUN - podbot_mm.dll v3.0B20a ini Chlvl ANY
[ 3] Fun RUN - fun_amxx.dll v1.8.1.3 pl1 ANY ANY
[ 4] Engine RUN - engine_amxx.dll v1.8.1.3 pl1 ANY ANY
[ 5] FakeMeta RUN - fakemeta_amxx.dl v1.8.1.3 pl1 ANY ANY
[ 6] CStrike RUN - cstrike_amxx.dll v1.8.1.3 pl1 ANY ANY
[ 7] CSX RUN - csx_amxx.dll v1.8.1.3 pl1 ANY ANY
[ 8] Ham Sandwich RUN - hamsandwich_amxx v1.8.1.3 pl1 ANY ANY
[ 9] Orpheu RUN - orpheu_amxx.dll v2.3 pl1 ANY ANY
[10] Cvar Utilities RUN - cvar_util_amxx.d v1.0.0 pl1 ANY ANY
10 plugi
Quote:

L 04/11/2011 - 23:03:55: [AMXX] Plugin "cvar_utilities_test.amxx" failed to load: Plugin uses an unknown function (name "CvarHookChange") - check your modules.ini
What's wrong?

Arkshine 04-11-2011 17:10

Re: Cvar Utilities
 
Check the server logs and past the output above the message "Module failed to load. Contact the author". It appears after the metamod/amxmodx message at the very start. If you still don't see the message, try to type in the console server : meta reload Cvar ; the error should appears.

But the error should be either you have not uploaded the module at the right place, or a signature has not been found. If you are sure binary is well uploaded it would be weird ; I've tested the module on the latest engine version and with hlbeta update too with success and all signatures were found.


All times are GMT -4. The time now is 17:29.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.