@@ -71,161 +71,5 @@ void (__fastcall* CUGCFileRequestManager__Update_orig)(CUGCFileRequestManager* t
7171void __fastcall CUGCFileRequestManager__Update_hook (CUGCFileRequestManager* thisPtr) { }
7272
7373}
74-
75- // / Interfaced UTIL Functions \\\
76-
77- // ---------------------------------------------------------------------------------
78- // Purpose: Get the player's base class with its entity index. Thanks to Nanoman2525 for this.
79- // ---------------------------------------------------------------------------------
80- CBasePlayer* UTIL_PlayerByIndex (const int playerIndex)
81- {
82- #ifdef _WIN32
83- static auto PlayerByIndex_ = reinterpret_cast <CBasePlayer* (__cdecl*)(int )>(Memory::Scan<void *>(SERVER, " 55 8B EC 8B 4D 08 33 C0 85 C9 7E 30" ));
84- return PlayerByIndex_ (playerIndex);
85- #else // Linux support TODO
86- return nullptr ;
87- #endif
88- }
89-
90- // ---------------------------------------------------------------------------------
91- // Purpose: Show on screen message to players. msg_dest are definSed macros in globals.hpp.
92- // ---------------------------------------------------------------------------------
93- void UTIL_ClientPrint (CBasePlayer* player, const int msg_dest, const char * msg_name, const char * param1, const char * param2, const char * param3, const char * param4)
94- {
95- static auto ClientPrint_ = reinterpret_cast <void (__cdecl*)(CBasePlayer*, int , const char *, const char *, const char *, const char *, const char *)>(Memory::Scan<void *>(SERVER, " 55 8B EC 83 EC 20 56 8B 75 08 85 F6 74 4C" ));
96- ClientPrint_ (player, msg_dest, msg_name, param1, param2, param3, param4);
97- }
98-
99- // ---------------------------------------------------------------------------------
100- // Purpose: Show on text on screen just like game_text does.
101- // ---------------------------------------------------------------------------------
102- void UTIL_HudMessage (CBasePlayer* pPlayer, const HudMessageParams& textparms, const char * pMessage)
103- {
104- static auto HudMessage_ = reinterpret_cast <void (__cdecl*)(CBasePlayer*, const HudMessageParams&, const char *)>(Memory::Scan (SERVER, " 55 8B EC 83 EC 20 8D 4D ? E8 ? ? ? ? 8B 45 ? 8D 4D ? 85 C0 74 ? 50 E8 ? ? ? ? EB ? E8 ? ? ? ? 56" ));
105- HudMessage_ (pPlayer, textparms, pMessage);
106- }
107-
108- // ---------------------------------------------------------------------------------
109- // Purpose: Get the CBasePlayer of the player who executed the ConVar or ConCommand.
110- // ---------------------------------------------------------------------------------
111- CBasePlayer* UTIL_GetCommandClient ()
11274{
113- static auto GetCommandClient_ = reinterpret_cast <CBasePlayer* (__cdecl*)()>(Memory::Scan (SERVER, " A1 ? ? ? ? 40 85 C0" ));
114- return GetCommandClient_ ();
115- }
116-
117- // ---------------------------------------------------------------------------------
118- // Purpose: Get the client index of the player who executed the ConVar or ConCommand. This is not the player's entity index which is 1 more.
119- // ---------------------------------------------------------------------------------
120- int UTIL_GetCommandClientIndex ()
121- {
122- static auto GetCommandClientIndex_ = reinterpret_cast <int (__cdecl*)()>(Memory::Scan (SERVER, " A1 ? ? ? ? 40 C3" ));
123- return GetCommandClientIndex_ ();
124- }
125-
126- // / CBaseEntity Class Functions \\\
127-
128- // ---------------------------------------------------------------------------------
129- // Purpose: Self-explanatory. Thanks to Nanoman2525 for this.
130- // ---------------------------------------------------------------------------------
131- void CBaseEntity__RemoveEntity (CBaseEntity* pEntity)
132- {
133- static auto RemoveEntity_ = reinterpret_cast <void (__cdecl*)(void *)>(Memory::Scan<void *>(SERVER, " 55 8B EC 57 8B 7D 08 85 FF 74 72" ));
134- RemoveEntity_ ((reinterpret_cast <IServerEntity*>(pEntity)->GetNetworkable ()));
135- }
136-
137- // ---------------------------------------------------------------------------------
138- // Purpose: Get team number for the supplied CBasePlayer.
139- // ---------------------------------------------------------------------------------
140- int CBaseEntity__GetTeamNumber (CBasePlayer* pPlayer)
141- {
142- static auto GetTeamNumber_ = reinterpret_cast <int (__thiscall*)(CBaseEntity*)>(Memory::Scan<void *>(SERVER, " 8B 81 F4 02 00 00 C3" ));
143- return GetTeamNumber_ (reinterpret_cast <CBaseEntity*>(pPlayer));
144- }
145-
146- // ---------------------------------------------------------------------------------
147- // Purpose: Get the script scope of a entity. Thanks to Nullderef/Vista for this.
148- // ---------------------------------------------------------------------------------
149- HSCRIPT CBaseEntity__GetScriptScope (CBaseEntity* entity)
150- {
151- if (!entity)
152- return nullptr ;
153-
154- return *reinterpret_cast <HSCRIPT*>(reinterpret_cast <uintptr_t >(entity) + 0x33c );
155- }
156-
157- // ---------------------------------------------------------------------------------
158- // Purpose: Get the script instance of a entity. Thanks to Nullderef/Vista for this.
159- // ---------------------------------------------------------------------------------
160- HSCRIPT CBaseEntity__GetScriptInstance (CBaseEntity* entity)
161- {
162- static auto GetScriptInstance_ = reinterpret_cast <HSCRIPT (__thiscall*)(CBaseEntity*)>(Memory::Scan<void *>(SERVER, " 55 8B EC 51 56 8B F1 83 BE 50" ));
163- if (!GetScriptInstance_)
164- {
165- Log (WARNING, false , " Could not get script instance for entity!" );
166- return nullptr ;
167- }
168-
169- return GetScriptInstance_ (entity);
170- }
171-
172- // TODO: Implement EmitSound
173- // int CBaseEntity__EmitSound(CBaseEntity* entity, IRecipientFilter* filter, int iEntIndex, const char* soundName, const Vector* pOrigin, float soundTime)
174- // {
175- // static auto
176- // //55 8B EC 83 EC 4C 8B 0D
177- // }
178-
179- // / CBasePlayer Class Functions \\\
180-
181- void CBasePlayer__ShowViewPortPanel (const int playerIndex, const char * name, const bool bShow, KeyValues* data)
182- {
183- CBasePlayer* pPlayer = UTIL_PlayerByIndex (playerIndex);
184- if (!pPlayer)
185- {
186- Log (WARNING, false , " Couldn't get player to display view port panel to! playerIndex: %i" , playerIndex);
187- return ;
188- }
189- static auto ShowViewPortPanel_ = reinterpret_cast <void (__thiscall*)(CBasePlayer*, const char *, bool , KeyValues*)>(Memory::Scan<void *>(SERVER, " 55 8B EC 83 EC 20 53 56 8B F1 57 8D 4D ? E8 ? ? ? ? 56" ));
190- ShowViewPortPanel_ (pPlayer, name, bShow, data);
191- }
192-
193-
194- // / CPortal_Player Class Functions \\\
195-
196- // ---------------------------------------------------------------------------------
197- // Purpose: Respawn the a player by their entity index.
198- // ---------------------------------------------------------------------------------
199- void CPortal_Player__RespawnPlayer (const int playerIndex)
200- {
201- CBasePlayer* pPlayer = UTIL_PlayerByIndex (playerIndex);
202- if (!pPlayer)
203- {
204- Log (WARNING, false , " Couldn't get player to respawn! playerIndex: %i" , playerIndex);
205- return ;
206- }
207-
208- static auto RespawnPlayer_ = reinterpret_cast <void (__thiscall*)(CPortal_Player*)>(Memory::Scan<void *>(SERVER, " 0F 57 C0 56 8B F1 57 8D 8E" ));
209- RespawnPlayer_ (reinterpret_cast <CPortal_Player*>(pPlayer));
210- }
211-
212- // ---------------------------------------------------------------------------------
213- // Purpose: Set the flashlight for a player on or off. Thanks to Nanoman2525 for this.
214- // Not a function in the CPortal_Player class, just more grouping it with the
215- // class. This does the same thing as the FlashlightTurnOn and FlashlightTurnOff
216- // functions in CPortal_Player but done in one function.
217- // ---------------------------------------------------------------------------------
218- void CPortal_Player__SetFlashlightState (const int playerIndex, const bool enable)
219- {
220- CBasePlayer* pPlayer = UTIL_PlayerByIndex (playerIndex);
221- if (!pPlayer)
222- {
223- Log (WARNING, true , " Couldn't get player to set flashlight state! playerIndex: %i enable: %i" , playerIndex, !!enable);
224- return ;
225- }
226-
227- if (enable)
228- reinterpret_cast <void (__thiscall*)(CBaseEntity*, int )>(Memory::Scan<void *>(SERVER, " 55 8B EC 53 8B D9 8B 83 A8" ))(reinterpret_cast <CBaseEntity*>(pPlayer), EF_DIMLIGHT);
229- else
230- reinterpret_cast <void (__thiscall*)(CBaseEntity*, int )>(Memory::Scan<void *>(SERVER, " 55 8B EC 53 56 8B 75 08 8B D9 8B 83" ))(reinterpret_cast <CBaseEntity*>(pPlayer), EF_DIMLIGHT);
23175}
0 commit comments