Skip to content

Commit

Permalink
Fix spectate
Browse files Browse the repository at this point in the history
  • Loading branch information
DayibBaba committed Nov 16, 2023
1 parent 476426e commit d5a9136
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
20 changes: 8 additions & 12 deletions src/game/features/Features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/util/network.hpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit d5a9136

Please sign in to comment.