Skip to content

Commit

Permalink
Add targeting support to !noclip
Browse files Browse the repository at this point in the history
  • Loading branch information
Vauff committed Nov 11, 2024
1 parent 5b2ad5d commit 583712e
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/adminsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,34 +426,30 @@ CON_COMMAND_CHAT_FLAGS(setteam, "<name> <team (0-3)> - Set a player's team", ADM
PrintMultiAdminAction(nType, pszCommandPlayerName, "moved", szAction);
}

CON_COMMAND_CHAT_FLAGS(noclip, "- Toggle noclip on yourself", ADMFLAG_SLAY | ADMFLAG_CHEATS)
CON_COMMAND_CHAT_FLAGS(noclip, "[name] - Toggle noclip on a player", ADMFLAG_CHEATS)
{
if (!player)
{
ClientPrint(player, HUD_PRINTCONSOLE, CHAT_PREFIX "You cannot use this command from the server console.");
int iNumClients = 0;
int pSlots[MAXPLAYERS];

if (!g_playerManager->CanTargetPlayers(player, args.ArgC() < 2 ? "@me" : args[1], iNumClients, pSlots, NO_MULTIPLE | NO_DEAD | NO_SPECTATOR))
return;
}

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

if (!pPawn)
return;

if (pPawn->m_iHealth() <= 0)
{
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You cannot noclip while dead!");
return;
}

if (pPawn->m_nActualMoveType() == MOVETYPE_NOCLIP)
{
pPawn->SetMoveType(MOVETYPE_WALK);
ClientPrintAll(HUD_PRINTTALK, CHAT_PREFIX ADMIN_PREFIX "exited noclip.", player->GetPlayerName());
PrintSingleAdminAction(pszCommandPlayerName, pTarget->GetPlayerName(), "disabled noclip on");
}
else
{
pPawn->SetMoveType(MOVETYPE_NOCLIP);
ClientPrintAll(HUD_PRINTTALK, CHAT_PREFIX ADMIN_PREFIX "entered noclip.", player->GetPlayerName());
PrintSingleAdminAction(pszCommandPlayerName, pTarget->GetPlayerName(), "enabled noclip on");
}
}

Expand Down

0 comments on commit 583712e

Please sign in to comment.