Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Вопрос Ошибка с шемой (asphyxia)

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
14 Июл 2025
Сообщения
11
Реакции
0
Всем привет! Я новичек, и сейчас я перехожу с оффсетов на шему. Я все пастил с asphyxia, но почему-то ничео не работает, а конкретно возвращает 00000.
Даже локальный контроллер и павн получить неполучается. Вот код:

Макрос PRINT вместо std::cout

C++:
Expand Collapse Copy
// Макрос PRINT вместо std::cout
template<typename T, typename... ARGS>
inline void NEW_CPP_CONVERTOR_TO_PRINT(T first, ARGS... args) {
    std::cout << first;
    NEW_CPP_CONVERTOR_TO_PRINT(args...);
}


#define PRINT(...) NEW_CPP_CONVERTOR_TO_PRINT(__VA_ARGS__)

entity.cpp из асфиксии:


C++:
Expand Collapse Copy
#include "entity.h"

#include "convars.h"
#include "cgameentitysystem.h"
#include "ienginecvar.h"
#include "iengineclient.h"

#include "const.h"

// global empty vector for when we can't get the origin
static Vector_t vecEmpty = Vector_t(0, 0, 0);

CCSPlayerController* CCSPlayerController::GetLocalPlayerController()
{
    const int nIndex = I::Engine->GetLocalPlayer();
    return I::GameResourceService->pGameEntitySystem->Get<CCSPlayerController>(nIndex);
}

const Vector_t& CCSPlayerController::GetPawnOrigin()
{
    CBaseHandle hPawnHandle = this->GetPawnHandle();
    if (!hPawnHandle.IsValid())
        return vecEmpty;

    C_CSPlayerPawn* pPlayerPawn = I::GameResourceService->pGameEntitySystem->Get<C_CSPlayerPawn>(hPawnHandle);
    if (pPlayerPawn == nullptr)
        return vecEmpty;

    return pPlayerPawn->GetSceneOrigin();
}

C_BaseEntity* C_BaseEntity::GetLocalPlayer()
{
    const int nIndex = I::Engine->GetLocalPlayer();
    return I::GameResourceService->pGameEntitySystem->Get(nIndex);
}

const Vector_t& C_BaseEntity::GetSceneOrigin()
{
    if (this->GetGameSceneNode())
        return GetGameSceneNode()->GetAbsOrigin();

    return vecEmpty;
}

bool C_CSPlayerPawn::IsOtherEnemy(C_CSPlayerPawn* pOther)
{
    // check are other player is invalid or we're comparing against ourselves
    if (pOther == nullptr || this == pOther)
        return false;

    if (CONVAR::game_type->value.i32 == GAMETYPE_FREEFORALL && CONVAR::game_mode->value.i32 == GAMEMODE_FREEFORALL_SURVIVAL)
        // check is not teammate
        return (this->GetSurvivalTeam() != pOther->GetSurvivalTeam());

    // @todo: check is deathmatch
    if (CONVAR::mp_teammates_are_enemies->value.i1)
        return true;

    return this->GetAssociatedTeam() != pOther->GetAssociatedTeam();
}

int C_CSPlayerPawn::GetAssociatedTeam()
{
    const int nTeam = this->GetTeam();

    // @todo: check is coaching, currently cs2 doesnt have sv_coaching_enabled, so just let it be for now...
    //if (CONVAR::sv_coaching_enabled->GetBool() && nTeam == TEAM_SPECTATOR)
    //    return this->GetCoachingTeam();

    return nTeam;
}

bool C_CSPlayerPawn::CanAttack(const float flServerTime)
{
    // check is player ready to attack
    if (CCSPlayer_WeaponServices* pWeaponServices = this->GetWeaponServices(); pWeaponServices != nullptr)
        if (this->IsWaitForNoAttack() || pWeaponServices->GetNextAttack() > flServerTime)
            return false;

    return true;
}


std::uint32_t C_CSPlayerPawn::GetOwnerHandleIndex()
{
    std::uint32_t Result = -1;
    if (this && GetCollision() && !(GetCollision()->GetSolidFlags() & 4))
        Result = this->GetOwnerHandle().GetEntryIndex();

    return Result;
}

