48 lines
1.1 KiB
C++
Raw Normal View History

2021-05-26 13:33:26 +02:00
#include "backend/looped/looped.hpp"
#include "natives.hpp"
#include "services/players/player_service.hpp"
#include "util/globals.hpp"
2021-05-26 13:33:26 +02:00
namespace big
{
static bool bReset = true;
2021-05-26 13:33:26 +02:00
void looped::player_spectate()
2021-05-26 13:33:26 +02:00
{
const auto vehicle = self::veh;
const auto ped = self::ped;
if (!g_player_service->get_selected()->is_valid() || !g.player.spectating)
{
if (g.player.spectating) g.player.spectating = false;
2021-05-26 13:33:26 +02:00
if (!bReset)
{
bReset = true;
2021-05-26 13:33:26 +02:00
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, -1);
HUD::SET_MINIMAP_IN_SPECTATOR_MODE(false, -1);
ENTITY::FREEZE_ENTITY_POSITION(ped, false);
ENTITY::FREEZE_ENTITY_POSITION(vehicle, false);
STREAMING::SET_FOCUS_ENTITY(ped);
}
return;
}
const auto target = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player_service->get_selected()->id());
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, target);
HUD::SET_MINIMAP_IN_SPECTATOR_MODE(true, target);
ENTITY::FREEZE_ENTITY_POSITION(ped, true);
ENTITY::FREEZE_ENTITY_POSITION(vehicle, true);
STREAMING::SET_FOCUS_ENTITY(target);
bReset = false;
2021-05-26 13:33:26 +02:00
}
}