Skip to content

Commit

Permalink
Fixed spectate ?!?!?!?!?! (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
DayibBaba authored Oct 22, 2023
1 parent e5bd3bf commit 20503dd
Showing 1 changed file with 41 additions and 16 deletions.
57 changes: 41 additions & 16 deletions src/game/features/Features.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
#include "Features.hpp"
#include "game/rdr/Natives.hpp"

#include "core/commands/Commands.hpp"
#include "game/backend/ScriptMgr.hpp"
#include "core/commands/HotkeySystem.hpp"
#include "game/frontend/GUI.hpp"
#include "game/rdr/Enums.hpp"
#include "game/backend/Players.hpp"
#include "core/frontend/Notifications.hpp"
#include "game/backend/FiberPool.hpp"
#include "game/backend/FiberPool.hpp"
#include "game/backend/Players.hpp"
#include "game/backend/ScriptMgr.hpp"
#include "game/bigfeatures/Esp.hpp"
#include "game/frontend/GUI.hpp"
#include "game/rdr/Enums.hpp"
#include "game/rdr/Natives.hpp"

namespace YimMenu
{
static void UpdateSelfVars()
{
Self::PlayerPed = PLAYER::PLAYER_PED_ID();
Self::Id = PLAYER::PLAYER_ID();
Self::Pos = ENTITY::GET_ENTITY_COORDS(Self::PlayerPed, true, true);
Self::Rot = ENTITY::GET_ENTITY_ROTATION(Self::PlayerPed, 2);
Self::Id = PLAYER::PLAYER_ID();
Self::Pos = ENTITY::GET_ENTITY_COORDS(Self::PlayerPed, true, true);
Self::Rot = ENTITY::GET_ENTITY_ROTATION(Self::PlayerPed, 2);

if (PED::IS_PED_IN_ANY_VEHICLE(Self::PlayerPed, true))
Self::Veh = PED::GET_VEHICLE_PED_IS_IN(Self::PlayerPed, true);
Expand All @@ -28,7 +29,7 @@ namespace YimMenu
Self::Mount = PED::GET_MOUNT(Self::PlayerPed);
else if (ENTITY::DOES_ENTITY_EXIST(PED::_GET_LAST_MOUNT(Self::PlayerPed)))
Self::Mount = PED::_GET_LAST_MOUNT(Self::PlayerPed);
else if(ENTITY::DOES_ENTITY_EXIST(PLAYER::GET_MOUNT_OWNED_BY_PLAYER(Self::Id)))
else if (ENTITY::DOES_ENTITY_EXIST(PLAYER::GET_MOUNT_OWNED_BY_PLAYER(Self::Id)))
Self::Mount = PLAYER::GET_MOUNT_OWNED_BY_PLAYER(Self::Id);
else
Self::Mount = 0;
Expand All @@ -46,21 +47,46 @@ namespace YimMenu

if (g_Spectating)
{
auto playerPed = Players::GetSelected().GetPed().GetHandle();

if (CAM::HAS_LETTER_BOX())
{
CAM::_REQUEST_LETTER_BOX_NOW(false, false);
CAM::_FORCE_LETTER_BOX_THIS_UPDATE();
}

if (!NETWORK::NETWORK_IS_IN_SPECTATOR_MODE())
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, Players::GetSelected().GetPed().GetHandle()),
STREAMING::SET_FOCUS_ENTITY(Players::GetSelected().GetPed().GetHandle());
{
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, playerPed);
STREAMING::SET_FOCUS_ENTITY(playerPed);
}

if (!STREAMING::IS_ENTITY_FOCUS(playerPed))
STREAMING::SET_FOCUS_ENTITY(playerPed);

if (!Players::GetSelected().IsValid() || !NETWORK::NETWORK_IS_PLAYER_CONNECTED(Players::GetSelected().GetId()))
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, 0), g_Spectating = false, Notifications::Show("Spectate", "Player is no longer in the session.\nSpectate mode disabled.", NotificationType::Warning);
{
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, 0);
STREAMING::SET_FOCUS_ENTITY(Self::PlayerPed);
g_Spectating = false;
STREAMING::CLEAR_FOCUS();
Notifications::Show("Spectate", "Player is no longer in the session.\nSpectate mode disabled.", NotificationType::Warning);
}
}
else
{
if (NETWORK::NETWORK_IS_IN_SPECTATOR_MODE())
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, 0);
{
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, Self::PlayerPed);
STREAMING::SET_FOCUS_ENTITY(Self::PlayerPed);
STREAMING::CLEAR_FOCUS();
CAM::_REQUEST_LETTER_BOX_NOW(false, false);
CAM::_FORCE_LETTER_BOX_THIS_UPDATE();
}
}
}


void BlockAllControls()
{
FiberPool::Push([] {
Expand Down Expand Up @@ -132,6 +158,5 @@ namespace YimMenu

ScriptMgr::Yield();
}

}
}

0 comments on commit 20503dd

Please sign in to comment.