diff --git a/cmake/gtav-classes.cmake b/cmake/gtav-classes.cmake index 66e05572..2ae3d1d5 100644 --- a/cmake/gtav-classes.cmake +++ b/cmake/gtav-classes.cmake @@ -3,7 +3,7 @@ include(FetchContent) FetchContent_Declare( gtav_classes GIT_REPOSITORY https://github.com/Mr-X-GTA/GTAV-Classes-1.git - GIT_TAG 9ca0cb74882505d7d2c382e9a588972fd4589775 + GIT_TAG e803b20ec3d6cf20d6b254c915e088bd010f006e GIT_PROGRESS TRUE CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/src/util/scripts.hpp b/src/util/scripts.hpp index 366bc69d..b02158c0 100644 --- a/src/util/scripts.hpp +++ b/src/util/scripts.hpp @@ -6,6 +6,7 @@ #include "gta_util.hpp" #include "misc.hpp" #include "natives.hpp" +#include "packet.hpp" #include "script.hpp" #include "script_local.hpp" #include "services/players/player_service.hpp" @@ -63,21 +64,34 @@ namespace big::scripts { if (auto launcher = gta_util::find_script_thread(hash); launcher && launcher->m_net_component) { - for (int i = 0; !((CGameScriptHandlerNetComponent*)launcher->m_net_component)->is_local_player_host(); i++) + auto net_component = reinterpret_cast(launcher->m_net_component); + + if (net_component->is_local_player_host()) { - if (i > 200) - return false; - - ((CGameScriptHandlerNetComponent*)launcher->m_net_component) - ->send_host_migration_event(g_player_service->get_self()->get_net_game_player()); - script::get_current()->yield(10ms); - - if (!launcher->m_stack || !launcher->m_net_component) - return false; + return true; } + + net_component->do_host_migration(g_player_service->get_self()->get_net_game_player(), 0xFFFF, true); + + packet pack; + pack.write_message(rage::eNetMessage::MsgScriptVerifyHostAck); + net_component->m_script_handler->get_id()->serialize(&pack.m_buffer); + pack.write(true, 1); + pack.write(true, 1); + pack.write(0xFFFF, 16); + + for (auto& player : g_player_service->players()) + { + if (player.second->get_net_game_player()) + { + pack.send(player.second->get_net_game_player()->m_msg_id); + } + } + + return true; } - return true; + return false; } inline int launcher_index_from_hash(rage::joaat_t script_hash)