2023-01-03 16:48:32 +00:00
|
|
|
#include "backend/player_command.hpp"
|
2023-03-01 21:27:15 +00:00
|
|
|
#include "gta/net_game_event.hpp"
|
2023-01-22 21:57:32 +00:00
|
|
|
#include "gta/script_handler.hpp"
|
2023-03-01 21:27:15 +00:00
|
|
|
#include "gta_util.hpp"
|
|
|
|
#include "hooking.hpp"
|
2023-06-06 07:40:40 +00:00
|
|
|
#include "lua/lua_manager.hpp"
|
2023-07-12 17:03:29 +00:00
|
|
|
#include "util/math.hpp"
|
2023-03-01 21:27:15 +00:00
|
|
|
#include "util/session.hpp"
|
2023-01-03 16:48:32 +00:00
|
|
|
|
2022-11-13 16:34:44 +00:00
|
|
|
#include <network/CNetGamePlayer.hpp>
|
2023-01-03 16:48:32 +00:00
|
|
|
#include <network/Network.hpp>
|
|
|
|
#include <script/globals/GPBD_FM_3.hpp>
|
2023-01-22 21:57:32 +00:00
|
|
|
#include <script/globals/GlobalPlayerBD.hpp>
|
2022-07-03 01:05:33 +02:00
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
|
|
|
void format_string(std::string_view player_name, std::string_view protection_type, bool should_log, bool should_notify)
|
|
|
|
{
|
|
|
|
if (should_log)
|
|
|
|
LOG(WARNING) << "BLOCKED_SCRIPT_EVENT From: " << player_name << " Event Type: " << protection_type;
|
|
|
|
|
|
|
|
if (should_notify)
|
|
|
|
g_notification_service->push_warning("Script Event Protection",
|
2023-03-01 21:27:15 +00:00
|
|
|
std::format("From: {}\nEvent Type: {}", player_name.data(), protection_type.data()));
|
2022-07-03 01:05:33 +02:00
|
|
|
}
|
|
|
|
|
2023-01-03 16:48:32 +00:00
|
|
|
inline bool is_player_driver_of_local_vehicle(Player sender)
|
|
|
|
{
|
|
|
|
auto plyr = g_player_service->get_by_id(sender);
|
|
|
|
|
|
|
|
if (!plyr || !plyr->get_current_vehicle() || !g_player_service->get_self()->get_current_vehicle())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return g_player_service->get_self()->get_current_vehicle()->m_driver == plyr->get_ped();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool is_player_our_goon(Player sender)
|
|
|
|
{
|
|
|
|
auto& boss_goon = scr_globals::gpbd_fm_3.as<GPBD_FM_3*>()->Entries[self::id].BossGoon;
|
|
|
|
|
|
|
|
if (boss_goon.Boss != self::id)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (int i = 0; i < boss_goon.Goons.Size; i++)
|
|
|
|
{
|
|
|
|
if (boss_goon.Goons[i] == sender)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-07-12 17:03:29 +00:00
|
|
|
inline bool is_player_our_boss(Player sender)
|
|
|
|
{
|
|
|
|
return sender == scr_globals::gpbd_fm_3.as<GPBD_FM_3*>()->Entries[self::id].BossGoon.Boss;
|
|
|
|
}
|
|
|
|
|
2022-07-03 01:05:33 +02:00
|
|
|
bool hooks::scripted_game_event(CScriptedGameEvent* scripted_game_event, CNetGamePlayer* player)
|
|
|
|
{
|
|
|
|
const auto args = scripted_game_event->m_args;
|
|
|
|
|
2023-03-01 21:27:15 +00:00
|
|
|
const auto hash = static_cast<eRemoteEvent>(args[0]);
|
2022-07-03 01:05:33 +02:00
|
|
|
const auto player_name = player->get_name();
|
|
|
|
|
2023-01-03 16:48:32 +00:00
|
|
|
auto plyr = g_player_service->get_by_id(player->m_player_id);
|
2022-07-03 01:05:33 +02:00
|
|
|
|
2023-07-01 22:40:17 +02:00
|
|
|
if (g_lua_manager && g_lua_manager->get_module_count() > 0)
|
2023-06-06 07:40:40 +00:00
|
|
|
{
|
|
|
|
std::vector<int32_t> script_event_args;
|
|
|
|
|
|
|
|
for (int i = 0; i < scripted_game_event->m_args_size; i++)
|
|
|
|
script_event_args.push_back(args[i]);
|
|
|
|
|
2023-07-02 00:59:02 +02:00
|
|
|
auto event_ret = g_lua_manager->trigger_event<menu_event::ScriptedGameEventReceived, bool>((int)player->m_player_id, script_event_args);
|
2023-06-06 07:40:40 +00:00
|
|
|
if (event_ret.has_value())
|
|
|
|
return true; // don't care, block event if any bool is returned
|
|
|
|
}
|
|
|
|
|
2022-07-03 01:05:33 +02:00
|
|
|
switch (hash)
|
|
|
|
{
|
|
|
|
case eRemoteEvent::Bounty:
|
2023-01-03 16:48:32 +00:00
|
|
|
if (g.protections.script_events.bounty && args[2] == self::id)
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.bounty.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2023-01-22 21:57:32 +00:00
|
|
|
case eRemoteEvent::CeoKick:
|
|
|
|
if (player->m_player_id != scr_globals::gpbd_fm_3.as<GPBD_FM_3*>()->Entries[self::id].BossGoon.Boss)
|
|
|
|
{
|
|
|
|
g.reactions.ceo_kick.process(plyr);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2022-07-03 01:05:33 +02:00
|
|
|
case eRemoteEvent::CeoMoney:
|
2023-03-01 21:27:15 +00:00
|
|
|
if (g.protections.script_events.ceo_money
|
|
|
|
&& player->m_player_id != scr_globals::gpbd_fm_3.as<GPBD_FM_3*>()->Entries[self::id].BossGoon.Boss)
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.ceo_money.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eRemoteEvent::ClearWantedLevel:
|
2023-01-03 16:48:32 +00:00
|
|
|
if (g.protections.script_events.clear_wanted_level && !is_player_driver_of_local_vehicle(player->m_player_id))
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.clear_wanted_level.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2023-03-01 21:27:15 +00:00
|
|
|
case eRemoteEvent::Crash: g.reactions.crash.process(plyr); return true;
|
2022-07-27 14:39:22 +02:00
|
|
|
case eRemoteEvent::Crash2:
|
2023-04-27 04:11:05 -04:00
|
|
|
if (args[2] > 32) // actual crash condition is if args[2] is above 255
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.crash.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2023-01-22 21:57:32 +00:00
|
|
|
case eRemoteEvent::Crash3:
|
|
|
|
{
|
|
|
|
if (isnan(*(float*)&args[3]) || isnan(*(float*)&args[4]))
|
|
|
|
{
|
|
|
|
g.reactions.crash.process(plyr);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2022-08-29 10:26:18 +00:00
|
|
|
case eRemoteEvent::Notification:
|
|
|
|
switch (static_cast<eRemoteEvent>(args[2]))
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2022-08-29 10:26:18 +00:00
|
|
|
case eRemoteEvent::NotificationMoneyBanked:
|
|
|
|
case eRemoteEvent::NotificationMoneyRemoved:
|
|
|
|
case eRemoteEvent::NotificationMoneyStolen:
|
2022-12-18 23:15:52 +01:00
|
|
|
if (g.protections.script_events.fake_deposit)
|
2022-08-29 10:26:18 +00:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.fake_deposit.process(plyr);
|
2022-08-29 10:26:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2022-07-03 01:05:33 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eRemoteEvent::ForceMission:
|
2022-12-18 23:15:52 +01:00
|
|
|
if (g.protections.script_events.force_mission)
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.force_mission.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2022-11-12 00:38:28 +01:00
|
|
|
case eRemoteEvent::GiveCollectible:
|
2023-01-03 16:48:32 +00:00
|
|
|
if (g.protections.script_events.give_collectible)
|
2022-11-12 00:38:28 +01:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.give_collectible.process(plyr);
|
|
|
|
return true;
|
2022-11-12 00:38:28 +01:00
|
|
|
}
|
|
|
|
break;
|
2022-07-03 01:05:33 +02:00
|
|
|
case eRemoteEvent::GtaBanner:
|
2022-12-18 23:15:52 +01:00
|
|
|
if (g.protections.script_events.gta_banner)
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.gta_banner.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eRemoteEvent::MCTeleport:
|
2023-07-12 17:03:29 +00:00
|
|
|
if (g.protections.script_events.mc_teleport && args[3] <= 32 && !is_player_our_boss(plyr->id()))
|
2022-08-29 10:26:18 +00:00
|
|
|
{
|
2023-07-12 17:03:29 +00:00
|
|
|
for (int i = 0; i < 32; i++)
|
|
|
|
{
|
|
|
|
if (args[4 + i] == NETWORK::NETWORK_HASH_FROM_PLAYER_HANDLE(self::id))
|
|
|
|
{
|
|
|
|
g.reactions.mc_teleport.process(plyr);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2022-08-29 10:26:18 +00:00
|
|
|
}
|
2023-01-03 16:48:32 +00:00
|
|
|
else if (args[3] > 32)
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.crash.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eRemoteEvent::PersonalVehicleDestroyed:
|
2022-12-18 23:15:52 +01:00
|
|
|
if (g.protections.script_events.personal_vehicle_destroyed)
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.personal_vehicle_destroyed.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eRemoteEvent::RemoteOffradar:
|
2023-07-12 17:03:29 +00:00
|
|
|
if (g.protections.script_events.remote_off_radar && !is_player_our_boss(plyr->id()) && !is_player_driver_of_local_vehicle(plyr->id()))
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.remote_off_radar.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2022-08-29 10:26:18 +00:00
|
|
|
case eRemoteEvent::TSECommand:
|
2023-07-12 17:03:29 +00:00
|
|
|
if (g.protections.script_events.rotate_cam && static_cast<eRemoteEvent>(args[2]) == eRemoteEvent::TSECommandRotateCam && !NETWORK::NETWORK_IS_ACTIVITY_SESSION())
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.rotate_cam.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2022-07-15 14:55:40 +02:00
|
|
|
case eRemoteEvent::SendToCayoPerico:
|
2023-01-03 16:48:32 +00:00
|
|
|
if (g.protections.script_events.send_to_location && args[3] == 0)
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.send_to_location.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eRemoteEvent::SendToCutscene:
|
2023-07-12 17:03:29 +00:00
|
|
|
if (g.protections.script_events.send_to_cutscene && !is_player_our_boss(plyr->id()))
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.send_to_cutscene.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2022-07-15 14:55:40 +02:00
|
|
|
case eRemoteEvent::SendToLocation:
|
|
|
|
{
|
2023-07-12 17:03:29 +00:00
|
|
|
if (is_player_our_boss(plyr->id()))
|
|
|
|
break;
|
|
|
|
|
2022-07-15 14:55:40 +02:00
|
|
|
bool known_location = false;
|
|
|
|
|
|
|
|
if (args[2] == 0 && args[3] == 0)
|
|
|
|
{
|
|
|
|
if (args[4] == 4 && args[5] == 0)
|
|
|
|
{
|
|
|
|
known_location = true;
|
|
|
|
|
2022-12-18 23:15:52 +01:00
|
|
|
if (g.protections.script_events.send_to_location)
|
2022-07-15 14:55:40 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.send_to_location.process(plyr);
|
2022-07-15 14:55:40 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((args[4] == 3 || args[4] == 4) && args[5] == 1)
|
|
|
|
{
|
|
|
|
known_location = true;
|
|
|
|
|
2022-12-18 23:15:52 +01:00
|
|
|
if (g.protections.script_events.send_to_location)
|
2022-07-15 14:55:40 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.send_to_location.process(plyr);
|
2022-07-15 14:55:40 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!known_location)
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.tse_freeze.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2022-07-15 14:55:40 +02:00
|
|
|
}
|
2022-07-03 01:05:33 +02:00
|
|
|
case eRemoteEvent::SoundSpam:
|
2023-01-03 16:48:32 +00:00
|
|
|
{
|
|
|
|
if (g.protections.script_events.sound_spam && (!plyr || plyr->m_invites_rate_limit.process()))
|
|
|
|
{
|
2023-07-12 17:03:29 +00:00
|
|
|
if (plyr->m_invites_rate_limit.exceeded_last_process())
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.sound_spam.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2023-01-03 16:48:32 +00:00
|
|
|
}
|
2022-07-03 01:05:33 +02:00
|
|
|
case eRemoteEvent::Spectate:
|
2022-12-18 23:15:52 +01:00
|
|
|
if (g.protections.script_events.spectate)
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.spectate_notification.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eRemoteEvent::Teleport:
|
2023-01-03 16:48:32 +00:00
|
|
|
if (g.protections.script_events.force_teleport && !is_player_driver_of_local_vehicle(player->m_player_id))
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.force_teleport.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2023-03-01 21:27:15 +00:00
|
|
|
case eRemoteEvent::TransactionError: g.reactions.transaction_error.process(plyr); return true;
|
2022-07-03 01:05:33 +02:00
|
|
|
case eRemoteEvent::VehicleKick:
|
2022-12-18 23:15:52 +01:00
|
|
|
if (g.protections.script_events.vehicle_kick)
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.vehicle_kick.process(plyr);
|
2022-07-03 01:05:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2022-12-14 16:27:40 +00:00
|
|
|
case eRemoteEvent::NetworkBail:
|
2023-07-12 17:03:29 +00:00
|
|
|
session::add_infraction(plyr, Infraction::TRIED_KICK_PLAYER);
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.network_bail.process(plyr);
|
|
|
|
return true;
|
2022-08-29 10:26:18 +00:00
|
|
|
case eRemoteEvent::TeleportToWarehouse:
|
2023-01-03 16:48:32 +00:00
|
|
|
if (g.protections.script_events.teleport_to_warehouse && !is_player_driver_of_local_vehicle(player->m_player_id))
|
2022-08-29 10:26:18 +00:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.teleport_to_warehouse.process(plyr);
|
2022-08-29 10:26:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eRemoteEvent::StartActivity:
|
2022-12-06 16:12:02 +00:00
|
|
|
{
|
2022-08-29 10:26:18 +00:00
|
|
|
eActivityType activity = static_cast<eActivityType>(args[2]);
|
2022-12-18 23:15:52 +01:00
|
|
|
if (g.protections.script_events.start_activity)
|
2022-08-29 10:26:18 +00:00
|
|
|
{
|
|
|
|
if (activity == eActivityType::Survival || activity == eActivityType::Mission || activity == eActivityType::Deathmatch || activity == eActivityType::BaseJump || activity == eActivityType::Race)
|
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.tse_freeze.process(plyr);
|
2022-08-29 10:26:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (activity == eActivityType::Darts)
|
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.start_activity.process(plyr);
|
2022-08-29 10:26:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (activity == eActivityType::PilotSchool)
|
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.start_activity.process(plyr);
|
2022-08-29 10:26:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (activity == eActivityType::ImpromptuDeathmatch)
|
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.start_activity.process(plyr);
|
2022-08-29 10:26:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
2023-01-22 21:57:32 +00:00
|
|
|
else if (activity == eActivityType::DefendSpecialCargo || activity == eActivityType::GunrunningDefend || activity == eActivityType::BikerDefend || args[2] == 238)
|
2022-08-29 10:26:18 +00:00
|
|
|
{
|
2023-01-22 21:57:32 +00:00
|
|
|
g.reactions.trigger_business_raid.process(plyr);
|
2022-08-29 10:26:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2023-01-03 16:48:32 +00:00
|
|
|
else if (activity == eActivityType::Tennis)
|
2022-08-29 10:26:18 +00:00
|
|
|
{
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.crash.process(plyr);
|
|
|
|
return true;
|
|
|
|
}
|
2022-08-29 10:26:18 +00:00
|
|
|
|
2023-01-03 16:48:32 +00:00
|
|
|
if (g.protections.script_events.start_activity && !is_player_our_goon(player->m_player_id))
|
|
|
|
{
|
|
|
|
g.reactions.start_activity.process(plyr);
|
2022-08-29 10:26:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
2023-01-03 16:48:32 +00:00
|
|
|
|
2022-08-29 10:26:18 +00:00
|
|
|
break;
|
2022-07-03 01:05:33 +02:00
|
|
|
}
|
2022-12-06 16:12:02 +00:00
|
|
|
case eRemoteEvent::InteriorControl:
|
2022-12-27 01:49:55 +08:00
|
|
|
{
|
2022-12-06 16:12:02 +00:00
|
|
|
int interior = (int)args[2];
|
2023-04-27 04:11:05 -04:00
|
|
|
if (interior < 0 || interior > 161) // the upper bound will change after an update
|
2022-12-06 16:12:02 +00:00
|
|
|
{
|
|
|
|
if (auto plyr = g_player_service->get_by_id(player->m_player_id))
|
|
|
|
session::add_infraction(plyr, Infraction::TRIED_KICK_PLAYER);
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.null_function_kick.process(plyr);
|
2022-12-06 16:12:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
2023-07-12 17:03:29 +00:00
|
|
|
|
|
|
|
if (NETWORK::NETWORK_IS_ACTIVITY_SESSION())
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (!g_local_player)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (is_player_our_boss(plyr->id()))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (is_player_driver_of_local_vehicle(plyr->id()))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (!plyr->get_ped() || math::distance_between_vectors(*plyr->get_ped()->get_position(), *g_local_player->get_position()) > 75.0f)
|
|
|
|
{
|
|
|
|
g.reactions.send_to_interior.process(plyr);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-12-06 16:12:02 +00:00
|
|
|
break;
|
|
|
|
}
|
2023-03-01 21:27:15 +00:00
|
|
|
case eRemoteEvent::DestroyPersonalVehicle: g.reactions.destroy_personal_vehicle.process(plyr); return true;
|
2023-01-22 21:57:32 +00:00
|
|
|
case eRemoteEvent::KickFromInterior:
|
|
|
|
if (scr_globals::globalplayer_bd.as<GlobalPlayerBD*>()->Entries[self::id].SimpleInteriorData.Owner != plyr->id())
|
|
|
|
{
|
|
|
|
g.reactions.kick_from_interior.process(plyr);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eRemoteEvent::TriggerCEORaid:
|
|
|
|
{
|
|
|
|
if (auto script = gta_util::find_script_thread(RAGE_JOAAT("freemode")))
|
|
|
|
{
|
2023-07-16 12:24:40 -04:00
|
|
|
if (script->m_net_component && ((CGameScriptHandlerNetComponent*)script->m_net_component)->m_host && ((CGameScriptHandlerNetComponent*)script->m_net_component)->m_host->m_net_game_player != player)
|
2023-01-22 21:57:32 +00:00
|
|
|
{
|
|
|
|
g.reactions.trigger_business_raid.process(plyr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2023-02-04 16:35:18 +00:00
|
|
|
case eRemoteEvent::StartScriptProceed:
|
2023-01-22 21:57:32 +00:00
|
|
|
{
|
2023-02-04 16:35:18 +00:00
|
|
|
// TODO: Breaks stuff
|
|
|
|
if (auto script = gta_util::find_script_thread(RAGE_JOAAT("freemode")))
|
|
|
|
{
|
2023-07-16 12:24:40 -04:00
|
|
|
if (script->m_net_component && ((CGameScriptHandlerNetComponent*)script->m_net_component)->m_host && ((CGameScriptHandlerNetComponent*)script->m_net_component)->m_host->m_net_game_player != player)
|
2023-02-04 16:35:18 +00:00
|
|
|
{
|
|
|
|
g.reactions.start_script.process(plyr);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2023-01-22 21:57:32 +00:00
|
|
|
}
|
2022-12-27 01:49:55 +08:00
|
|
|
}
|
2022-07-03 01:05:33 +02:00
|
|
|
|
2022-12-22 21:23:32 +00:00
|
|
|
// detect pasted menus setting args[1] to something other than PLAYER_ID()
|
|
|
|
if (*(int*)&args[1] != player->m_player_id && player->m_player_id != -1)
|
|
|
|
{
|
|
|
|
LOG(INFO) << "Hash = " << (int)args[0];
|
2023-01-22 21:57:32 +00:00
|
|
|
LOG(INFO) << "Sender = " << args[1];
|
2023-01-03 16:48:32 +00:00
|
|
|
g.reactions.tse_sender_mismatch.process(plyr);
|
2022-12-22 21:23:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-03-01 21:27:15 +00:00
|
|
|
if (g.debug.logs.script_event.logs
|
|
|
|
&& (!g.debug.logs.script_event.filter_player || g.debug.logs.script_event.player_id == player->m_player_id))
|
2022-07-03 01:05:33 +02:00
|
|
|
{
|
2022-10-23 20:48:51 +02:00
|
|
|
std::string script_args = "{ ";
|
|
|
|
for (std::size_t i = 0; i < scripted_game_event->m_args_size; i++)
|
|
|
|
{
|
|
|
|
if (i)
|
|
|
|
script_args += ", ";
|
2022-07-03 01:05:33 +02:00
|
|
|
|
2023-01-03 16:48:32 +00:00
|
|
|
script_args += std::to_string((int)args[i]);
|
2022-10-23 20:48:51 +02:00
|
|
|
}
|
|
|
|
script_args += " };";
|
2022-07-03 01:05:33 +02:00
|
|
|
|
2023-02-08 23:36:55 +01:00
|
|
|
LOG(VERBOSE) << "Script Event:\n"
|
2023-03-01 21:27:15 +00:00
|
|
|
<< "\tPlayer: " << player->get_name() << "\n"
|
|
|
|
<< "\tArgs: " << script_args;
|
2022-07-03 01:05:33 +02:00
|
|
|
}
|
|
|
|
|
2023-02-20 06:04:13 +08:00
|
|
|
if (g.debug.logs.script_event.block_all)
|
|
|
|
return true;
|
|
|
|
|
2022-07-03 01:05:33 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|