MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / GetLifeState

Method GetLifeState

core/PlayerManager.cpp:2624–2664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2622}
2623
2624int CPlayer::GetLifeState()
2625{
2626 if (lifestate_offset == -1)
2627 {
2628 if (!g_pGameConf->GetOffset("m_lifeState", &lifestate_offset))
2629 {
2630 lifestate_offset = -2;
2631 }
2632 }
2633
2634 if (lifestate_offset < 0)
2635 {
2636 IPlayerInfo *info = GetPlayerInfo();
2637 if (info == NULL)
2638 {
2639 return PLAYER_LIFE_UNKNOWN;
2640 }
2641 return info->IsDead() ? PLAYER_LIFE_DEAD : PLAYER_LIFE_ALIVE;
2642 }
2643
2644 if (m_pEdict == NULL)
2645 {
2646 return PLAYER_LIFE_UNKNOWN;
2647 }
2648
2649 CBaseEntity *pEntity;
2650 IServerUnknown *pUnknown = m_pEdict->GetUnknown();
2651 if (pUnknown == NULL || (pEntity = pUnknown->GetBaseEntity()) == NULL)
2652 {
2653 return PLAYER_LIFE_UNKNOWN;
2654 }
2655
2656 if (*((uint8_t *)pEntity + lifestate_offset) == LIFE_ALIVE)
2657 {
2658 return PLAYER_LIFE_ALIVE;
2659 }
2660 else
2661 {
2662 return PLAYER_LIFE_DEAD;
2663 }
2664}
2665
2666IClient *CPlayer::GetIClient() const
2667{

Callers 2

smn_IsPlayerAliveFunction · 0.80

Calls 2

GetPlayerInfoFunction · 0.85
GetOffsetMethod · 0.45

Tested by

no test coverage detected