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

Method AddAdminCommand

core/ConCmdManager.cpp:319–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction,
320 const char *name,
321 const char *group,
322 int adminflags,
323 const char *description,
324 int flags,
325 IPlugin *pPlugin)
326{
327 ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags, pPlugin);
328
329 if (!pInfo)
330 return false;
331
332 GroupMap::Insert i = m_CmdGrps.findForAdd(group);
333 if (!i.found())
334 {
335 if (!m_CmdGrps.add(i, group))
336 return false;
337 i->value = new CommandGroup();
338 }
339 RefPtr<CommandGroup> cmdgroup = i->value;
340
341 CmdHook *pHook = new CmdHook(CmdHook::Client, pInfo, pFunction, description, pPlugin);
342 pHook->admin = std::make_unique<AdminCmdInfo>(cmdgroup, adminflags);
343
344 /* First get the command group override, if any */
345 bool override = adminsys->GetCommandOverride(group,
346 Override_CommandGroup,
347 &(pHook->admin->eflags));
348
349 /* Next get the command override, if any */
350 if (adminsys->GetCommandOverride(name,
351 Override_Command,
352 &(pHook->admin->eflags)))
353 {
354 override = true;
355 }
356
357 /* Assign normal flags if there were no overrides */
358 if (!override)
359 pHook->admin->eflags = pHook->admin->flags;
360 pInfo->eflags = pHook->admin->eflags;
361
362 cmdgroup->hooks.push_back(pHook);
363 pInfo->hooks.append(pHook);
364 RegisterInPlugin(pHook);
365 return true;
366}
367
368bool ConCmdManager::AddServerCommand(IPluginFunction *pFunction,
369 const char *name,

Callers 2

sm_RegConsoleCmdFunction · 0.80
sm_RegAdminCmdFunction · 0.80

Calls 5

RegisterInPluginFunction · 0.85
GetCommandOverrideMethod · 0.80
push_backMethod · 0.80
findForAddMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected