Skip to content

Commit

Permalink
Added invis & otr (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
DayibBaba authored Oct 22, 2023
1 parent e864592 commit e5bd3bf
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 31 deletions.
19 changes: 10 additions & 9 deletions src/game/features/Features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,25 @@ namespace YimMenu

void SpectateTick()
{
if(g_SpectateId != Players::GetSelected().GetId() && g_Spectating)
if (g_SpectateId != Players::GetSelected().GetId() && g_Spectating)
{
g_SpectateId = Players::GetSelected().GetId();
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(Players::GetSelected().GetId()));
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, Players::GetSelected().GetPed().GetHandle());
}

if(g_Spectating)
if (g_Spectating)
{
if(!NETWORK::NETWORK_IS_IN_SPECTATOR_MODE())
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(Players::GetSelected().GetId()));
if (!NETWORK::NETWORK_IS_IN_SPECTATOR_MODE())
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, Players::GetSelected().GetPed().GetHandle()),
STREAMING::SET_FOCUS_ENTITY(Players::GetSelected().GetPed().GetHandle());

if(!Players::GetSelected().IsValid() || !NETWORK::NETWORK_IS_PLAYER_CONNECTED(Players::GetSelected().GetId()))
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(Players::GetSelected().GetId())), g_Spectating = false, Notifications::Show("Spectate", "Player is no longer in the session.\nSpectate mode disabled.", NotificationType::Warning);
if (!Players::GetSelected().IsValid() || !NETWORK::NETWORK_IS_PLAYER_CONNECTED(Players::GetSelected().GetId()))
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, 0), g_Spectating = false, Notifications::Show("Spectate", "Player is no longer in the session.\nSpectate mode disabled.", NotificationType::Warning);
}
else
{
if(NETWORK::NETWORK_IS_IN_SPECTATOR_MODE())
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(Players::GetSelected().GetId()));
if (NETWORK::NETWORK_IS_IN_SPECTATOR_MODE())
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, 0);
}
}

Expand Down
27 changes: 27 additions & 0 deletions src/game/features/self/Invis.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "core/commands/LoopedCommand.hpp"
#include "game/features/Features.hpp"
#include "game/rdr/Enums.hpp"
#include "game/rdr/Natives.hpp"

namespace YimMenu::Features
{
//TODO: OnDisable doesn't call if menu is unloaded prematurely
class Invis : public LoopedCommand
{
using LoopedCommand::LoopedCommand;

virtual void OnTick() override
{
ENTITY::SET_ENTITY_VISIBLE(Self::PlayerPed, false);
NETWORK::SET_PLAYER_VISIBLE_LOCALLY(Self::Id, true);
}

virtual void OnDisable() override
{
ENTITY::SET_ENTITY_VISIBLE(Self::PlayerPed, true);
NETWORK::SET_PLAYER_VISIBLE_LOCALLY(Self::Id, true);
}
};

static Invis _Invis{"invis", "Invisibility", "Be invisible"};
}
35 changes: 35 additions & 0 deletions src/game/features/self/OffTheRadar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "core/commands/LoopedCommand.hpp"
#include "game/features/Features.hpp"
#include "game/rdr/Enums.hpp"
#include "game/rdr/Natives.hpp"
#include "game/rdr/ScriptGlobal.hpp"