std::uint16_t C_CSPlayerPawn::GetCollisionMask()
{
    if (this && GetCollision())
        return GetCollision()->CollisionMask(); // Collision + 0x38

    return 0;
}

bool C_CSWeaponBaseGun::CanPrimaryAttack(const int nWeaponType, const float flServerTime)
{
    // check are weapon support burst mode and it's ready to attack
    if (this->IsBurstMode())
    {
        // check is it ready to attack
        if (this->GetBurstShotsRemaining() > 0 /*&& this->GetNextBurstShotTime() <= flServerTime*/)
            return true;
    }

    // check is weapon ready to attack
    if (this->GetNextPrimaryAttackTick() > TIME_TO_TICKS(flServerTime))
        return false;

    // we doesn't need additional checks for knives
    if (nWeaponType == WEAPONTYPE_KNIFE)
        return true;

    // check do weapon have ammo
    if (this->GetClip1() <= 0)
        return false;

    const ItemDefinitionIndex_t nDefinitionIndex = this->GetAttributeManager()->GetItem()->GetItemDefinitionIndex();

    // check for revolver cocking ready
    if (nDefinitionIndex == WEAPON_R8_REVOLVER && this->GetPostponeFireReadyFrac() > flServerTime)
        return false;

    return true;
}

bool C_CSWeaponBaseGun::CanSecondaryAttack(const int nWeaponType, const float flServerTime)
{
    // check is weapon ready to attack
    if (this->GetNextSecondaryAttackTick() > TIME_TO_TICKS(flServerTime))
        return false;

    // we doesn't need additional checks for knives
    if (nWeaponType == WEAPONTYPE_KNIFE)
        return true;

    // check do weapon have ammo
    if (this->GetClip1() <= 0)
        return false;

    // only revolver is allowed weapon for secondary attack
    if (this->GetAttributeManager()->GetItem()->GetItemDefinitionIndex() != WEAPON_R8_REVOLVER)
        return false;

    return true;
}


Так же возможно проблема в том, как именно я вызываю шемы:
C++:
Expand Collapse Copy
    class SCHEMA_t {
    public:
        NODISCARD auto GetLocalController(){
            auto* controller = CCSPlayerController::GetLocalPlayerController();       
            if (controller != nullptr) return controller;
        }
        // Будующие функции

    };


или же проблема кроется в устаревшем паттерне для функции CallFunc
вызов:
C++:
Expand Collapse Copy
MEM::CallVFunc<void, 49U>(this, std::ref(nIndex), 0);

C++:
Expand Collapse Copy
    template <typename T, std::size_t nIndex, class CBaseClass, typename... Args_t>
    static CS_INLINE T CallVFunc(CBaseClass* thisptr, Args_t... argList)
    {
        using VirtualFn_t = T(__thiscall*)(const void*, decltype(argList)...);
        return (*reinterpret_cast<VirtualFn_t* const*>(reinterpret_cast<std::uintptr_t>(thisptr)))[nIndex](thisptr, argList...);
    }



Я совершенно не понимаю причину того, почему выдает 00000 в консоли
 
Последнее редактирование:
Всем привет! Я новичек, и сейчас я перехожу с оффсетов на шему. Я все пастил с asphyxia, но почему-то ничео не работает, а конкретно возвращает 00000.
Даже локальный контроллер и павн получить неполучается. Вот код:

Макрос PRINT вместо std::cout

C++:
Expand Collapse Copy
// Макрос PRINT вместо std::cout
template<typename T, typename... ARGS>
inline void NEW_CPP_CONVERTOR_TO_PRINT(T first, ARGS... args) {
    std::cout << first;
    NEW_CPP_CONVERTOR_TO_PRINT(args...);
}


#define PRINT(...) NEW_CPP_CONVERTOR_TO_PRINT(__VA_ARGS__)

entity.cpp из асфиксии:


C++:
Expand Collapse Copy
#include "entity.h"

#include "convars.h"
#include "cgameentitysystem.h"
#include "ienginecvar.h"
#include "iengineclient.h"

#include "const.h"

// global empty vector for when we can't get the origin
static Vector_t vecEmpty = Vector_t(0, 0, 0);

