More convar insanity

1) Added natives: HookConVarChange(), UnhookConVarChange(), and GetConVarName()
2) Fixed bug(s) where ConVar handles were being created when they didn't need to be
3) Fixed bug where convars not created by SourceMod would be unregistered

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40471
This commit is contained in:
Scott Ehlert
2007-02-11 11:09:38 +00:00
parent 682e7d4ab6
commit 0d54b19b8e
5 changed files with 397 additions and 50 deletions
+43 -2
View File
@@ -74,6 +74,36 @@ native Handle:CreateConVar(const String:name[], const String:defaultValue[], con
*/
native Handle:FindConVar(const String:name[]);
/**
* Called when a console variable's value is changed.
*
* @param convar Handle to the convar that was changed.
* @param oldValue String containing the value of the convar before it was changed.
* @param newValue String containing the new value of the convar.
* @noreturn
*/
functag OnConVarChanged public(Handle:convar, const String:oldValue[], const String:newValue[]);
/**
* Creates a hook for when a console variable's value is changed.
*
* @param convar Handle to the convar.
* @param callback An OnConVarChanged function pointer.
* @noreturn
* @error Invalid or corrupt Handle.
*/
native HookConVarChange(Handle:convar, OnConVarChanged:callback);
/**
* Removes a hook for when a console variable's value is changed.
*
* @param convar Handle to the convar.
* @param callback An OnConVarChanged function pointer.
* @return True on success, false otherwise.
* @error Invalid or corrupt Handle.
*/
native bool:UnhookConVarChange(Handle:convar, OnConVarChanged:callback);
/**
* Returns the boolean value of a console variable.
*
@@ -136,11 +166,11 @@ native SetConVarFloat(Handle:convar, Float:value);
*
* @param convar Handle to the convar.
* @param value Buffer to store the value of the convar.
* @param maxlen Maximum length of string buffer.
* @param maxlength Maximum length of string buffer.
* @noreturn
* @error Invalid or corrupt Handle.
*/
native GetConVarString(Handle:convar, String:value[], maxlen);
native GetConVarString(Handle:convar, String:value[], maxlength);
/**
* Sets the string value of a console variable.
@@ -171,6 +201,17 @@ native GetConVarFlags(Handle:convar);
*/
native SetConVarFlags(Handle:convar, flags);
/**
* Retrieves the name of a console variable.
*
* @param convar Handle to the convar.
* @param value Buffer to store the name of the convar.
* @param maxlength Maximum length of string buffer.
* @noreturn
* @error Invalid or corrupt Handle.
*/
native GetConVarName(Handle:convar, const String:name[], maxlength);
/**
* Retrieves the minimum floating point value that a console variable can contain.
*