-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfakeranks.cpp
203 lines (162 loc) · 5.63 KB
/
fakeranks.cpp
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#include <stdio.h>
#include "fakeranks.h"
#include "utils/module.h"
#include "schemasystem/schemasystem.h"
#include <funchook.h>
#include "cs2_sdk/entity/cbaseplayerpawn.h"
#include "cs2_sdk/entity/ccsplayercontroller.h"
#include "cs2_sdk/entity/cbaseplayercontroller.h"
#include <networksystem/inetworkserializer.h>
#include <networksystem/inetworkmessages.h>
#include <inetchannel.h>
#include "protobuf/generated/cstrike15_usermessages.pb.h"
class GameSessionConfiguration_t { };
SH_DECL_HOOK3_void(IServerGameDLL, GameFrame, SH_NOATTRIB, 0, bool, bool, bool);
SH_DECL_HOOK3_void(INetworkServerService, StartupServer, SH_NOATTRIB, 0, const GameSessionConfiguration_t &, ISource2WorldSession *, const char *);
/*
#ifdef _WIN32
#define ROOTBIN "/bin/win64/"
#define GAMEBIN "/csgo/bin/win64/"
#else
#define ROOTBIN "/bin/linuxsteamrt64/"
#define GAMEBIN "/csgo/bin/linuxsteamrt64/"
#endif
*/
FakeRank_RevealAll g_FakeRanks;
PLUGIN_EXPOSE(FakeRank_RevealAll, g_FakeRanks);
IServerGameDLL* server = NULL;
CSchemaSystem* g_pSchemaSystem2 = nullptr;
CGlobalVars *g_pGlobals = nullptr;
CGameEntitySystem* g_pEntitySystem = nullptr;
IGameEventSystem *g_pGameEventSystem = nullptr;
uint64_t iOldButtons[65];
CGlobalVars* GetGameGlobals()
{
INetworkGameServer* srv = g_pNetworkServerService->GetIGameServer();
if (!srv)
return nullptr;
return g_pNetworkServerService->GetIGameServer()->GetGlobals();
}
CGameEntitySystem* GameEntitySystem()
{
#ifdef WIN32
static int offset = 88;
#else
static int offset = 80;
#endif
return *reinterpret_cast<CGameEntitySystem**>((uintptr_t)(g_pGameResourceServiceServer)+offset);
}
bool FakeRank_RevealAll::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
PLUGIN_SAVEVARS();
GET_V_IFACE_ANY(GetServerFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
GET_V_IFACE_CURRENT(GetEngineFactory, g_pSchemaSystem2, CSchemaSystem, SCHEMASYSTEM_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, g_pNetworkMessages, INetworkMessages, NETWORKMESSAGES_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, g_pGameEventSystem, IGameEventSystem, GAMEEVENTSYSTEM_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, g_pNetworkServerService, INetworkServerService, NETWORKSERVERSERVICE_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, g_pGameResourceServiceServer, IGameResourceService, GAMERESOURCESERVICESERVER_INTERFACE_VERSION);
g_SMAPI->AddListener( this, this );
SH_ADD_HOOK(IServerGameDLL, GameFrame, server, SH_MEMBER(this, &FakeRank_RevealAll::Hook_GameFrame), true);
SH_ADD_HOOK(INetworkServerService, StartupServer, g_pNetworkServerService, SH_MEMBER(this, &FakeRank_RevealAll::Hook_StartupServer), true);
ConVar_Register( FCVAR_RELEASE | FCVAR_CLIENT_CAN_EXECUTE | FCVAR_GAMEDLL );
if(late)
{
g_pEntitySystem = GameEntitySystem();
g_pGlobals = GetGameGlobals();
}
return true;
}
bool FakeRank_RevealAll::Unload(char *error, size_t maxlen)
{
SH_REMOVE_HOOK(IServerGameDLL, GameFrame, server, SH_MEMBER(this, &FakeRank_RevealAll::Hook_GameFrame), true);
SH_REMOVE_HOOK(INetworkServerService, StartupServer, g_pNetworkServerService, SH_MEMBER(this, &FakeRank_RevealAll::Hook_StartupServer), true);
return true;
}
void FakeRank_RevealAll::Hook_StartupServer(const GameSessionConfiguration_t& config, ISource2WorldSession*, const char*)
{
g_pEntitySystem = GameEntitySystem();
g_pGlobals = GetGameGlobals();
}
void FakeRank_RevealAll::Hook_GameFrame(bool simulating, bool bFirstTick, bool bLastTick)
{
if(!g_pEntitySystem || !g_pGlobals)
return;
if(g_pGlobals->tickcount % 12 != 0)
return;
int maxClients = g_pGlobals->maxClients > 64 ? 64 : g_pGlobals->maxClients;
CRecipientFilter filter;
for(int i = 0; i < maxClients; i++)
{
CCSPlayerController* pPlayerController = (CCSPlayerController *)g_pEntitySystem->GetEntityInstance((CEntityIndex)(i + 1));
if(!pPlayerController) continue;
if(!pPlayerController->IsConnected() || !pPlayerController->m_hPawn() || !pPlayerController->m_hPawn()->m_pMovementServices()) continue;
uint64_t iButtons = pPlayerController->m_hPawn()->m_pMovementServices()->m_nButtons().m_pButtonStates()[0];
if(std::to_string(iButtons).find("858993") != std::string::npos && !(std::to_string(iOldButtons[i]).find("858993") != std::string::npos))
{
filter.AddRecipient(CPlayerSlot(i));
}
iOldButtons[i] = iButtons;
}
if(filter.GetRecipientCount() > 0)
{
INetworkMessageInternal *netmsg = g_pNetworkMessages->FindNetworkMessagePartial("CCSUsrMsg_ServerRankRevealAll");
CNetMessage *msg = netmsg->AllocateMessage();
g_pGameEventSystem->PostEventAbstract(0, false, &filter, netmsg, msg, 0);
// netmsg->DeallocateMessage(msg);
delete msg;
}
}
void FakeRank_RevealAll::AllPluginsLoaded()
{
}
void FakeRank_RevealAll::OnLevelInit(char const* pMapName,
char const* pMapEntities,
char const* pOldLevel,
char const* pLandmarkName,
bool loadGame,
bool background)
{
}
void FakeRank_RevealAll::OnLevelShutdown()
{
}
bool FakeRank_RevealAll::Pause(char *error, size_t maxlen)
{
return true;
}
bool FakeRank_RevealAll::Unpause(char *error, size_t maxlen)
{
return true;
}
const char *FakeRank_RevealAll::GetLicense()
{
return "GPLv3";
}
const char *FakeRank_RevealAll::GetVersion()
{
return "1.0.6";
}
const char *FakeRank_RevealAll::GetDate()
{
return __DATE__;
}
const char *FakeRank_RevealAll::GetLogTag()
{
return "FakeRanks";
}
const char *FakeRank_RevealAll::GetAuthor()
{
return "Cruze";
}
const char *FakeRank_RevealAll::GetDescription()
{
return "Reveals all fake ranks";
}
const char *FakeRank_RevealAll::GetName()
{
return "FakeRanks - Reveal All";
}
const char *FakeRank_RevealAll::GetURL()
{
return "https://github.com/cruze03";
}