Added seat changer feature. (#346)

This commit is contained in:
aa15032261 2022-07-17 04:37:44 +08:00 committed by GitHub
parent c554e49932
commit 76a049b62b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,78 @@ namespace big
{
void view::vehicle_fun()
{
static std::map<int, bool> seats;
static bool ready = true;
if (self::veh == 0)
{
seats.clear();
}
if (self::veh != 0 && ready == true)
{
ready = false;
g_fiber_pool->queue_job([] {
std::map<int, bool> tmp_seats;
Hash model = ENTITY::GET_ENTITY_MODEL(self::veh);
int num_of_seats = VEHICLE::GET_VEHICLE_MODEL_NUMBER_OF_SEATS(model);
for (int i = -1; i < num_of_seats - 1; i++)
{
tmp_seats[i] = VEHICLE::IS_VEHICLE_SEAT_FREE(self::veh, i, true);
}
seats = tmp_seats;
ready = true;
});
}
components::small_text("Seat Changer");
if (seats.size() == 0)
{
ImGui::Text("Please enter a vehicle.");
}
else
{
for (auto& it : seats)
{
int idx = it.first;
if (!it.second)
{
ImGui::BeginDisabled();
}
std::string name = "Driver";
if (idx >= 0)
{
name = "Seat " + std::to_string(idx + 1);
}
if ((idx + 1) % 4 != 0) {
ImGui::SameLine();
}
components::button(name, [idx] {
PED::SET_PED_INTO_VEHICLE(self::ped, self::veh, idx);
});
if (!it.second)
{
ImGui::EndDisabled();
}
}
}
ImGui::Separator();
components::small_text("Auto Drive");
components::button("Drive To Waypoint", [] {