Improve SoundESP

This commit is contained in:
bencat07 2019-06-10 22:40:01 +02:00
parent d5579a23fe
commit 5c82ee8152
2 changed files with 27 additions and 3 deletions

View File

@ -613,8 +613,8 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent)
switch (type) switch (type)
{ {
case ENTITY_PLAYER: case ENTITY_PLAYER:
health = CE_INT(ent, netvar.iHealth); health = g_pPlayerResource->GetHealth(ent);
healthmax = ent->m_iMaxHealth(); healthmax = g_pPlayerResource->GetMaxHealth(ent);
break; break;
case ENTITY_BUILDING: case ENTITY_BUILDING:
health = CE_INT(ent, netvar.iBuildingHealth); 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 text health is true, then add a string with the health
if ((int) show_health == 1 || (int) show_health == 3) 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 // Set the entity to repaint
espdata.needs_paint = true; espdata.needs_paint = true;

View File

@ -2,6 +2,9 @@
#include "soundcache.hpp" #include "soundcache.hpp"
std::map<int, SoundStruct> sound_cache; std::map<int, SoundStruct> sound_cache;
namespace soundcache
{
void CreateMove() void CreateMove()
{ {
if (CE_BAD(LOCAL_E)) if (CE_BAD(LOCAL_E))
@ -14,8 +17,29 @@ void CreateMove()
sound_cache[i.m_nSoundSource].last_update.update(); 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([]() { static InitRoutine init([]() {
EC::Register(EC::CreateMove, CreateMove, "CM_SoundCache"); EC::Register(EC::CreateMove, CreateMove, "CM_SoundCache");
EC::Register( EC::Register(
EC::LevelInit, []() { sound_cache.clear(); }, "soundcache_levelinit"); 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