-
Notifications
You must be signed in to change notification settings - Fork 172
Expand file tree
/
Copy pathadminsystem.h
More file actions
167 lines (145 loc) · 4.85 KB
/
Copy pathadminsystem.h
File metadata and controls
167 lines (145 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/**
* =============================================================================
* CS2Fixes
* Copyright (C) 2023-2024 Source2ZE
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform.h"
#include "utlvector.h"
#include "playermanager.h"
#include <ctime>
#define ADMFLAG_NONE (0)
#define ADMFLAG_RESERVATION (1 << 0) // a
#define ADMFLAG_GENERIC (1 << 1) // b
#define ADMFLAG_KICK (1 << 2) // c
#define ADMFLAG_BAN (1 << 3) // d
#define ADMFLAG_UNBAN (1 << 4) // e
#define ADMFLAG_SLAY (1 << 5) // f
#define ADMFLAG_CHANGEMAP (1 << 6) // g
#define ADMFLAG_CONVARS (1 << 7) // h
#define ADMFLAG_CONFIG (1 << 8) // i
#define ADMFLAG_CHAT (1 << 9) // j
#define ADMFLAG_VOTE (1 << 10) // k
#define ADMFLAG_PASSWORD (1 << 11) // l
#define ADMFLAG_RCON (1 << 12) // m
#define ADMFLAG_CHEATS (1 << 13) // n
#define ADMFLAG_CUSTOM1 (1 << 14) // o
#define ADMFLAG_CUSTOM2 (1 << 15) // p
#define ADMFLAG_CUSTOM3 (1 << 16) // q
#define ADMFLAG_CUSTOM4 (1 << 17) // r
#define ADMFLAG_CUSTOM5 (1 << 18) // s
#define ADMFLAG_CUSTOM6 (1 << 19) // t
#define ADMFLAG_CUSTOM7 (1 << 20) // u
#define ADMFLAG_CUSTOM8 (1 << 21) // v
#define ADMFLAG_CUSTOM9 (1 << 22) // w
#define ADMFLAG_CUSTOM10 (1 << 23) // x
#define ADMFLAG_CUSTOM11 (1 << 24) // y
#define ADMFLAG_ROOT (1 << 25) // z
#define ADMIN_PREFIX "Admin %s has "
void PrintSingleAdminAction(const char* pszAdminName, const char* pszTargetName, const char* pszAction, const char* pszAction2, const char* prefix);
void PrintMultiAdminAction(ETargetType nType, const char* pszAdminName, const char* pszAction, const char* pszAction2, const char* prefix);
class CInfractionBase
{
public:
CInfractionBase(time_t duration, uint64 steamId, bool bEndTime = false) : m_iSteamID(steamId)
{
// The duration is in minutes here
if (!bEndTime)
m_iTimestamp = duration != 0 ? std::time(nullptr) + (duration * 60) : 0;
else
m_iTimestamp = duration;
}
enum EInfractionType
{
Ban,
Mute,
Gag
};
virtual EInfractionType GetType() = 0;
virtual void ApplyInfraction(ZEPlayer*) = 0;
virtual void UndoInfraction(ZEPlayer *) = 0;
time_t GetTimestamp() { return m_iTimestamp; }
uint64 GetSteamId64() { return m_iSteamID; }
private:
time_t m_iTimestamp;
uint64 m_iSteamID;
};
class CBanInfraction : public CInfractionBase
{
public:
using CInfractionBase::CInfractionBase;
EInfractionType GetType() override { return Ban; }
void ApplyInfraction(ZEPlayer*) override;
// This isn't needed as we'll just not kick the player when checking infractions upon joining
void UndoInfraction(ZEPlayer *) override {}
};
class CMuteInfraction :public CInfractionBase
{
public:
using CInfractionBase::CInfractionBase;
EInfractionType GetType() override { return Mute; }
void ApplyInfraction(ZEPlayer*) override;
void UndoInfraction(ZEPlayer *) override;
};
class CGagInfraction : public CInfractionBase
{
public:
using CInfractionBase::CInfractionBase;
EInfractionType GetType() override { return Gag; }
void ApplyInfraction(ZEPlayer *) override;
void UndoInfraction(ZEPlayer *) override;
};
class CAdmin
{
public:
CAdmin(const char* pszName, uint64 iSteamID, uint64 iFlags) :
m_pszName(pszName), m_iSteamID(iSteamID), m_iFlags(iFlags)
{}
const char* GetName() { return m_pszName; };
uint64 GetSteamID() { return m_iSteamID; };
uint64 GetFlags() { return m_iFlags; };
private:
const char* m_pszName;
uint64 m_iSteamID;
uint64 m_iFlags;
};
class CAdminSystem
{
public:
CAdminSystem()
{
LoadAdmins();
LoadInfractions();
}
bool LoadAdmins();
bool LoadInfractions();
void AddInfraction(CInfractionBase*);
void SaveInfractions();
bool ApplyInfractions(ZEPlayer *player);
bool FindAndRemoveInfraction(ZEPlayer *player, CInfractionBase::EInfractionType type);
/// @brief Determines if the player has an active infraction of the specified type
/// @param player
/// @param type
/// @return true if an active infraction is found
bool HasInfraction(ZEPlayer *player, CInfractionBase::EInfractionType type);
CAdmin *FindAdmin(uint64 iSteamID);
uint64 ParseFlags(const char* pszFlags);
private:
CUtlVector<CAdmin> m_vecAdmins;
CUtlVector<CInfractionBase*> m_vecInfractions;
};
extern CAdminSystem *g_pAdminSystem;
void PrecacheAdminBeaconParticle(IEntityResourceManifest* pResourceManifest);