feat(self & vehicle): Added mobile radio and turning off engine. (#572)

This commit is contained in:
SpaghettDev 2022-11-11 11:51:40 -06:00 committed by GitHub
parent 9f55d0fda9
commit d0972f65d4
7 changed files with 69 additions and 0 deletions

View File

@ -36,6 +36,7 @@ namespace big
looped::self_hud();
looped::self_unlimited_oxygen();
looped::self_no_water_collision();
looped::self_mobile_radio();
script::get_current()->yield();
}

View File

@ -36,6 +36,7 @@ namespace big
static void self_hud();
static void self_unlimited_oxygen();
static void self_no_water_collision();
static void self_mobile_radio();
static void session_local_time();

View File

@ -0,0 +1,25 @@
#include "backend/looped/looped.hpp"
#include "natives.hpp"
namespace big
{
static bool bLastMobileRadio = false;
void looped::self_mobile_radio()
{
const bool bMobileRadio = g->self.mobile_radio;
if (bMobileRadio)
{
AUDIO::SET_MOBILE_PHONE_RADIO_STATE(true);
AUDIO::SET_MOBILE_RADIO_ENABLED_DURING_GAMEPLAY(true);
}
else if (bMobileRadio != bLastMobileRadio)
{
AUDIO::SET_MOBILE_PHONE_RADIO_STATE(false);
AUDIO::SET_MOBILE_RADIO_ENABLED_DURING_GAMEPLAY(false);
}
bLastMobileRadio = bMobileRadio;
}
}

View File

@ -169,6 +169,7 @@ namespace big
bool hide_ammo = false;
int selected_hud_component = 1;
bool hud_components_states[(int)HudComponents::HUD_WEAPONS] = { false };
bool mobile_radio = false;
};
struct session
@ -300,6 +301,8 @@ namespace big
bool vehicle_jump = false;
bool keep_vehicle_repaired = false;
bool no_water_collision = false;
bool disable_engine_auto_start = false;
bool change_engine_state_immediately = false;
speedo_meter speedo_meter{};
rainbow_paint rainbow_paint{};
fly fly{};
@ -576,6 +579,7 @@ namespace big
this->self.hud_components_states[i] = j["self"]["hud_components_states"].at(i);
this->self.unlimited_oxygen = j["self"]["unlimited_oxygen"];
this->self.no_water_collision = j["self"]["no_water_collision"];
this->self.mobile_radio = j["self"]["mobile_radio"];
this->session.log_chat_messages = j["session"]["log_chat_messages"];
this->session.log_text_messages = j["session"]["log_text_messages"];
@ -636,6 +640,8 @@ namespace big
this->vehicle.seatbelt = j["vehicle"]["seatbelt"];
this->vehicle.turn_signals = j["vehicle"]["turn_signals"];
this->vehicle.no_water_collision = j["vehicle"]["no_water_collision"];
this->vehicle.disable_engine_auto_start = j["vehicle"]["disable_engine_auto_start"];
this->vehicle.change_engine_state_immediately = j["vehicle"]["change_engine_state_immediately"];
this->vehicle.speedo_meter.enabled = j["vehicle"]["speedo_meter"]["enabled"];
this->vehicle.speedo_meter.left_side = j["vehicle"]["speedo_meter"]["left_side"];
@ -876,6 +882,7 @@ namespace big
},
{ "unlimited_oxygen", this->self.unlimited_oxygen },
{ "no_water_collision", this->self.no_water_collision },
{ "mobile_radio", this->self.mobile_radio },
}
},
{
@ -963,6 +970,8 @@ namespace big
{ "turn_signals", this->vehicle.turn_signals },
{ "seatbelt", this->vehicle.seatbelt },
{ "no_water_collision", this->vehicle.no_water_collision },
{ "disable_engine_auto_start", this->vehicle.disable_engine_auto_start },
{ "change_engine_state_immediately", this->vehicle.change_engine_state_immediately },
{
"speedo_meter",
{

View File

@ -658,4 +658,12 @@ namespace big::vehicle
}
}
}
inline void set_engine_state(Vehicle current_vehicle, bool state, bool immediately, bool disable_auto_start)
{
if (current_vehicle)
VEHICLE::SET_VEHICLE_ENGINE_ON(current_vehicle, state, immediately, disable_auto_start);
else
return g_notification_service->push_warning("Vehicle", "Please be in a car first then try again.");
}
}

View File

@ -80,6 +80,8 @@ namespace big
ImGui::Checkbox("No Collision", &g->self.no_collision);
ImGui::Checkbox("Mobile Radio", &g->self.mobile_radio);
ImGui::EndGroup();
ImGui::Separator();

View File

@ -41,6 +41,29 @@ namespace big
ImGui::Separator();
components::button("Turn Engine On", [] {
vehicle::set_engine_state(
self::veh,
true,
g->vehicle.change_engine_state_immediately,
g->vehicle.disable_engine_auto_start
);
});
ImGui::SameLine();
components::button("Turn Engine Off", [] {
vehicle::set_engine_state(
self::veh,
false,
g->vehicle.change_engine_state_immediately,
g->vehicle.disable_engine_auto_start
);
});
ImGui::Checkbox("Disable Engine Auto Start", &g->vehicle.disable_engine_auto_start);
ImGui::SameLine();
ImGui::Checkbox("Change State Immediately", &g->vehicle.change_engine_state_immediately);
ImGui::Separator();
components::sub_title("General");
{
ImGui::BeginGroup();