diff --git a/src/adminsystem.cpp b/src/adminsystem.cpp index 16e131bc..f02f37af 100644 --- a/src/adminsystem.cpp +++ b/src/adminsystem.cpp @@ -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 "); + 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) @@ -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) diff --git a/src/adminsystem.h b/src/adminsystem.h index 258feff9..258cb84d 100644 --- a/src/adminsystem.h +++ b/src/adminsystem.h @@ -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: