Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
Add .unban command (#20)
Browse files Browse the repository at this point in the history
Co-authored-by: marqdevx <[email protected]>
  • Loading branch information
marqdevx and marqdevx authored Feb 1, 2024
1 parent cf414de commit 703ed4e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/adminsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,39 @@ CON_COMMAND_CHAT(ban, "ban a player")
ClientPrintAll(HUD_PRINTTALK, CHAT_PREFIX ADMIN_PREFIX "banned %s for %i minutes.", player->GetPlayerName(), pTarget->GetPlayerName(), iDuration);
}

CON_COMMAND_CHAT(unban, "unbans a player")
{

if (!player)
return;

int iCommandPlayer = player->GetPlayerSlot();

ZEPlayer *pPlayer = g_playerManager->GetPlayer(iCommandPlayer);

if (!pPlayer->IsAdminFlagSet(ADMFLAG_BAN))
{
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX"You don't have access to this command.");
return;
}

if (args.ArgC() < 2)
{
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Usage: !unban <SteamID64>");
return;
}

uint64 targetSteamID = V_StringToUint64(args[1], -1);

if(g_pAdminSystem->FindAndRemoveInfraction(targetSteamID, CInfractionBase::Ban)){
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "SeeamID %llu unbanned.", targetSteamID);
}else{
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "SeeamID %llu is not banned.", targetSteamID);
}

return;
}

CON_COMMAND_CHAT(gag, "gag a player")
{
if(!g_bEnableGag)
Expand Down Expand Up @@ -938,6 +971,21 @@ bool CAdminSystem::FindAndRemoveInfraction(ZEPlayer *player, CInfractionBase::EI
return false;
}

bool CAdminSystem::FindAndRemoveInfraction(uint64 iSteamID, CInfractionBase::EInfractionType type)
{
FOR_EACH_VEC(m_vecInfractions, i)
{
if (m_vecInfractions[i]->GetSteamId64() == iSteamID && m_vecInfractions[i]->GetType() == type)
{
m_vecInfractions.Remove(i);

return true;
}
}

return false;
}

CAdmin *CAdminSystem::FindAdmin(uint64 iSteamID)
{
FOR_EACH_VEC(m_vecAdmins, i)
Expand Down
1 change: 1 addition & 0 deletions src/adminsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class CAdminSystem
void SaveInfractions();
bool ApplyInfractions(ZEPlayer *player);
bool FindAndRemoveInfraction(ZEPlayer *player, CInfractionBase::EInfractionType type);
bool FindAndRemoveInfraction(uint64 iSteamID, CInfractionBase::EInfractionType type);
CAdmin *FindAdmin(uint64 iSteamID);

private:
Expand Down

0 comments on commit 703ed4e

Please sign in to comment.