From d393fb37684d250ec72ce40292e6012607ce1649 Mon Sep 17 00:00:00 2001 From: Yimura Date: Wed, 19 May 2021 11:27:47 +0200 Subject: [PATCH] feat(Util): Added vehicle::spawn and notify::above_map --- BigBaseV2/src/util/all.hpp | 3 ++ BigBaseV2/src/util/notify.hpp | 13 +++++++++ BigBaseV2/src/util/vehicle.hpp | 52 ++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 BigBaseV2/src/util/all.hpp create mode 100644 BigBaseV2/src/util/notify.hpp create mode 100644 BigBaseV2/src/util/vehicle.hpp diff --git a/BigBaseV2/src/util/all.hpp b/BigBaseV2/src/util/all.hpp new file mode 100644 index 00000000..efad1bfe --- /dev/null +++ b/BigBaseV2/src/util/all.hpp @@ -0,0 +1,3 @@ +#pragma once +#include "notify.hpp" +#include "vehicle.hpp" \ No newline at end of file diff --git a/BigBaseV2/src/util/notify.hpp b/BigBaseV2/src/util/notify.hpp new file mode 100644 index 00000000..495ea836 --- /dev/null +++ b/BigBaseV2/src/util/notify.hpp @@ -0,0 +1,13 @@ +#pragma once +#include "natives.hpp" + +namespace big::notify +{ + inline void above_map(const char* text) + { + HUD::SET_TEXT_OUTLINE(); + HUD::BEGIN_TEXT_COMMAND_THEFEED_POST("STRING"); + HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(text); + HUD::END_TEXT_COMMAND_THEFEED_POST_TICKER(false, false); + } +} \ No newline at end of file diff --git a/BigBaseV2/src/util/vehicle.hpp b/BigBaseV2/src/util/vehicle.hpp new file mode 100644 index 00000000..5b6533b6 --- /dev/null +++ b/BigBaseV2/src/util/vehicle.hpp @@ -0,0 +1,52 @@ +#pragma once +#include "gta/joaat.hpp" +#include "natives.hpp" +#include "notify.hpp" +#include "pointers.hpp" +#include "script.hpp" + +namespace big::vehicle +{ + inline int spawn(const char* model, Vector3 location, float heading) + { + Hash hash = rage::joaat(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