feat(Vehicle): Added bring vehicle button

This commit is contained in:
Yimura 2021-05-21 14:09:28 +02:00
parent b21d6d23f3
commit 9b0bae0272
No known key found for this signature in database
GPG Key ID: 3D8FF4397E768682
3 changed files with 63 additions and 0 deletions

View File

@ -1,5 +1,11 @@
#include "core/data/speedo_meters.hpp"
#include "fiber_pool.hpp"
#include "gui/window/main/tabs.hpp"
#include "script.hpp"
#include "util/blip.hpp"
#include "util/entity.hpp"
#include "util/notify.hpp"
#include "util/vehicle.hpp"
namespace big
{
@ -9,6 +15,24 @@ namespace big
{
if (ImGui::BeginTabItem("Vehicle"))
{
if (ImGui::Button("Bring Personal Vehicle"))
{
QUEUE_JOB_BEGIN_CLAUSE()
{
Vector3 location;
if (!blip::get_blip_location(location, 225, 0)) return notify::above_map("No personal vehicle found, was it destroyed?");
Vehicle veh = vehicle::get_closest_to_location(location, 5.f);
if (veh == 0) return notify::above_map("Invalid vehicle handle...");
location = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true);
entity::take_control_of(veh);
vehicle::bring(veh, location);
}QUEUE_JOB_END_CLAUSE
}
if (ImGui::TreeNode("Speedo Meter"))
{
SpeedoMeter selected = g.vehicle.speedo_meter;

View File

@ -0,0 +1,23 @@
#pragma once
#include "gta/enums.hpp"
#include "natives.hpp"
#include "script.hpp"
namespace big::blip
{
inline bool get_blip_location(Vector3 &location, int sprite, int color = -1)
{
Blip blip;
for (blip = HUD::GET_FIRST_BLIP_INFO_ID(sprite);
HUD::DOES_BLIP_EXIST(blip) &&
color != -1 && HUD::GET_BLIP_COLOUR(blip);
blip = HUD::GET_NEXT_BLIP_INFO_ID(sprite)
) script::get_current()->yield();
if (!HUD::DOES_BLIP_EXIST(blip) || (color != -1 && HUD::GET_BLIP_COLOUR(blip) != color)) return false;
location = HUD::GET_BLIP_COORDS(blip);
return true;
}
}

View File

@ -7,6 +7,22 @@
namespace big::vehicle
{
inline void bring(Vehicle veh, Vector3 location, bool put_in = true)
{
ENTITY::SET_ENTITY_COORDS(veh, location.x, location.y, location.z + 1.f, 0, 0, 0, 1);
if (put_in)
{
script::get_current()->yield(100ms);
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);
}
inline int spawn(const char* model, Vector3 location, float heading)
{
Hash hash = rage::joaat(model);