feat(Player): Added Flying vehicle

Co-authored-by: LiamD-Flop
This commit is contained in:
Mystro 2022-05-05 23:51:18 +03:00 committed by GitHub
parent cf22bdc63a
commit 28640b453e
8 changed files with 56 additions and 6 deletions

View File

@ -88,6 +88,7 @@ namespace big
looped::vehicle_drive_on_water();
looped::vehicle_god_mode();
looped::vehicle_horn_boost();
looped::vehicle_instant_brake();
looped::vehicle_is_targetable();
looped::vehicle_rainbow_paint();
looped::vehicle_speedo_meter();
@ -98,4 +99,4 @@ namespace big
looped::vehicle_ls_customs();
}QUEUE_JOB_END_CLAUSE
}
}
}

View File

@ -38,6 +38,7 @@ namespace big
static void vehicle_drive_on_water();
static void vehicle_god_mode();
static void vehicle_horn_boost();
static void vehicle_instant_brake();
static void vehicle_is_targetable();
static void vehicle_ls_customs();
static void vehicle_rainbow_paint();
@ -57,4 +58,4 @@ namespace big
static void weapons_steal_vehicle_gun();
static void weapons_vehicle_gun();
};
}
}

View File

@ -0,0 +1,21 @@
#include "backend/looped/looped.hpp"
#include "gta/enums.hpp"
#include "natives.hpp"
namespace big
{
void looped::vehicle_instant_brake()
{
if (!g->vehicle.instant_brake) return;
const Vehicle veh = PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), false);
if (veh == 0 || ENTITY::GET_ENTITY_SPEED_VECTOR(veh, true).y < 1.f)
{
return;
}
if (PAD::IS_CONTROL_PRESSED(0, 33))
VEHICLE::SET_VEHICLE_FORWARD_SPEED(veh, 0);
}
}

View File

@ -194,6 +194,7 @@ namespace big
bool drive_on_water = false;
bool god_mode = false;
bool horn_boost = false;
bool instant_brake = false;
bool is_targetable = true;
bool ls_customs = false; // don't save this to disk
bool pv_teleport_into = false;
@ -428,6 +429,7 @@ namespace big
this->vehicle.drive_on_water = j["vehicle"]["drive_on_water"];
this->vehicle.god_mode = j["vehicle"]["god_mode"];
this->vehicle.horn_boost = j["vehicle"]["horn_boost"];
this->vehicle.instant_brake = j["vehicle"]["instant_brake"];
this->vehicle.is_targetable = j["vehicle"]["is_targetable"];
this->vehicle.pv_teleport_into = j["vehicle"]["pv_teleport_into"];
this->vehicle.rainbow_paint = j["vehicle"]["rainbow_paint"];
@ -631,6 +633,7 @@ namespace big
{ "drive_on_water", this->vehicle.drive_on_water },
{ "god_mode", this->vehicle.god_mode },
{ "horn_boost", this->vehicle.horn_boost },
{ "instant_brake", this->vehicle.instant_brake },
{ "is_targetable", this->vehicle.is_targetable },
{ "pv_teleport_into", this->vehicle.pv_teleport_into },
{ "rainbow_paint", this->vehicle.rainbow_paint },

View File

@ -51,13 +51,12 @@ namespace big
auto location = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(PLAYER::PLAYER_PED_ID(), 2.5f, 2.5f, .5f);
if (m_current_veh == -1)
{
m_new_model = false;
location.z = -10.f;
m_current_veh = vehicle::spawn(m_model, location, 0.f, false);
ENTITY::FREEZE_ENTITY_POSITION(m_current_veh, true);
ENTITY::SET_ENTITY_ALPHA(m_current_veh, 0, 0);
ENTITY::SET_ENTITY_COLLISION(m_current_veh, false, false);
m_new_model = false;
}
else if (m_new_model)
{
@ -117,4 +116,4 @@ namespace big
LOG(WARNING) << "Failed to load vehicles.json:\n" << ex.what();
}
}
}
}

View File

@ -3,6 +3,7 @@
#include "natives.hpp"
#include "script_global.hpp"
#include "system.hpp"
#include "entity.hpp"
namespace big::toxic
{
@ -65,6 +66,25 @@ namespace big::toxic
TASK::CLEAR_PED_TASKS_IMMEDIATELY(target);
}
inline void flying_vehicle(const Player player)
{
Entity ent = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(player);
if (!PED::IS_PED_IN_ANY_VEHICLE(ent, true))
g_notification_service->push_warning("Toxic", "Target player is not in a vehicle.");
else {
ent = PED::GET_VEHICLE_PED_IS_IN(ent, false);
Vector3 location = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true);
if (entity::take_control_of(ent))
ENTITY::APPLY_FORCE_TO_ENTITY(ent, 1, 0.f, 0.f, 50000.f, 0.f, 0.f, 0.f, 0, 0, 1, 1, 0, 1);
else
g_notification_service->push_warning("Toxic", "Failed to take control of player vehicle.");
}
}
inline void clear_wanted_player(Player target)
{

View File

@ -125,7 +125,11 @@ namespace big
components::button("Kick From Vehicle", [] {
toxic::kick_from_vehicle(g_player_service->get_selected()->id());
});
components::button("Flying Vehicle", [] {
toxic::flying_vehicle(g_player_service->get_selected()->id());
});
}
}
}
}
}

View File

@ -11,6 +11,7 @@ namespace big
ImGui::Checkbox("Can Be Targeted", &g->vehicle.is_targetable);
ImGui::Checkbox("God Mode", &g->vehicle.god_mode);
ImGui::Checkbox("Horn Boost", &g->vehicle.horn_boost);
ImGui::Checkbox("Instant Brake", &g->vehicle.instant_brake);
ImGui::Checkbox("Drive On Water", &g->vehicle.drive_on_water);
ImGui::EndGroup();