CCSPlayerController* CCSPlayerController::GetLocalPlayerController()
{
    const int nIndex = I::Engine->GetLocalPlayer();
    return I::GameResourceService->pGameEntitySystem->Get<CCSPlayerController>(nIndex);
}

const Vector_t& CCSPlayerController::GetPawnOrigin()
{
    CBaseHandle hPawnHandle = this->GetPawnHandle();
    if (!hPawnHandle.IsValid())
        return vecEmpty;

    C_CSPlayerPawn* pPlayerPawn = I::GameResourceService->pGameEntitySystem->Get<C_CSPlayerPawn>(hPawnHandle);
    if (pPlayerPawn == nullptr)
        return vecEmpty;

    return pPlayerPawn->GetSceneOrigin();
}

C_BaseEntity* C_BaseEntity::GetLocalPlayer()
{
    const int nIndex = I::Engine->GetLocalPlayer();
    return I::GameResourceService->pGameEntitySystem->Get(nIndex);
}

const Vector_t& C_BaseEntity::GetSceneOrigin()
{
    if (this->GetGameSceneNode())
        return GetGameSceneNode()->GetAbsOrigin();

    return vecEmpty;
}

bool C_CSPlayerPawn::IsOtherEnemy(C_CSPlayerPawn* pOther)
{
    // check are other player is invalid or we're comparing against ourselves
    if (pOther == nullptr || this == pOther)
        return false;

    if (CONVAR::game_type->value.i32 == GAMETYPE_FREEFORALL && CONVAR::game_mode->value.i32 == GAMEMODE_FREEFORALL_SURVIVAL)
        // check is not teammate
        return (this->GetSurvivalTeam() != pOther->GetSurvivalTeam());

    // @todo: check is deathmatch
    if (CONVAR::mp_teammates_are_enemies->value.i1)
        return true;

    return this->GetAssociatedTeam() != pOther->GetAssociatedTeam();
}

int C_CSPlayerPawn::GetAssociatedTeam()
{
    const int nTeam = this->GetTeam();

    // @todo: check is coaching, currently cs2 doesnt have sv_coaching_enabled, so just let it be for now...
    //if (CONVAR::sv_coaching_enabled->GetBool() && nTeam == TEAM_SPECTATOR)
    //    return this->GetCoachingTeam();

    return nTeam;
}

bool C_CSPlayerPawn::CanAttack(const float flServerTime)
{
    // check is player ready to attack
    if (CCSPlayer_WeaponServices* pWeaponServices = this->GetWeaponServices(); pWeaponServices != nullptr)
        if (this->IsWaitForNoAttack() || pWeaponServices->GetNextAttack() > flServerTime)
            return false;

    return true;
}


std::uint32_t C_CSPlayerPawn::GetOwnerHandleIndex()
{
    std::uint32_t Result = -1;
    if (this && GetCollision() && !(GetCollision()->GetSolidFlags() & 4))
        Result = this->GetOwnerHandle().GetEntryIndex();

    return Result;
}

std::uint16_t C_CSPlayerPawn::GetCollisionMask()
{
    if (this && GetCollision())
        return GetCollision()->CollisionMask(); // Collision + 0x38

    return 0;
}

bool C_CSWeaponBaseGun::CanPrimaryAttack(const int nWeaponType, const float flServerTime)
{
    // check are weapon support burst mode and it's ready to attack
    if (this->IsBurstMode())
    {
        // check is it ready to attack
        if (this->GetBurstShotsRemaining() > 0 /*&& this->GetNextBurstShotTime() <= flServerTime*/)
            return true;
    }

    // check is weapon ready to attack
    if (this->GetNextPrimaryAttackTick() > TIME_TO_TICKS(flServerTime))
        return false;

    // we doesn't need additional checks for knives
    if (nWeaponType == WEAPONTYPE_KNIFE)
        return true;

    // check do weapon have ammo
    if (this->GetClip1() <= 0)
        return false;

    const ItemDefinitionIndex_t nDefinitionIndex = this->GetAttributeManager()->GetItem()->GetItemDefinitionIndex();

    // check for revolver cocking ready
    if (nDefinitionIndex == WEAPON_R8_REVOLVER && this->GetPostponeFireReadyFrac() > flServerTime)
        return false;

    return true;
}

bool C_CSWeaponBaseGun::CanSecondaryAttack(const int nWeaponType, const float flServerTime)
{
    // check is weapon ready to attack
    if (this->GetNextSecondaryAttackTick() > TIME_TO_TICKS(flServerTime))
        return false;

    // we doesn't need additional checks for knives
    if (nWeaponType == WEAPONTYPE_KNIFE)
        return true;

    // check do weapon have ammo
    if (this->GetClip1() <= 0)
        return false;

    // only revolver is allowed weapon for secondary attack
    if (this->GetAttributeManager()->GetItem()->GetItemDefinitionIndex() != WEAPON_R8_REVOLVER)
        return false;

    return true;
}


Так же возможно проблема в том, как именно я вызываю шемы:
C++:
Expand Collapse Copy
    class SCHEMA_t {
    public:
        NODISCARD auto GetLocalController(){
            auto* controller = CCSPlayerController::GetLocalPlayerController();      
            if (controller != nullptr) return controller;
        }
        // Будующие функции

    };


или же проблема кроется в устаревшем паттерне для функции CallFunc
вызов:
C++:
Expand Collapse Copy
MEM::CallVFunc<void, 49U>(this, std::ref(nIndex), 0);

C++:
Expand Collapse Copy
    template <typename T, std::size_t nIndex, class CBaseClass, typename... Args_t>
    static CS_INLINE T CallVFunc(CBaseClass* thisptr, Args_t... argList)
    {
        using VirtualFn_t = T(__thiscall*)(const void*, decltype(argList)...);
        return (*reinterpret_cast<VirtualFn_t* const*>(reinterpret_cast<std::uintptr_t>(thisptr)))[nIndex](thisptr, argList...);
    }



Я совершенно не понимаю причину того, почему выдает 00000 в консоли
умоляю не делай на асфиксии
 
скорее всего у тебя индекс устарел Engine GetLocalPlayer() можешь так получать локал контролер и обнови шему
Код:
Expand Collapse Copy
CCSPlayerController* CCSPlayerController::GetLocalPlayerController()
{

    int nHighestIndex = I::GameResourceService->pGameEntitySystem->GetHighestEntityIndex();
    for (int i = 1; i <= nHighestIndex; i++)
    {
        C_BaseEntity* pEntity = I::GameResourceService->pGameEntitySystem->Get(i);
        if (!pEntity) continue;

        CSchemaClassInfo* pInfo = nullptr;
        pEntity->GetSchemaClassInfo(&pInfo);
        if (!pInfo) continue;

        if (FNV1A::Hash(pInfo->Name) == FNV1A::HashConst("CCSPlayerController"))
        {
            CCSPlayerController* pController = reinterpret_cast<CCSPlayerController*>(pEntity);
            if (pController && pController->IsLocalPlayerController())
                return pController;
        }
    }
    return nullptr;
}
Код:
Expand Collapse Copy
C_BaseEntity* C_BaseEntity::GetLocalPlayer()
{

    int nHighestIndex = I::GameResourceService->pGameEntitySystem->GetHighestEntityIndex();

    for (int i = 1; i <= nHighestIndex; i++)
    {
        C_BaseEntity* pEntity = I::GameResourceService->pGameEntitySystem->Get(i);
        if (!pEntity)
            continue;

        CSchemaClassInfo* pClassInfo = nullptr;
        pEntity->GetSchemaClassInfo(&pClassInfo);
        if (!pClassInfo)
            continue;

        const FNV1A_t uHashedName = FNV1A::Hash(pClassInfo->Name);


        if (uHashedName == FNV1A::HashConst("CCSPlayerController"))
        {
            CCSPlayerController* pController = reinterpret_cast<CCSPlayerController*>(pEntity);
            if (pController && pController->IsLocalPlayerController())
                return pController;
        }

        else if (uHashedName == FNV1A::HashConst("C_CSPlayerPawn"))
        {
            C_CSPlayerPawn* pPawn = reinterpret_cast<C_CSPlayerPawn*>(pEntity);
            if (pPawn && pPawn->IsLocalPlayerPawn())
                return pPawn;
        }
    }

    return nullptr;
}
 
Последнее редактирование:
Назад
Сверху Снизу