1+ /* ******************************************************************
2+ * @file cportal_player.cpp
3+ * @brief CPortal_Player class recreation.
4+ * @author Orsell
5+ * @date 06 2025
6+ *********************************************************************/
7+
8+ #include " stdafx.hpp"
9+ #include " modules/cportal_player.h"
10+
11+ #include < const.h>
12+
13+ #include " utils/loggingsystem.hpp"
14+ #include " utils/memory.hpp"
15+
16+ #include " modules/cbaseplayer.h"
17+ #include " modules/utils.h"
18+
19+ /* *
20+ * @brief Respawn a player where ever their spawn point is set.
21+ * @param playerEntityIndex Player entity index.
22+ */
23+ void CPortal_Player::RespawnPlayer (const int playerEntityIndex)
24+ {
25+ CPortal_Player* pPlayer = reinterpret_cast <CPortal_Player*>(Utils::PlayerByIndex (playerEntityIndex));
26+ if (!pPlayer)
27+ {
28+ Log (WARNING, false , " Couldn't get player to respawn! playerIndex: %i" , playerEntityIndex);
29+ return ;
30+ }
31+
32+ static auto respawnPlayer = reinterpret_cast <void (__thiscall*)(CPortal_Player*)>(Memory::Scan<void *>(SERVER, " 0F 57 C0 56 8B F1 57 8D 8E" ));
33+ respawnPlayer (pPlayer);
34+ }
35+
36+ /* *
37+ * @brief Set the flashlight state for a player.
38+ * @note Not a function in the CPortal_Player class, just more grouping it with the
39+ * class. This does the same thing as the FlashlightTurnOn and FlashlightTurnOff
40+ * functions in CPortal_Player but done in one function.
41+ * @param playerEntityIndex Player entity index.
42+ * @param enabled Should flashlight be enabled or not.
43+ */
44+ void CPortal_Player::SetFlashlightState (const int playerEntityIndex, const bool enabled)
45+ {
46+ CBasePlayer* pPlayer = Utils::PlayerByIndex (playerEntityIndex);
47+ if (!pPlayer)
48+ {
49+ Log (WARNING, true , " Couldn't get player to set flashlight state! playerIndex: %i enable: %i" , playerEntityIndex, !!enabled);
50+ return ;
51+ }
52+
53+ if (enabled)
54+ 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);
55+ else
56+ 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);
57+ }
0 commit comments