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

Method ProcessCommandTarget

extensions/sdktools/extension.cpp:458–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

456}
457
458bool SDKTools::ProcessCommandTarget(cmd_target_info_t *info)
459{
460 IGamePlayer *pAdmin = info->admin ? playerhelpers->GetGamePlayer(info->admin) : NULL;
461
462 if (strcmp(info->pattern, "@aim") == 0)
463 {
464 /* The server can't aim, of course. */
465 if (pAdmin == NULL)
466 {
467 return false;
468 }
469
470 int player_index;
471 if ((player_index = GetClientAimTarget(pAdmin->GetEdict(), true)) < 1)
472 {
473 info->reason = COMMAND_TARGET_NONE;
474 info->num_targets = 0;
475 return true;
476 }
477
478 IGamePlayer *pTarget = playerhelpers->GetGamePlayer(player_index);
479
480 if (pTarget == NULL)
481 {
482 info->reason = COMMAND_TARGET_NONE;
483 info->num_targets = 0;
484 return true;
485 }
486
487 info->reason = playerhelpers->FilterCommandTarget(pAdmin, pTarget, info->flags);
488 if (info->reason != COMMAND_TARGET_VALID)
489 {
490 info->num_targets = 0;
491 return true;
492 }
493
494 info->targets[0] = player_index;
495 info->num_targets = 1;
496 info->reason = COMMAND_TARGET_VALID;
497 info->target_name_style = COMMAND_TARGETNAME_RAW;
498 ke::SafeStrcpy(info->target_name, info->target_name_maxlength, pTarget->GetName());
499 return true;
500 }
501 else if (strcmp(info->pattern, "@spec") == 0)
502 {
503 const char *teamname = tools_GetTeamName(1);
504 if (strcasecmp(teamname, "spectator") != 0)
505 return false;
506 info->num_targets = 0;
507 for (int i = 1; i <= playerhelpers->GetMaxClients(); i++)
508 {
509 IGamePlayer *player = playerhelpers->GetGamePlayer(i);
510 if (player == NULL || !player->IsInGame() || player->IsSourceTV() || player->IsReplay())
511 continue;
512 IPlayerInfo *plinfo = player->GetPlayerInfo();
513 if (plinfo == NULL)
514 continue;
515 if (plinfo->GetTeamIndex() == 1 &&

Callers

nothing calls this directly

Calls 12

GetClientAimTargetFunction · 0.85
tools_GetTeamNameFunction · 0.85
GetGamePlayerMethod · 0.80
GetEdictMethod · 0.80
FilterCommandTargetMethod · 0.80
GetMaxClientsMethod · 0.80
IsInGameMethod · 0.80
IsSourceTVMethod · 0.80
IsReplayMethod · 0.80
GetPlayerInfoMethod · 0.80
GetTeamIndexMethod · 0.80
GetNameMethod · 0.45

Tested by

no test coverage detected