namespace YimMenu::Features
{
class OffTheRadar : public LoopedCommand
{
using LoopedCommand::LoopedCommand;

virtual void OnTick() override
{
if (*Pointers.IsSessionStarted)
{
auto offtheradar = ScriptGlobal(1102813).At(3).As<int*>();
if (offtheradar)
*offtheradar = 32;
}
}

virtual void OnDisable() override
{
if (*Pointers.IsSessionStarted)
{
auto offtheradar = ScriptGlobal(1102813).At(3).As<int*>();
if (offtheradar)
*offtheradar = 0;
}
}
};

static OffTheRadar _OffTheRadar{"offtheradar", "Off The Radar", "You won't show up on the maps of other players"};
}
44 changes: 25 additions & 19 deletions src/game/frontend/submenus/Players.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace YimMenu::Submenus
{
bool popPlayerList = true; //TODO make optional
void drawPlayerList(bool external, float offset = 15.0f)
void drawPlayerList(bool external, float offset = 25.0f)
{
struct ComparePlayerNames
{
Expand All @@ -33,6 +33,8 @@ namespace YimMenu::Submenus
ImVec2(ImGui::GetWindowPos().x + ImGui::GetWindowSize().x + offset, ImGui::GetWindowPos().y));
ImGui::SetNextWindowSize(ImVec2(150, ImGui::GetWindowSize().y));
ImGui::Begin("Player List", nullptr, ImGuiWindowFlags_NoDecoration);

ImGui::Checkbox("Spectate", &YimMenu::g_Spectating);
for (auto& [id, player] : sortedPlayers)
{
if (ImGui::Selectable(player.GetName(), (YimMenu::Players::GetSelected() == player)))
Expand Down Expand Up @@ -61,14 +63,12 @@ namespace YimMenu::Submenus
auto main = std::make_shared<Category>("Main");
auto column = std::make_shared<Column>(2);

auto playersListGroup = std::make_shared<Group>("Players");
auto playerOptionsGroup = std::make_shared<Group>("Info", ImVec2(0, 250));

playersListGroup->AddItem(std::make_shared<ImGuiItem>([] {
drawPlayerList(false);
main->AddItem(std::make_shared<ImGuiItem>([] {
drawPlayerList(true);
}));

auto playerOptionsGroup = std::make_shared<Group>("Info");

playerOptionsGroup->AddItem(std::make_shared<ImGuiItem>([] {
ImGui::Text(YimMenu::Players::GetSelected().GetName());
ImGui::Separator();
Expand All @@ -84,13 +84,22 @@ namespace YimMenu::Submenus

});
}
if (ImGui::Button("Teleport Behind"))
{
FiberPool::Push([] {
auto playerCoords = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(
PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(YimMenu::Players::GetSelected().GetId()),
0,
-10,
0);
if (Teleport::TeleportEntity(Self::PlayerPed, playerCoords))
g_Spectating = false;
});
}
}));

column->AddColumnOffset(1, 160);
column->AddItem(playersListGroup);
column->AddNextColumn();
column->AddItem(playerOptionsGroup);

main->AddItem(column);
AddCategory(std::move(main));
}
Expand All @@ -102,25 +111,19 @@ namespace YimMenu::Submenus
drawPlayerList(popPlayerList);
}));

helpful->AddItem(std::make_shared<ImGuiItem>([] {
ImGui::Text(YimMenu::Players::GetSelected().GetName());
}));

AddCategory(std::move(helpful));
}

{
auto toxic = std::make_shared<Category>("Toxic");
auto toxic = std::make_shared<Category>("Toxic");
auto columns = std::make_shared<Column>(2);
auto miscGroup = std::make_shared<Group>("Misc", ImVec2(0, 250));

toxic->AddItem(std::make_shared<ImGuiItem>([] {
drawPlayerList(popPlayerList);
}));

toxic->AddItem(std::make_shared<ImGuiItem>([] {
ImGui::Text(YimMenu::Players::GetSelected().GetName());
}));

toxic->AddItem(std::make_shared<ImGuiItem>([] {
miscGroup->AddItem(std::make_shared<ImGuiItem>([] {
if (ImGui::Button("Explode"))
{
FiberPool::Push([] {
Expand All @@ -134,6 +137,9 @@ namespace YimMenu::Submenus
};
}));

columns->AddColumnOffset(1, 160);
columns->AddItem(miscGroup);
toxic->AddItem(columns);

AddCategory(std::move(toxic));
}
Expand Down
1 change: 0 additions & 1 deletion src/game/frontend/submenus/Self.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ namespace YimMenu::Submenus
horseGlobalsGroup->AddItem(std::make_shared<BoolCommandItem>("horsegodmode"_J));
horseGlobalsGroup->AddItem(std::make_shared<BoolCommandItem>("horsenoragdoll"_J));
horseGlobalsGroup->AddItem(std::make_shared<BoolCommandItem>("keephorsebarsfilled"_J));
horseGlobalsGroup->AddItem(std::make_shared<BoolCommandItem>("keephorsebarsfilled"_J));
horseGlobalsGroup->AddItem(std::make_shared<BoolCommandItem>("keephorsecoresfilled"_J));
horseGlobalsGroup->AddItem(std::make_shared<BoolCommandItem>("keephorseagitationlow"_J));
horseGlobalsGroup->AddItem(std::make_shared<CommandItem>("tpmounttoself"_J));
Expand Down
2 changes: 0 additions & 2 deletions src/game/hooks/Misc/ThrowFatalError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ namespace YimMenu::Hooks
void Misc::ThrowFatalError(int code, int fileHash, int fileLine)
{
LOG(FATAL) << "RECEIVED FATAL ERROR | Code = " << HEX((uint32_t)code) << " | FileHash = " << HEX((uint32_t)fileHash) << " | FileLine = " << (uint32_t)fileLine << " | ReturnAddress = " << HEX((__int64)_ReturnAddress() - (__int64)GetModuleHandle(0));

BaseHook::Get<Misc::ThrowFatalError, DetourHook<decltype(&Misc::ThrowFatalError)>>()->Original()(code, fileHash, fileLine); //Function is noreturn
}
}

0 comments on commit e5bd3bf

Please sign in to comment.