2021-08-05 01:26:23 +02:00
|
|
|
#pragma once
|
|
|
|
#include "core/data/session_types.hpp"
|
|
|
|
#include "script_global.hpp"
|
|
|
|
#include "script.hpp"
|
2022-03-21 17:06:16 -04:00
|
|
|
#include "natives.hpp"
|
2022-10-26 20:27:15 +02:00
|
|
|
#include "util/misc.hpp"
|
|
|
|
#include "util/globals.hpp"
|
2022-10-26 14:12:29 +02:00
|
|
|
#include "gta/joaat.hpp"
|
|
|
|
#include "rage/rlSessionByGamerTaskResult.hpp"
|
|
|
|
#include "pointers.hpp"
|
2022-11-19 01:49:36 +00:00
|
|
|
#include "services/players/player_service.hpp"
|
|
|
|
#include "services/player_database/player_database_service.hpp"
|
2021-08-05 01:26:23 +02:00
|
|
|
|
|
|
|
namespace big::session
|
|
|
|
{
|
2022-10-19 00:30:32 +02:00
|
|
|
inline void join_type(eSessionType session)
|
2021-08-05 01:26:23 +02:00
|
|
|
{
|
2022-10-19 00:30:32 +02:00
|
|
|
*script_global(2726795).as<int*>() = (session == eSessionType::SC_TV ? 1 : 0); // If SC TV Then Enable Spectator Mode
|
2022-08-14 18:19:15 +08:00
|
|
|
|
2022-10-19 00:30:32 +02:00
|
|
|
if (session == eSessionType::LEAVE_ONLINE)
|
2022-05-03 09:02:18 -04:00
|
|
|
*script_global(1574589).at(2).as<int*>() = -1;
|
2021-08-05 01:26:23 +02:00
|
|
|
else
|
2022-10-19 00:30:32 +02:00
|
|
|
*script_global(1575015).as<int*>() = (int)session;
|
2021-08-05 01:26:23 +02:00
|
|
|
|
2022-05-03 09:02:18 -04:00
|
|
|
*script_global(1574589).as<int*>() = 1;
|
2021-08-05 01:26:23 +02:00
|
|
|
script::get_current()->yield(200ms);
|
2022-05-03 09:02:18 -04:00
|
|
|
*script_global(1574589).as<int*>() = 0;
|
2021-08-05 01:26:23 +02:00
|
|
|
}
|
2022-03-21 17:06:16 -04:00
|
|
|
|
2022-10-19 00:30:32 +02:00
|
|
|
static constexpr char const* weathers[] = {
|
|
|
|
"EXTRASUNNY", "CLEAR", "CLOUDS", "SMOG",
|
|
|
|
"FOGGY", "OVERCAST", "RAIN", "THUNDER",
|
|
|
|
"CLEARING", "NEUTRAL", "SNOW", "BLIZZARD",
|
|
|
|
"SNOWLIGHT", "XMAS", "HALLOWEEN" };
|
|
|
|
inline void local_weather()
|
2022-03-21 17:06:16 -04:00
|
|
|
{
|
|
|
|
MISC::CLEAR_OVERRIDE_WEATHER();
|
|
|
|
|
|
|
|
MISC::SET_OVERRIDE_WEATHER(weathers[g->session.local_weather]);
|
|
|
|
|
|
|
|
*script_global(262145).at(4723).as<bool*>() = g->session.local_weather == 13;
|
|
|
|
}
|
2022-10-26 14:12:29 +02:00
|
|
|
|
2022-10-26 20:27:15 +02:00
|
|
|
inline void set_fm_event_index(int index)
|
|
|
|
{
|
|
|
|
int idx = index / 32;
|
|
|
|
int bit = index % 32;
|
2022-11-21 15:42:12 +00:00
|
|
|
misc::set_bit(scr_globals::gsbd_fm_events.at(11).at(341).at(idx, 1).as<int*>(), bit);
|
|
|
|
misc::set_bit(scr_globals::gsbd_fm_events.at(11).at(348).at(idx, 1).as<int*>(), bit);
|
|
|
|
misc::set_bit(scr_globals::gpbd_fm_3.at(self::id, scr_globals::size::gpbd_fm_3).at(10).at(205).at(idx, 1).as<int*>(), bit);
|
2022-10-26 20:27:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void force_thunder()
|
|
|
|
{
|
|
|
|
session::set_fm_event_index(9);
|
|
|
|
session::set_fm_event_index(10);
|
|
|
|
session::set_fm_event_index(11);
|
|
|
|
}
|
|
|
|
|
2022-10-26 14:12:29 +02:00
|
|
|
inline void join_by_rockstar_id(uint64_t rid)
|
|
|
|
{
|
|
|
|
if (SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(RAGE_JOAAT("maintransition")) != 0 ||
|
|
|
|
STREAMING::IS_PLAYER_SWITCH_IN_PROGRESS())
|
|
|
|
{
|
|
|
|
g_notification_service->push_error("RID Joiner", "Player switch in progress, wait a bit.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rage::rlGamerHandle player_handle(rid);
|
|
|
|
rage::rlSessionByGamerTaskResult result;
|
|
|
|
bool success = false;
|
|
|
|
int state = 0;
|
|
|
|
if (g_pointers->m_start_get_session_by_gamer_handle(0, &player_handle, 1, &result, 1, &success, &state))
|
|
|
|
{
|
|
|
|
while (state == 1)
|
|
|
|
script::get_current()->yield();
|
|
|
|
|
|
|
|
if (state == 3 && success)
|
|
|
|
{
|
|
|
|
g->session.join_queued = true;
|
|
|
|
g->session.info = result.m_session_info;
|
|
|
|
session::join_type({ eSessionType::NEW_PUBLIC });
|
|
|
|
if (SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(RAGE_JOAAT("maintransition")) == 0)
|
|
|
|
{
|
|
|
|
g->session.join_queued = false;
|
|
|
|
g_notification_service->push_error("RID Joiner", "Unable to launch maintransition");
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-21 15:42:12 +00:00
|
|
|
g_notification_service->push_error("RID Joiner", "Target player is offline?");
|
2022-10-26 14:12:29 +02:00
|
|
|
}
|
2022-11-19 01:49:36 +00:00
|
|
|
|
|
|
|
inline void add_infraction(player_ptr player, Infraction infraction)
|
|
|
|
{
|
|
|
|
auto plyr = g_player_database_service->get_or_create_player(player);
|
2022-11-21 15:42:12 +00:00
|
|
|
if (!plyr->infractions.contains((int)infraction))
|
|
|
|
{
|
|
|
|
plyr->is_modder = true;
|
|
|
|
player->is_modder = true;
|
|
|
|
plyr->infractions.insert((int)infraction);
|
|
|
|
g_player_database_service->save();
|
|
|
|
}
|
2022-11-19 01:49:36 +00:00
|
|
|
}
|
2022-10-26 14:12:29 +02:00
|
|
|
}
|