From d5a9136baa8300012130ede345db339a3f1cd793 Mon Sep 17 00:00:00 2001 From: DayibBaba <79384354+DayibBaba@users.noreply.github.com> Date: Thu, 16 Nov 2023 12:46:02 +0100 Subject: [PATCH] Fix spectate --- src/game/features/Features.cpp | 20 ++++++++------------ src/util/network.hpp | 2 -- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/game/features/Features.cpp b/src/game/features/Features.cpp index 50a5700a..2a84da8c 100644 --- a/src/game/features/Features.cpp +++ b/src/game/features/Features.cpp @@ -41,28 +41,24 @@ namespace YimMenu void SpectateTick() { if (g_SpectateId != Players::GetSelected().GetId() && g_Spectating - && ENTITY::DOES_ENTITY_EXIST(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_SpectateId))) + && ENTITY::DOES_ENTITY_EXIST(Players::GetSelected().GetPed().GetHandle())) { g_SpectateId = Players::GetSelected().GetId(); - NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_SpectateId)); + NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, Players::GetSelected().GetPed().GetHandle()); } - if (g_Spectating) + if (g_Spectating && g_SpectateId == Players::GetSelected().GetId()) { - auto playerPed = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_SpectateId); - CAM::SET_CINEMATIC_MODE_ACTIVE(false); + auto playerPed = Players::GetSelected().GetPed().GetHandle(); + + if (!STREAMING::IS_ENTITY_FOCUS(playerPed)) + STREAMING::SET_FOCUS_ENTITY(playerPed); if (!NETWORK::NETWORK_IS_IN_SPECTATOR_MODE() && ENTITY::DOES_ENTITY_EXIST(playerPed)) { NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, playerPed); } - - if (GRAPHICS::_ANIMPOSTFX_IS_TAG_PLAYING("SpectateFilter")) - { - GRAPHICS::_ANIMPOSTFX_STOP_TAG("SpectateFilter"); - } - - if (!Players::GetSelected().IsValid() || !NETWORK::NETWORK_IS_PLAYER_CONNECTED(Players::GetSelected().GetId())) + if (!Players::GetSelected().IsValid()) { STREAMING::CLEAR_FOCUS(); NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, Self::PlayerPed); diff --git a/src/util/network.hpp b/src/util/network.hpp index f1f958cf..ead9da16 100644 --- a/src/util/network.hpp +++ b/src/util/network.hpp @@ -1,6 +1,4 @@ #pragma once -#include "../../build/_deps/rdr_classes-src/entity/fwEntity.hpp" -#include "../../build/_deps/rdr_classes-src/network/netObject.hpp" #include "common.hpp" #include "game/backend/FiberPool.hpp" #include "game/backend/ScriptMgr.hpp"