From 51cd6e37ff3f8dbfae8f2966209dd914cd5656be Mon Sep 17 00:00:00 2001 From: gir489 <100792176+gir489returns@users.noreply.github.com> Date: Sat, 27 Apr 2024 10:10:35 -0400 Subject: [PATCH] Fixed commands not working in single player. (#2980) * Fixed commands not working in single player. * Code review changes. --- src/backend/commands/spawn/spawn_vehicle.cpp | 10 +++++----- src/native_hooks/shop_controller.hpp | 2 +- src/services/players/player.cpp | 5 ++++- src/util/vehicle.cpp | 5 ++++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/backend/commands/spawn/spawn_vehicle.cpp b/src/backend/commands/spawn/spawn_vehicle.cpp index 3dba2f35..aea19dea 100644 --- a/src/backend/commands/spawn/spawn_vehicle.cpp +++ b/src/backend/commands/spawn/spawn_vehicle.cpp @@ -32,11 +32,11 @@ namespace big return; } - const auto spawn_location = - vehicle::get_spawn_location(ctx->get_sender()->id() == self::id ? g.spawn_vehicle.spawn_inside : false, - hash, - PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(ctx->get_sender()->id())); - const auto spawn_heading = ENTITY::GET_ENTITY_HEADING(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(ctx->get_sender()->id())); + auto id = ctx->get_sender()->id(); + + const auto spawn_location = vehicle::get_spawn_location(id == self::id ? g.spawn_vehicle.spawn_inside : false, + hash, PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(id)); + const auto spawn_heading = ENTITY::GET_ENTITY_HEADING(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(id)); auto veh = vehicle::spawn(hash, spawn_location, spawn_heading); diff --git a/src/native_hooks/shop_controller.hpp b/src/native_hooks/shop_controller.hpp index da505ec0..e90df4b0 100644 --- a/src/native_hooks/shop_controller.hpp +++ b/src/native_hooks/shop_controller.hpp @@ -36,7 +36,7 @@ namespace big { if (g.window.gui.format_money) { - auto arg0 = src->get_arg(0); + auto arg0 = src->get_arg(0); Hash casino_chips = self::char_index ? "MP1_CASINO_CHIPS"_J : "MP0_CASINO_CHIPS"_J; int player_chips; diff --git a/src/services/players/player.cpp b/src/services/players/player.cpp index 5103cd50..5116767d 100644 --- a/src/services/players/player.cpp +++ b/src/services/players/player.cpp @@ -127,7 +127,10 @@ namespace big uint8_t player::id() const { - return m_net_game_player == nullptr ? -1 : m_net_game_player->m_player_id; + if (*g_pointers->m_gta.m_is_session_started) + return m_net_game_player == nullptr ? -1 : m_net_game_player->m_player_id; + else + return self::id; } bool player::is_host() const diff --git a/src/util/vehicle.cpp b/src/util/vehicle.cpp index daac2dc0..c13c921f 100644 --- a/src/util/vehicle.cpp +++ b/src/util/vehicle.cpp @@ -152,13 +152,16 @@ namespace big::vehicle Vehicle spawn(Hash hash, Vector3 location, float heading, bool is_networked, bool script_veh) { + if (is_networked && !*g_pointers->m_gta.m_is_session_started) + is_networked = false; + if (entity::request_model(hash)) { auto veh = VEHICLE::CREATE_VEHICLE(hash, location.x, location.y, location.z, heading, is_networked, script_veh, false); STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(hash); - if (is_networked && *g_pointers->m_gta.m_is_session_started) + if (is_networked) { set_mp_bitset(veh); }