-
Notifications
You must be signed in to change notification settings - Fork 48
Fast Train & Object Spawner #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 9 commits
fe40492
8682be1
e26b33c
ec326e2
bd70bed
43c52f2
ac941bf
b934627
be54436
45a34e5
debbe39
c673ee8
cea3546
a86d3f2
6ba1f45
4bff7df
790d105
cf88782
290508b
4efeceb
4b6e85e
72153c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "core/commands/LoopedCommand.hpp" | ||
#include "core/frontend/Notifications.hpp" | ||
#include "game/features/Features.hpp" | ||
#include "game/rdr/Enums.hpp" | ||
#include "game/rdr/Natives.hpp" | ||
#include "game/backend/Self.hpp" | ||
|
||
namespace YimMenu::Features | ||
{ | ||
class FastTrain : public LoopedCommand | ||
{ | ||
using LoopedCommand::LoopedCommand; | ||
|
||
virtual void OnTick() override | ||
{ | ||
Vehicle vehicle = PED::GET_VEHICLE_PED_IS_USING(Self::GetPed().GetHandle()); | ||
Deadlineem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Hash vehicleModelHash = ENTITY::GET_ENTITY_MODEL(vehicle); | ||
|
||
if (VEHICLE::IS_THIS_MODEL_A_TRAIN(vehicleModelHash)) | ||
{ | ||
VEHICLE::SET_TRAIN_SPEED(vehicle, 1000.0); | ||
VEHICLE::SET_TRAIN_CRUISE_SPEED(vehicle, 1000.0); | ||
VEHICLE::_SET_TRAIN_MAX_SPEED(vehicle, 1000.0); | ||
} | ||
} | ||
|
||
virtual void OnDisable() override | ||
{ | ||
Vehicle vehicle = PED::GET_VEHICLE_PED_IS_USING(Self::GetPed().GetHandle()); | ||
Deadlineem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Hash vehicleModelHash = ENTITY::GET_ENTITY_MODEL(vehicle); | ||
|
||
if (VEHICLE::IS_THIS_MODEL_A_TRAIN(vehicleModelHash)) | ||
{ | ||
VEHICLE::SET_TRAIN_SPEED(vehicle, 0.0); | ||
VEHICLE::SET_TRAIN_CRUISE_SPEED(vehicle, 0.0); | ||
VEHICLE::_SET_TRAIN_MAX_SPEED(vehicle, 0.0); | ||
} | ||
} | ||
}; | ||
|
||
static FastTrain _FastTrain{"fasttrain", "Fast Train", "Makes the train much faster than normal. Instantly stops it when disabled."}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
#include "core/commands/Command.hpp" | ||
#include "game/backend/FiberPool.hpp" | ||
#include "game/backend/NativeHooks.hpp" | ||
#include "game/backend/ScriptMgr.hpp" | ||
#include "game/backend/Self.hpp" | ||
#include "game/frontend/items/Items.hpp" | ||
#include "game/rdr/Natives.hpp" | ||
#include "game/rdr/data/ObjModels.hpp" | ||
#include "ObjectSpawner.hpp" | ||
#include "util/SpawnObject.hpp" | ||
|
||
namespace YimMenu::Submenus | ||
{ | ||
static bool IsObjectModelInList(const std::string& model) | ||
{ | ||
for (const auto& objModel : YimMenu::Data::g_ObjModels) | ||
{ | ||
if (objModel.model == model) | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
static int ObjectSpawnerInputCallback(ImGuiInputTextCallbackData* data) | ||
{ | ||
if (data->EventFlag == ImGuiInputTextFlags_CallbackCompletion) | ||
{ | ||
std::string newText; | ||
std::string inputLower = data->Buf; | ||
std::transform(inputLower.begin(), inputLower.end(), inputLower.begin(), ::tolower); | ||
|
||
for (const auto& objModel : YimMenu::Data::g_ObjModels) | ||
{ | ||
std::string modelLower = objModel.model; | ||
std::transform(modelLower.begin(), modelLower.end(), modelLower.begin(), ::tolower); | ||
if (modelLower.find(inputLower) != std::string::npos) | ||
{ | ||
newText = objModel.model; | ||
break; | ||
} | ||
} | ||
|
||
if (!newText.empty()) | ||
{ | ||
data->DeleteChars(0, data->BufTextLen); | ||
data->InsertChars(0, newText.c_str()); | ||
} | ||
|
||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
||
void RenderObjectSpawnerMenu() | ||
{ | ||
static std::string objectModelBuffer; | ||
static float positionOffsetX = 5.0f; | ||
static float positionOffsetY = 5.0f; | ||
static float positionOffsetZ = 0.0f; | ||
static float pitch = 0.0f; | ||
static float yaw = 0.0f; | ||
static float roll = 0.0f; | ||
static float alpha = 125.0f; | ||
static bool onGround = false; | ||
static bool isFrozen = false; | ||
static bool isBurning = false; | ||
static bool isPickup = false; | ||
static bool showPreview = false; | ||
static bool hasCollision = false; | ||
static int modelHash = 0; | ||
|
||
Vector3 playerCoords = ENTITY::GET_ENTITY_COORDS(Self::GetPed().GetHandle(), true, true); | ||
Deadlineem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Vector3 forwardVector = ENTITY::GET_ENTITY_FORWARD_VECTOR(Self::GetPed().GetHandle()); | ||
|
||
Vector3 spawnPosition; | ||
spawnPosition.x = playerCoords.x + forwardVector.x * positionOffsetX; | ||
spawnPosition.y = playerCoords.y + forwardVector.y * positionOffsetY; | ||
spawnPosition.z = playerCoords.z + positionOffsetZ; | ||
|
||
char buffer[256]; | ||
strncpy(buffer, objectModelBuffer.c_str(), sizeof(buffer)); | ||
|
||
ImGui::InputTextWithHint("##objectmodel", "Object Model", buffer, sizeof(buffer), ImGuiInputTextFlags_CallbackCompletion, ObjectSpawnerInputCallback); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could use the frontend item There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity Code Description Project File Line Suppression State Details InputTextWithHint("##objectmodel", "Object Model", &buffer, ImGuiInputTextFlags_CallbackCompletion, nullptr, ObjectSpawnerInputCallback) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Buffer has to be a string, not a char. |
||
|
||
objectModelBuffer = buffer; | ||
|
||
if (ImGui::IsItemHovered()) | ||
ImGui::SetTooltip("Press Tab to auto-fill"); | ||
|
||
if (!objectModelBuffer.empty() && !IsObjectModelInList(objectModelBuffer)) | ||
{ | ||
ImGui::BeginListBox("##objectmodels", ImVec2(250, 100)); | ||
|
||
std::string bufferLower = objectModelBuffer; | ||
std::transform(bufferLower.begin(), bufferLower.end(), bufferLower.begin(), ::tolower); | ||
for (const auto& objModel : YimMenu::Data::g_ObjModels) | ||
{ | ||
std::string objModelLower = objModel.model; | ||
std::transform(objModelLower.begin(), objModelLower.end(), objModelLower.begin(), ::tolower); | ||
if (objModelLower.find(bufferLower) != std::string::npos && ImGui::Selectable(objModel.model.c_str())) | ||
{ | ||
objectModelBuffer = objModel.model; | ||
modelHash = Joaat(objectModelBuffer.c_str()); | ||
STREAMING::REQUEST_MODEL(modelHash, false); | ||
while (!STREAMING::HAS_MODEL_LOADED(modelHash)) | ||
{ | ||
return; | ||
} | ||
} | ||
} | ||
|
||
ImGui::EndListBox(); | ||
} | ||
|
||
ImGui::SliderFloat("Offset X", &positionOffsetX, -25.0f, 25.0f); | ||
ImGui::SliderFloat("Offset Y", &positionOffsetY, -25.0f, 25.0f); | ||
ImGui::SliderFloat("Offset Z", &positionOffsetZ, -10.0f, 10.0f); | ||
ImGui::SliderFloat("Pitch", &pitch, -180.0f, 180.0f); | ||
ImGui::SliderFloat("Yaw", &yaw, -180.0f, 180.0f); | ||
ImGui::SliderFloat("Roll", &roll, -180.0f, 180.0f); | ||
ImGui::SliderFloat("Transparency", &alpha, 0.0f, 255.0f); | ||
|
||
ImGui::Checkbox("Place on Ground", &onGround); | ||
ImGui::SameLine(); | ||
ImGui::Checkbox("Freeze Position", &isFrozen); | ||
ImGui::SameLine(); | ||
ImGui::Checkbox("Set on Fire", &isBurning); | ||
ImGui::SameLine(); | ||
ImGui::Checkbox("Set as Pickup", &isPickup); | ||
|
||
ImGui::Checkbox("Set Collision", &hasCollision); | ||
ImGui::SameLine(); | ||
ImGui::Checkbox("Show Preview", &showPreview); | ||
|
||
if (ImGui::Button("Spawn Object")) | ||
{ | ||
int modelHash = Joaat(objectModelBuffer.c_str()); | ||
SpawnObject(modelHash, spawnPosition, pitch, yaw, roll, onGround, isFrozen, isBurning, isPickup, hasCollision); | ||
} | ||
ImGui::SameLine(); | ||
if (ImGui::Button("Reset Sliders")) | ||
{ | ||
positionOffsetX = 5.0f; | ||
positionOffsetY = 5.0f; | ||
positionOffsetZ = 0.0f; | ||
pitch = 0.0f; | ||
yaw = 0.0f; | ||
roll = 0.0f; | ||
alpha = 125.0f; | ||
} | ||
|
||
if (showPreview == true) | ||
Deadlineem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
int modelHash = Joaat(objectModelBuffer.c_str()); | ||
PreviewObject(modelHash, spawnPosition, pitch, yaw, roll, alpha, showPreview); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
|
||
namespace YimMenu::Submenus | ||
{ | ||
void RenderObjectSpawnerMenu(); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.