alliedmodders / hl2sdk

Half-Life 2 SDK Mirrors
https://github.com/valvesoftware
344 stars 164 forks source link

CBaseViewModel #179

Closed N1eLLsmesh closed 10 months ago

N1eLLsmesh commented 10 months ago

I'm so sorry, but i don't un how can I get CBaseViewModel from Cbaseentity, Someone can help, I would be very grateful.. Here is the code to get CBaseEntity

#pragma once
#include <entity2/entityidentity.h>
#include <baseentity.h>
#include "schemasystem.h"
#include "ehandle.h"
#include "CBsePlayer.h"

//#include "playernet_vars.h"
#include "shared_classnames.h"
//#include "CBsePlayer.h"
//#include "c_baseplayer.h"

//class CBasePlayer*;

inline CEntityInstance* UTIL_FindEntityByClassname(CEntityInstance* pStart, const char* name)
{
    extern CEntitySystem* g_pEntitySystem;
    CEntityIdentity* pEntity = pStart ? pStart->m_pEntity->m_pNext : g_pEntitySystem->m_EntityList.m_pFirstActiveEntity;

    for (; pEntity; pEntity = pEntity->m_pNext)
    {
        if (!strcmp(pEntity->m_designerName.String(), name))
            return pEntity->m_pInstance;
    };

    return nullptr;
}

class SC_CBaseEntity : public CBaseEntity
{
public:
    SCHEMA_FIELD(int32_t, CBaseEntity, m_iHealth);
    SCHEMA_FIELD(int32_t, CBaseEntity, m_iMaxHealth);
    SCHEMA_FIELD(LifeState_t, CBaseEntity, m_lifeState);
    SCHEMA_FIELD(uint8_t, CBaseEntity, m_iTeamNum);
    SCHEMA_FIELD(float, CBaseEntity, m_flGravityScale);
    SCHEMA_FIELD(CHandle<SC_ViewModel>, CBaseViewModel, m_hViewModel);

//CBaseViewModel* ToBaseViewModel()
  //  {
      //  if ( !m_hViewModel )
     //       return nullptr;

     //   return ::ToBaseViewModel(m_hViewModel.Get());
   // }

    //CBasePlayer* GetPlayer();
   // virtual CBasePlayer* GetPredictionOwner();  // Добавьте это определение
};
psychonic commented 10 months ago

Normally, this issues section is only for bugs in the sdk itself, not for offer individual help and discussion. I had originally left this open because of the current state of Source 2 to assist in collaboration.

However, since you then later sent an unsolicited email to me personally, noting that your only purpose for this is to break one of more of Valve's server guidelines, I'm going to close this out. We (myself and the AM community) are definitely not going to be giving an explicit support for that. You're on your own.

Wend4r commented 10 months ago

Your field m_hViewModel placed in CCSPlayer_ViewModelServices

Your can get it by

// Alignment: 136
// Size: 0x1550
class CCSPlayerPawnBase : public CBasePlayerPawn
{
    // ...
    CPlayer_ViewModelServices* m_pViewModelServices; // 0xbc0   
    // ...
};
// Alignment: 1
// Size: 0x50
class CCSPlayer_ViewModelServices : public CPlayer_ViewModelServices
{
public:
    // MNetworkEnable
    CHandle< CBaseViewModel > m_hViewModel[3]; // 0x40  
};