Skip to content

Commit 67d3b6a

Browse files
committed
Add targeting support to !noclip
1 parent 5fc73ce commit 67d3b6a

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/adminsystem.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -426,34 +426,30 @@ CON_COMMAND_CHAT_FLAGS(setteam, "<name> <team (0-3)> - Set a player's team", ADM
426426
PrintMultiAdminAction(nType, pszCommandPlayerName, "moved", szAction);
427427
}
428428

429-
CON_COMMAND_CHAT_FLAGS(noclip, "- Toggle noclip on yourself", ADMFLAG_SLAY | ADMFLAG_CHEATS)
429+
CON_COMMAND_CHAT_FLAGS(noclip, "[name] - Toggle noclip on a player", ADMFLAG_CHEATS)
430430
{
431-
if (!player)
432-
{
433-
ClientPrint(player, HUD_PRINTCONSOLE, CHAT_PREFIX "You cannot use this command from the server console.");
431+
int iNumClients = 0;
432+
int pSlots[MAXPLAYERS];
433+
434+
if (!g_playerManager->CanTargetPlayers(player, args.ArgC() < 2 ? "@me" : args[1], iNumClients, pSlots, NO_MULTIPLE | NO_DEAD | NO_SPECTATOR))
434435
return;
435-
}
436436

437-
CBasePlayerPawn *pPawn = player->m_hPawn();
437+
CCSPlayerController* pTarget = CCSPlayerController::FromSlot(pSlots[0]);
438+
CBasePlayerPawn *pPawn = pTarget->m_hPawn();
439+
const char* pszCommandPlayerName = player ? player->GetPlayerName() : CONSOLE_NAME;
438440

439441
if (!pPawn)
440442
return;
441443

442-
if (pPawn->m_iHealth() <= 0)
443-
{
444-
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You cannot noclip while dead!");
445-
return;
446-
}
447-
448444
if (pPawn->m_nActualMoveType() == MOVETYPE_NOCLIP)
449445
{
450446
pPawn->SetMoveType(MOVETYPE_WALK);
451-
ClientPrintAll(HUD_PRINTTALK, CHAT_PREFIX ADMIN_PREFIX "exited noclip.", player->GetPlayerName());
447+
PrintSingleAdminAction(pszCommandPlayerName, pTarget->GetPlayerName(), "disabled noclip on");
452448
}
453449
else
454450
{
455451
pPawn->SetMoveType(MOVETYPE_NOCLIP);
456-
ClientPrintAll(HUD_PRINTTALK, CHAT_PREFIX ADMIN_PREFIX "entered noclip.", player->GetPlayerName());
452+
PrintSingleAdminAction(pszCommandPlayerName, pTarget->GetPlayerName(), "enabled noclip on");
457453
}
458454
}
459455

0 commit comments

Comments
 (0)