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

Method OnRootConsoleCommand

core/ConVarManager.cpp:285–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283}
284
285void ConVarManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command)
286{
287 int argcount = command->ArgC();
288 if (argcount >= 3)
289 {
290 bool wantReset = false;
291
292 /* Get plugin index that was passed */
293 const char *arg = command->Arg(2);
294 if (argcount >= 4 && strcmp(arg, "reset") == 0)
295 {
296 wantReset = true;
297 arg = command->Arg(3);
298 }
299
300 /* Get plugin object */
301 IPlugin *plugin = scripts->FindPluginByConsoleArg(arg);
302
303 if (!plugin)
304 {
305 UTIL_ConsolePrint("[SM] Plugin \"%s\" was not found.", arg);
306 return;
307 }
308
309 /* Get plugin name */
310 const sm_plugininfo_t *plinfo = plugin->GetPublicInfo();
311 const char *plname = IS_STR_FILLED(plinfo->name) ? plinfo->name : plugin->GetFilename();
312
313 ConVarList *pConVarList;
314 ConVarList::iterator iter;
315
316 /* If no convar list... */
317 if (!plugin->GetProperty("ConVarList", (void **)&pConVarList))
318 {
319 UTIL_ConsolePrint("[SM] No convars found for: %s", plname);
320 return;
321 }
322
323 if (!wantReset)
324 {
325 UTIL_ConsolePrint("[SM] Listing %d convars for: %s", pConVarList->size(), plname);
326 UTIL_ConsolePrint(" %-32.31s %s", "[Name]", "[Value]");
327 }
328
329 /* Iterate convar list and display/reset each one */
330 for (iter = pConVarList->begin(); iter != pConVarList->end(); iter++)
331 {
332 /*const */ConVar *pConVar = const_cast<ConVar *>(*iter);
333 if (!wantReset)
334 {
335 UTIL_ConsolePrint(" %-32.31s %s", pConVar->GetName(), pConVar->GetString());
336 } else {
337 pConVar->Revert();
338 }
339 }
340
341 if (wantReset)
342 {

Callers

nothing calls this directly

Calls 13

UTIL_ConsolePrintFunction · 0.85
IS_STR_FILLEDFunction · 0.85
GetPublicInfoMethod · 0.80
GetPropertyMethod · 0.80
ArgCMethod · 0.45
ArgMethod · 0.45
GetFilenameMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected