MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / sm_CreateConVar

Function sm_CreateConVar

core/smn_console.cpp:243–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241#endif
242
243static cell_t sm_CreateConVar(IPluginContext *pContext, const cell_t *params)
244{
245 char *name, *defaultVal, *helpText;
246
247 pContext->LocalToString(params[1], &name);
248
249 // While the engine seems to accept a blank convar name, it causes a crash upon server quit
250 if (name == NULL || strcmp(name, "") == 0)
251 {
252 return pContext->ThrowNativeError("Convar with blank name is not permitted");
253 }
254
255 pContext->LocalToString(params[2], &defaultVal);
256 pContext->LocalToString(params[3], &helpText);
257
258 bool hasMin = params[5] ? true : false;
259 bool hasMax = params[7] ? true : false;
260 float min = sp_ctof(params[6]);
261 float max = sp_ctof(params[8]);
262
263 Handle_t hndl = g_ConVarManager.CreateConVar(pContext, name, defaultVal, helpText, params[4], hasMin, min, hasMax, max);
264
265 if (hndl == BAD_HANDLE)
266 {
267 return pContext->ThrowNativeError("Convar \"%s\" was not created. A console command with the same might already exist.", name);
268 }
269
270 return hndl;
271}
272
273static cell_t sm_FindConVar(IPluginContext *pContext, const cell_t *params)
274{

Callers

nothing calls this directly

Calls 1

CreateConVarMethod · 0.80

Tested by

no test coverage detected