Начинающий
- Статус
- Оффлайн
- Регистрация
- 26 Дек 2024
- Сообщения
- 55
- Реакции
- 0
CBaseEntity = nullWhy would it crash lmao its calling the game's function to get the localplayer controller
for other entities you can do
C++:C_BaseEntity* SDK::GetBaseEntityByIndex(int i) { using GetBaseEntityByIndexFn = void* (__fastcall*)(int index); static GetBaseEntityByIndexFn GetBaseEntityByIndex = reinterpret_cast<GetBaseEntityByIndexFn>( Utils::PatternScan(CLIENT_DLL, X("8B D1 48 8B 0D ? ? ? ? E9 ? ? ? ? CC CC 48 8B 89"))); return GetBaseEntityByIndex == nullptr ? nullptr : reinterpret_cast<C_BaseEntity*>(GetBaseEntityByIndex(i)); }
Example how i do it :
C++:
auto pPlayerPawn = reinterpret_cast<C_CSPlayerPawn*>(gEntitySystem->GetEntity(pPlayerController->m_hPawn()));
C++:
inline auto gEntitySystem = *reinterpret_cast<CGameEntitySystem**>(schema.FindPattern("client.dll", "48 8B 0D ? ? ? ? 0F 28 DE 4C 89 6C 24 ? 4C 8B C0 4C 89 6C 24 ? 49 8B D6"));
C++:
class CGameEntitySystem {
public:
template <typename T = C_BaseEntity>
T* GetEntity(int Index)
{
return reinterpret_cast<T*>(this->GetEntityByIndexFunction(Index));
}
template <typename T = C_BaseEntity>
T* GetEntity(CBaseHandle hHandle)
{
if (!hHandle.IsValid())
return nullptr;
return reinterpret_cast<T*>(this->GetEntityByIndexFunction(hHandle.GetEntryIndex()));
}
int GetHighestEntityIndex()
{
return *reinterpret_cast<int*>(reinterpret_cast<std::uintptr_t>(this) + 0x20F0);
}
private:
void* GetEntityByIndexFunction(int Index)
{
SCHEMA schema;
using fnGetBaseEntity = void* (__fastcall*)(void*, int);
static auto GetBaseEntity = reinterpret_cast<fnGetBaseEntity>(schema.FindPattern("client.dll", "8B D1 48 8B 0D ? ? ? ? E9 ? ? ? ? CC CC 48 8B 89"));
return GetBaseEntity(this, Index);
}
};
Последнее редактирование: