From e2b49fd59fe11e4ba1294d4d2f821e16ee33b697 Mon Sep 17 00:00:00 2001 From: Yimura Date: Thu, 14 Jan 2021 21:32:24 +0100 Subject: [PATCH] feat(Functions): Added spawn vehicle func --- BigBaseV2/src/features/functions.cpp | 43 ++++++++++++++++++++++++++++ BigBaseV2/src/features/functions.hpp | 2 ++ 2 files changed, 45 insertions(+) diff --git a/BigBaseV2/src/features/functions.cpp b/BigBaseV2/src/features/functions.cpp index 26531bd2..25df2dd0 100644 --- a/BigBaseV2/src/features/functions.cpp +++ b/BigBaseV2/src/features/functions.cpp @@ -184,4 +184,47 @@ namespace big::features::functions { return sqrt(pow((a.x - b.x), 2) + pow((a.y - b.y), 2) + pow((a.z - b.z), 2)); } + + Entity spawn_vehicle(const char* model, Vector3 location, float heading) + { + Hash hash = MISC::GET_HASH_KEY(model); + + if (hash) + { + for (uint8_t i = 0; !STREAMING::HAS_MODEL_LOADED(hash) && i < 100; i++) + { + STREAMING::REQUEST_MODEL(hash); + + script::get_current()->yield(); + } + if (!STREAMING::HAS_MODEL_LOADED(hash)) + { + notify::above_map("~r~Failed to spawn model, did you give an incorrect model?"); + + return -1; + } + + *(unsigned short*)g_pointers->m_model_spawn_bypass = 0x9090; + Vehicle veh = VEHICLE::CREATE_VEHICLE(hash, location.x, location.y, location.z, heading, true, false, false); + *(unsigned short*)g_pointers->m_model_spawn_bypass = 0x0574; + + script::get_current()->yield(); + + STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(hash); + + if (*g_pointers->m_is_session_started) + { + DECORATOR::DECOR_SET_INT(veh, "MPBitset", 0); + ENTITY::_SET_ENTITY_SOMETHING(veh, true); + int networkId = NETWORK::VEH_TO_NET(veh); + if (NETWORK::NETWORK_GET_ENTITY_IS_NETWORKED(veh)) + NETWORK::SET_NETWORK_ID_EXISTS_ON_ALL_MACHINES(networkId, true); + VEHICLE::SET_VEHICLE_IS_STOLEN(veh, false); + } + + return veh; + } + + return -1; + } } \ No newline at end of file diff --git a/BigBaseV2/src/features/functions.hpp b/BigBaseV2/src/features/functions.hpp index 67aaf485..cc54250f 100644 --- a/BigBaseV2/src/features/functions.hpp +++ b/BigBaseV2/src/features/functions.hpp @@ -13,6 +13,8 @@ namespace big::features::functions void spoof_rank(int rank); void toggle_protections(bool toggle); + Entity spawn_vehicle(const char* model, Vector3 location, float heading); + bool take_control_of_entity(Entity ent); BOOL raycast_entity(Entity* ent);