generated from YimMenu/YimMenuV2
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Fast Train & Object Spawner #171
Open
Deadlineem
wants to merge
22
commits into
YimMenu:master
Choose a base branch
from
Deadlineem:Train-&-Object-Spawner
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
fe40492
updated obj spawner & train
Deadlineem 8682be1
Fixed some missing things that for some reason did not get pushed.
Deadlineem e26b33c
added stuff to World.cpp for frontend GUI
Deadlineem ec326e2
Removed Tooltips (broken)
Deadlineem bd70bed
Removed LIGHT_INTENSITY from train, was testing to see if i can make …
Deadlineem 43c52f2
Merge branch 'master' into Train-&-Object-Spawner
Rxann ac941bf
Added Fast Train toggle to vehicles
Deadlineem b934627
Added Train Toggle
Deadlineem be54436
Fixed the SpawnObject function, missing an arguement for hasCollision
Deadlineem 45a34e5
Update CagePlayerLarge.cpp
Deadlineem debbe39
Fixed requested changes
Deadlineem c673ee8
Fixed requested changes
Deadlineem cea3546
fixed CagePlayerLarge, idk why it keeps reverting lol
Deadlineem a86d3f2
altered fast train
Deadlineem 6ba1f45
Added Tooltips
Deadlineem 4bff7df
Fixed showPreview
Deadlineem 790d105
used Self::GetPed().GetPosition()
Deadlineem cf88782
Removed some if statements
Deadlineem 290508b
added if statement
Deadlineem 4efeceb
Merge branch 'master' into Train-&-Object-Spawner
Rxann 4b6e85e
indents
Deadlineem 72153c4
Merge branch 'Train-&-Object-Spawner' of https://github.com/Deadlinee…
Deadlineem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#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 | ||
{ | ||
auto vehicle = Self::GetVehicle(); | ||
if (vehicle) | ||
{ | ||
Hash vehicleModelHash = ENTITY::GET_ENTITY_MODEL(vehicle.GetHandle()); | ||
|
||
if (VEHICLE::IS_THIS_MODEL_A_TRAIN(vehicleModelHash)) | ||
{ | ||
VEHICLE::SET_TRAIN_SPEED(vehicle.GetHandle(), 1000.0); | ||
VEHICLE::SET_TRAIN_CRUISE_SPEED(vehicle.GetHandle(), 1000.0); | ||
VEHICLE::_SET_TRAIN_MAX_SPEED(vehicle.GetHandle(), 1000.0); | ||
} | ||
} | ||
} | ||
|
||
virtual void OnDisable() override | ||
{ | ||
auto vehicle = Self::GetVehicle(); | ||
if (vehicle) | ||
{ | ||
Hash vehicleModelHash = ENTITY::GET_ENTITY_MODEL(vehicle.GetHandle()); | ||
|
||
if (VEHICLE::IS_THIS_MODEL_A_TRAIN(vehicleModelHash)) | ||
{ | ||
VEHICLE::SET_TRAIN_SPEED(vehicle.GetHandle(), 0.0); | ||
VEHICLE::SET_TRAIN_CRUISE_SPEED(vehicle.GetHandle(), 0.0); | ||
VEHICLE::_SET_TRAIN_MAX_SPEED(vehicle.GetHandle(), 0.0); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
static FastTrain _FastTrain{"fasttrain", "Fast Train", "Makes the train much faster than normal. Instantly stops it when disabled."}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
#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 = Self::GetPed().GetPosition(); | ||
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); | ||
|
||
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::Separator(); | ||
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::Separator(); | ||
ImGui::SliderFloat("Transparency", &alpha, 0.0f, 255.0f); | ||
|
||
ImGui::Checkbox("Place on Ground", &onGround); | ||
if (ImGui::IsItemHovered()) | ||
ImGui::SetTooltip("Places the object properly on the ground when spawned."); | ||
ImGui::SameLine(); | ||
ImGui::Checkbox("Freeze Position", &isFrozen); | ||
if (ImGui::IsItemHovered()) | ||
ImGui::SetTooltip("Locks the object in place when spawned, preventing it from being moved."); | ||
ImGui::SameLine(); | ||
ImGui::Checkbox("Set on Fire", &isBurning); | ||
if (ImGui::IsItemHovered()) | ||
ImGui::SetTooltip("Sets things on fire near the object when spawned."); | ||
ImGui::SameLine(); | ||
ImGui::Checkbox("Set as Pickup", &isPickup); | ||
if (ImGui::IsItemHovered()) | ||
ImGui::SetTooltip("Sets the object as a pickup (if applicable) for spawning lootable items."); | ||
|
||
ImGui::Checkbox("Set Collision", &hasCollision); | ||
if (ImGui::IsItemHovered()) | ||
ImGui::SetTooltip("Sets the collision of the object making it so you cannot pass through it."); | ||
ImGui::SameLine(); | ||
ImGui::Checkbox("Show Preview", &showPreview); | ||
if (ImGui::IsItemHovered()) | ||
ImGui::SetTooltip("Shows a preview of the object in front of you."); | ||
|
||
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) | ||
{ | ||
int modelHash = Joaat(objectModelBuffer.c_str()); | ||
PreviewObject(modelHash, spawnPosition, pitch, yaw, roll, alpha, showPreview); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
|
||
namespace YimMenu::Submenus | ||
{ | ||
void RenderObjectSpawnerMenu(); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use the frontend item
InputTextWithHint
. Make sure to call.Draw()
if you choose to go this route, you probably should though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Severity Code Description Project File Line Suppression State Details
Error C2440 '': cannot convert from 'initializer list' to 'YimMenu::InputTextWithHint'
InputTextWithHint("##objectmodel", "Object Model", &buffer, ImGuiInputTextFlags_CallbackCompletion, nullptr, ObjectSpawnerInputCallback)
.Draw();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buffer has to be a string, not a char.