2021-05-26 13:33:26 +02:00
|
|
|
#include "backend/looped/looped.hpp"
|
|
|
|
#include "natives.hpp"
|
2022-01-31 18:27:35 +01:00
|
|
|
#include "services/player_service.hpp"
|
2021-05-26 13:33:26 +02:00
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
2021-07-23 23:02:26 +02:00
|
|
|
static bool bReset = true;
|
2021-05-26 13:33:26 +02:00
|
|
|
|
2022-03-21 18:02:30 +01:00
|
|
|
void looped::player_spectate()
|
2021-05-26 13:33:26 +02:00
|
|
|
{
|
2022-02-22 01:18:49 +01:00
|
|
|
if (!g_player_service->get_selected()->is_valid() || !g->player.spectating)
|
2021-07-23 23:02:26 +02:00
|
|
|
{
|
2022-02-22 01:18:49 +01:00
|
|
|
if (g->player.spectating) g->player.spectating = false;
|
2021-05-26 13:33:26 +02:00
|
|
|
|
2021-07-23 23:02:26 +02:00
|
|
|
if (!bReset)
|
|
|
|
{
|
|
|
|
bReset = true;
|
2021-05-26 13:33:26 +02:00
|
|
|
|
2022-02-01 23:14:58 +01:00
|
|
|
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, -1);
|
2021-09-19 12:31:15 +02:00
|
|
|
HUD::SET_MINIMAP_IN_SPECTATOR_MODE(false, -1);
|
2022-03-30 23:40:49 +02:00
|
|
|
ENTITY::FREEZE_ENTITY_POSITION(PLAYER::PLAYER_PED_ID(), false);
|
2022-05-08 00:13:53 +03:00
|
|
|
ENTITY::FREEZE_ENTITY_POSITION(PED::GET_VEHICLE_PED_IS_USING(PLAYER::PLAYER_PED_ID()), false);
|
2021-07-23 23:02:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-21 18:02:30 +01:00
|
|
|
const Ped target = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player_service->get_selected()->id());
|
2021-09-19 12:31:15 +02:00
|
|
|
|
2022-02-01 23:14:58 +01:00
|
|
|
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, target);
|
2021-09-19 12:31:15 +02:00
|
|
|
HUD::SET_MINIMAP_IN_SPECTATOR_MODE(true, target);
|
2022-03-30 23:40:49 +02:00
|
|
|
ENTITY::FREEZE_ENTITY_POSITION(PLAYER::PLAYER_PED_ID(), true);
|
2022-05-08 00:13:53 +03:00
|
|
|
ENTITY::FREEZE_ENTITY_POSITION(PED::GET_VEHICLE_PED_IS_USING(PLAYER::PLAYER_PED_ID()), true);
|
2022-03-21 18:02:30 +01:00
|
|
|
|
2021-07-23 23:02:26 +02:00
|
|
|
bReset = false;
|
2021-05-26 13:33:26 +02:00
|
|
|
}
|
2022-05-08 00:13:53 +03:00
|
|
|
}
|