diff --git a/src/hacks/ESP.cpp b/src/hacks/ESP.cpp index 4ad1e119..3df16d10 100644 --- a/src/hacks/ESP.cpp +++ b/src/hacks/ESP.cpp @@ -613,8 +613,8 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) switch (type) { case ENTITY_PLAYER: - health = CE_INT(ent, netvar.iHealth); - healthmax = ent->m_iMaxHealth(); + health = g_pPlayerResource->GetHealth(ent); + healthmax = g_pPlayerResource->GetMaxHealth(ent); break; case ENTITY_BUILDING: health = CE_INT(ent, netvar.iBuildingHealth); @@ -1041,7 +1041,7 @@ void _FASTCALL ProcessEntity(CachedEntity *ent) // If text health is true, then add a string with the health if ((int) show_health == 1 || (int) show_health == 3) { - AddEntityString(ent, format(ent->m_iHealth(), '/', ent->m_iMaxHealth(), " HP"), colors::Health(ent->m_iHealth(), ent->m_iMaxHealth())); + AddEntityString(ent, format(g_pPlayerResource->GetHealth(ent), '/', g_pPlayerResource->GetMaxHealth(ent), " HP"), colors::Health(g_pPlayerResource->GetHealth(ent), g_pPlayerResource->GetMaxHealth(ent))); } // Set the entity to repaint espdata.needs_paint = true; diff --git a/src/soundcache.cpp b/src/soundcache.cpp index 485480ed..d27d6301 100644 --- a/src/soundcache.cpp +++ b/src/soundcache.cpp @@ -2,6 +2,9 @@ #include "soundcache.hpp" std::map sound_cache; +namespace soundcache +{ + void CreateMove() { if (CE_BAD(LOCAL_E)) @@ -14,8 +17,29 @@ void CreateMove() sound_cache[i.m_nSoundSource].last_update.update(); } } + +class SoundCacheEventListener : public IGameEventListener2 +{ + virtual void FireGameEvent(IGameEvent *event) + { + if (!isHackActive()) + return; + sound_cache[event->GetInt("userid")].sound.m_pOrigin = Vector(0.0f); + } +}; + +SoundCacheEventListener &listener() +{ + static SoundCacheEventListener object{}; + return object; +} + static InitRoutine init([]() { EC::Register(EC::CreateMove, CreateMove, "CM_SoundCache"); EC::Register( EC::LevelInit, []() { sound_cache.clear(); }, "soundcache_levelinit"); + g_IEventManager2->AddListener(&listener(), "player_death", false); + EC::Register( + EC::Shutdown, []() { g_IEventManager2->RemoveListener(&listener()); }, "event_shutdown"); }); +} // namespace soundcache