Added GetConVarDefault() native (bug 4502, r=dvander).
This commit is contained in:
		
							parent
							
								
									651dfb796c
								
							
						
					
					
						commit
						6f16fc77b8
					
				| @ -509,6 +509,24 @@ static cell_t sm_ResetConVar(IPluginContext *pContext, const cell_t *params) | ||||
| 	return 1; | ||||
| } | ||||
| 
 | ||||
| static cell_t GetConVarDefault(IPluginContext *pContext, const cell_t *params) | ||||
| { | ||||
| 	Handle_t hndl = static_cast<Handle_t>(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); | ||||
| 	} | ||||
| 
 | ||||
| 	size_t bytes; | ||||
| 	pContext->StringToLocalUTF8(params[2], params[3], pConVar->GetDefault(), &bytes); | ||||
| 
 | ||||
| 	return bytes; | ||||
| } | ||||
| 
 | ||||
| static cell_t sm_GetConVarFlags(IPluginContext *pContext, const cell_t *params) | ||||
| { | ||||
| 	Handle_t hndl = static_cast<Handle_t>(params[1]); | ||||
| @ -1406,6 +1424,7 @@ REGISTER_NATIVES(consoleNatives) | ||||
| 	{"GetConVarBounds",		sm_GetConVarBounds}, | ||||
| 	{"SetConVarBounds",		sm_SetConVarBounds}, | ||||
| 	{"QueryClientConVar",	sm_QueryClientConVar}, | ||||
| 	{"GetConVarDefault",	GetConVarDefault}, | ||||
| 	{"RegServerCmd",		sm_RegServerCmd}, | ||||
| 	{"RegConsoleCmd",		sm_RegConsoleCmd}, | ||||
| 	{"GetCmdArgString",		sm_GetCmdArgString}, | ||||
|  | ||||
| @ -593,6 +593,17 @@ native SetConVarString(Handle:convar, const String:value[], bool:replicate=false | ||||
|  */ | ||||
| native ResetConVar(Handle:convar, bool:replicate=false, bool:notify=false); | ||||
| 
 | ||||
| /** | ||||
|  * Retrieves the default string value of a console variable. | ||||
|  * | ||||
|  * @param convar		Handle to the convar. | ||||
|  * @param default		Buffer to store the default value of the convar. | ||||
|  * @param maxlength		Maximum length of string buffer. | ||||
|  * @return				Number of bytes written to the buffer (UTF-8 safe). | ||||
|  * @error				Invalid or corrupt Handle. | ||||
|  */ | ||||
| native GetConVarDefault(Handle:convar, String:default[], maxlength); | ||||
| 
 | ||||
| /** | ||||
|  * Returns the bitstring of flags on a console variable. | ||||
|  * | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user