TmpMenu/src/backend/looped/vehicle/ls_customs.cpp
maybegreat48 64197f938a Update to 1.64 (#691)
* Update some globals
* fix(pointers): bypass C4 limit
* fix(pointers): CanApplyData signature
* feat(hooks): removed metric formatter
The function in question no longer exists along with the other metric functions.

* chore(metadata): bumped online and build number
* fix(pointers): updated Rage Security signature
* Updated some globals and locals. Part 1
* Update crossmap
* chore(Script): update script patches
* chore(nativeHooks): Update rage::scrProgram vtable size
* chore(nativeHooks): Fix rage::scrProgram destructor index
* fix(Sigscanner): Temporarily disable AC bypass
* chore(Hooks): disable can_apply_data
* Updated some globals and locals. Part 2
* chore(globals): Update transition state global
* chore(ScriptLauncher): Update local index
* feat(Toxic): Add new teleport locations
* fix(Protections): Update max interior index

Co-authored-by: Yimura <24669514+Yimura@users.noreply.github.com>
Co-authored-by: Bugisoft <58910128+BugisoftRSG@users.noreply.github.com>
Co-authored-by: BugisoftRSG <metaclientauth@gmail.com>
2022-12-14 16:27:40 +00:00

72 lines
2.0 KiB
C++

#include "backend/looped/looped.hpp"
#include "gta_util.hpp"
#include "script_local.hpp"
#include "util/math.hpp"
#include "util/scripts.hpp"
namespace big
{
static bool state = false;
static bool busy = false;
constexpr auto CARMOD_SHOP_STRUCT = 730; // move_m@generic_idles@std -- one function below -- first local
constexpr auto CARMOD_SHOP_CUTSCENE = 2208; // "carmod_fam1" -- first boolean local below it
void looped::vehicle_ls_customs()
{
if (busy) return;
busy = true;
constexpr int hash = RAGE_JOAAT("carmod_shop");
if (g->vehicle.ls_customs && g->vehicle.ls_customs == state)
{
if (
auto carmod_shop_thread = gta_util::find_script_thread(hash);
carmod_shop_thread &&
*script_local(carmod_shop_thread, CARMOD_SHOP_STRUCT).at(11).as<int*>() != 4
)
{
g->vehicle.ls_customs = false;
*script_local(carmod_shop_thread, CARMOD_SHOP_STRUCT).as<int*>() = 1; // cleanup
}
}
if (g->vehicle.ls_customs && g->vehicle.ls_customs != state)
{
Vehicle veh = self::veh;
if (!ENTITY::DOES_ENTITY_EXIST(veh) || ENTITY::IS_ENTITY_DEAD(veh, false))
{
busy = false;
g->vehicle.ls_customs = false;
g_notification_service->push_warning("LS Customs", "You aren't in a vehicle.");
return;
}
scripts::request_script(hash);
if (scripts::wait_till_loaded(hash))
{
int args[] = { 45, 0, 9 };
scripts::start_script_with_args(hash, args, 3, 3600);
scripts::wait_till_running(hash);
}
if (scripts::is_running(hash))
{
if (auto carmod_shop_thread = gta_util::find_script_thread(hash); carmod_shop_thread)
{
*script_local(carmod_shop_thread, CARMOD_SHOP_STRUCT).at(409).as<int*>() = veh; // "HIDDEN_RADIO_09_HIPHOP_OLD"
*script_local(carmod_shop_thread, CARMOD_SHOP_CUTSCENE).as<bool*>() = false; // skips cutscene that's invisible
*script_local(carmod_shop_thread, CARMOD_SHOP_STRUCT).at(11).as<int*>() = 4;
}
}
}
busy = false;
state = g->vehicle.ls_customs;
}
}