2021-05-19 11:27:47 +02:00
|
|
|
#pragma once
|
2021-05-25 14:11:13 +02:00
|
|
|
#include "entity.hpp"
|
2021-05-19 11:27:47 +02:00
|
|
|
#include "gta/joaat.hpp"
|
2021-05-25 14:11:13 +02:00
|
|
|
#include "math.hpp"
|
2021-05-19 11:27:47 +02:00
|
|
|
#include "natives.hpp"
|
|
|
|
#include "pointers.hpp"
|
|
|
|
#include "script.hpp"
|
2021-09-21 13:39:15 +02:00
|
|
|
#include "teleport.hpp"
|
2021-05-19 11:27:47 +02:00
|
|
|
|
|
|
|
namespace big::vehicle
|
|
|
|
{
|
2021-05-21 14:09:28 +02:00
|
|
|
inline void bring(Vehicle veh, Vector3 location, bool put_in = true)
|
|
|
|
{
|
2021-09-21 13:39:15 +02:00
|
|
|
Vector3 vecVehicleLocation = ENTITY::GET_ENTITY_COORDS(veh, true);
|
|
|
|
teleport::load_ground_at_3dcoord(vecVehicleLocation);
|
2021-05-25 14:11:13 +02:00
|
|
|
|
2021-09-21 13:39:15 +02:00
|
|
|
if (!entity::take_control_of(veh))
|
2022-03-02 00:21:29 +01:00
|
|
|
return g_notification_service->push_warning("Vehicle", "Failed to take control of remote vehicle.");
|
2021-09-21 13:39:15 +02:00
|
|
|
ENTITY::SET_ENTITY_COORDS(veh, location.x, location.y, location.z + 1.f, 0, 0, 0, 0);
|
2022-01-18 02:03:20 +01:00
|
|
|
ENTITY::SET_ENTITY_HEADING(veh, ENTITY::GET_ENTITY_HEADING(PLAYER::PLAYER_PED_ID()));
|
2021-05-21 14:09:28 +02:00
|
|
|
|
|
|
|
if (put_in)
|
|
|
|
{
|
2021-05-25 14:11:13 +02:00
|
|
|
for (size_t i = 0; i < 100 && math::distance_between_vectors(location, ENTITY::GET_ENTITY_COORDS(veh, true)) > 10; i++)
|
|
|
|
script::get_current()->yield();
|
|
|
|
|
2021-05-21 14:09:28 +02:00
|
|
|
PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), veh, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline Vehicle get_closest_to_location(Vector3 location, float range, int flags = 70)
|
|
|
|
{
|
|
|
|
return VEHICLE::GET_CLOSEST_VEHICLE(location.x, location.y, location.z, range, 0, flags);
|
|
|
|
}
|
|
|
|
|
2021-07-23 11:58:43 +02:00
|
|
|
inline bool repair(Vehicle veh)
|
|
|
|
{
|
2022-01-07 17:00:42 +01:00
|
|
|
if (!ENTITY::IS_ENTITY_A_VEHICLE(veh) || !entity::take_control_of(veh)) return false;
|
2021-08-03 20:25:55 +02:00
|
|
|
|
2021-07-23 11:58:43 +02:00
|
|
|
VEHICLE::SET_VEHICLE_FIXED(veh);
|
|
|
|
VEHICLE::SET_VEHICLE_DEFORMATION_FIXED(veh);
|
|
|
|
VEHICLE::SET_VEHICLE_DIRT_LEVEL(veh, 0.f);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-03-14 23:31:30 +01:00
|
|
|
inline int spawn(std::string_view model, Vector3 location, float heading, bool is_networked = true)
|
2021-05-19 11:27:47 +02:00
|
|
|
{
|
2022-03-14 23:31:30 +01:00
|
|
|
if (const Hash hash = rage::joaat(model.data()); hash)
|
2021-05-19 11:27:47 +02:00
|
|
|
{
|
|
|
|
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))
|
|
|
|
{
|
2022-03-02 00:21:29 +01:00
|
|
|
g_notification_service->push_warning("Spawn", "Failed to spawn model, did you give an incorrect model?");
|
2021-05-19 11:27:47 +02:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*(unsigned short*)g_pointers->m_model_spawn_bypass = 0x9090;
|
2022-03-14 23:31:30 +01:00
|
|
|
Vehicle veh = VEHICLE::CREATE_VEHICLE(hash, location.x, location.y, location.z, heading, is_networked, false, false);
|
2021-05-19 11:27:47 +02:00
|
|
|
*(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);
|
2021-11-08 13:00:04 +01:00
|
|
|
ENTITY::SET_ENTITY_CLEANUP_BY_ENGINE_(veh, true);
|
2021-05-19 11:27:47 +02:00
|
|
|
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;
|
|
|
|
}
|
2022-03-21 17:05:13 -04:00
|
|
|
|
|
|
|
inline void telport_into_veh(Vehicle veh)
|
|
|
|
{
|
|
|
|
PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), veh, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void max_vehicle(Vehicle veh)
|
|
|
|
{
|
|
|
|
VEHICLE::SET_VEHICLE_MOD_KIT(veh, 0);
|
|
|
|
VEHICLE::TOGGLE_VEHICLE_MOD(veh, 18 /* Turbo */, TRUE);
|
|
|
|
VEHICLE::TOGGLE_VEHICLE_MOD(veh, 20 /* Tire Smoke */, TRUE);
|
|
|
|
VEHICLE::TOGGLE_VEHICLE_MOD(veh, 17 /* Xenon Headlights */, TRUE);
|
|
|
|
VEHICLE::SET_VEHICLE_WINDOW_TINT(veh, 1);
|
|
|
|
for (int i = 0; i < 50; i++)
|
|
|
|
{
|
|
|
|
VEHICLE::SET_VEHICLE_MOD(veh, i, VEHICLE::GET_NUM_VEHICLE_MODS(veh, i) - 1, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 11:27:47 +02:00
|
|
|
}
|