diff --git a/core/smn_console.cpp b/core/smn_console.cpp index fbb6f206..5ed90a7e 100644 --- a/core/smn_console.cpp +++ b/core/smn_console.cpp @@ -650,6 +650,23 @@ static cell_t sm_GetConVarName(IPluginContext *pContext, const cell_t *params) return 1; } +static cell_t sm_GetConVarDescription(IPluginContext *pContext, const cell_t *params) +{ + Handle_t hndl = static_cast(params[1]); + HandleError err; + ConVar *pConVar; + + if ((err=g_ConVarManager.ReadConVarHandle(hndl, &pConVar)) + != HandleError_None) + { + return pContext->ThrowNativeError("Invalid convar handle %x (error %d)", hndl, err); + } + + pContext->StringToLocalUTF8(params[2], params[3], pConVar->GetHelpText(), NULL); + + return 1; +} + static bool s_QueryAlreadyWarned = false; static cell_t sm_QueryClientConVar(IPluginContext *pContext, const cell_t *params) @@ -1510,6 +1527,7 @@ REGISTER_NATIVES(consoleNatives) {"ConVar.GetBounds", sm_GetConVarBounds}, {"ConVar.SetBounds", sm_SetConVarBounds}, {"ConVar.GetName", sm_GetConVarName}, + {"ConVar.GetDescription", sm_GetConVarDescription}, {"ConVar.ReplicateToClient", ConVar_ReplicateToClient}, {"ConVar.AddChangeHook", sm_HookConVarChange}, {"ConVar.RemoveChangeHook", sm_UnhookConVarChange}, diff --git a/plugins/include/convars.inc b/plugins/include/convars.inc index 7533a7f5..cde31d1e 100644 --- a/plugins/include/convars.inc +++ b/plugins/include/convars.inc @@ -225,6 +225,12 @@ methodmap ConVar < Handle // @param maxlength Maximum length of string buffer. public native void GetName(char[] name, int maxlength); + // Retrieves the description of a console variable. + // + // @param buffer Buffer to store the description of the convar. + // @param maxlength Maximum length of string buffer. + public native void GetDescription(char[] buffer, int maxlength); + // Replicates a convar value to a specific client. This does not change the actual convar value. // // @param client Client index