2022-12-22 21:23:32 +00:00
|
|
|
#include "backend/bool_command.hpp"
|
2023-03-01 21:27:15 +00:00
|
|
|
#include "backend/command.hpp"
|
2022-12-22 21:23:32 +00:00
|
|
|
#include "natives.hpp"
|
|
|
|
#include "pointers.hpp"
|
|
|
|
#include "util/vehicle.hpp"
|
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
2023-05-10 17:11:59 -04:00
|
|
|
class spawn_vehicle : command
|
|
|
|
{
|
|
|
|
using command::command;
|
|
|
|
|
2023-07-20 22:46:32 +02:00
|
|
|
virtual std::optional<std::vector<uint64_t>> parse_args(const std::vector<std::string>& args, const std::shared_ptr<command_context> ctx)
|
2023-05-10 17:11:59 -04:00
|
|
|
{
|
|
|
|
auto hash = rage::joaat(args[0]);
|
2023-07-20 22:46:32 +02:00
|
|
|
return std::vector<uint64_t>{hash};
|
2023-05-10 17:11:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual CommandAccessLevel get_access_level()
|
|
|
|
{
|
|
|
|
return CommandAccessLevel::FRIENDLY;
|
|
|
|
}
|
|
|
|
|
2023-07-20 22:46:32 +02:00
|
|
|
virtual void execute(const std::vector<uint64_t>& args, const std::shared_ptr<command_context> ctx)
|
2023-05-10 17:11:59 -04:00
|
|
|
{
|
|
|
|
if (!STREAMING::IS_MODEL_IN_CDIMAGE(args[0]) || !STREAMING::IS_MODEL_A_VEHICLE(args[0]))
|
|
|
|
{
|
|
|
|
ctx->report_error("Specified model is invalid");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto spawn_location =
|
|
|
|
vehicle::get_spawn_location(ctx->get_sender()->id() == self::id ? g.spawn_vehicle.spawn_inside : false,
|
|
|
|
args[0],
|
|
|
|
PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(ctx->get_sender()->id()));
|
|
|
|
const auto spawn_heading = ENTITY::GET_ENTITY_HEADING(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(ctx->get_sender()->id()));
|
|
|
|
|
|
|
|
const auto veh = vehicle::spawn(args[0], spawn_location, spawn_heading);
|
|
|
|
|
|
|
|
if (veh == 0)
|
|
|
|
{
|
|
|
|
g_notification_service->push_error("Vehicle", "Unable to spawn vehicle");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (g.spawn_vehicle.spawn_maxed)
|
|
|
|
{
|
|
|
|
vehicle::max_vehicle(veh);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g.spawn_vehicle.spawn_inside && ctx->get_sender()->id() == self::id)
|
|
|
|
{
|
|
|
|
vehicle::teleport_into_vehicle(veh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
spawn_vehicle g_spawn_vehicle("spawn", "Spawn Vehicle", "Spawn a vehicle with the specified model", 1);
|
|
|
|
bool_command g_spawn_maxed("spawnmaxed", "Spawn Maxed", "Controls whether the vehicle spawned will have its mods maxed out",
|
|
|
|
g.spawn_vehicle.spawn_maxed);
|
|
|
|
bool_command g_spawn_inside("spawnin", "Spawn Inside", "Controls whether the player should be set inside the vehicle after it spawns",
|
|
|
|
g.spawn_vehicle.spawn_inside);
|
|
|
|
}
|