CheatMenuSA/CheatMenu/Player.cpp

467 lines
13 KiB
C++
Raw Normal View History

2020-12-02 16:19:16 -05:00
#include "pch.h"
#include "Player.h"
#include "Ped.h"
#include "Menu.h"
#include "Ui.h"
#include "Util.h"
2020-12-02 16:19:16 -05:00
2021-03-02 14:18:37 -05:00
inline static void PlayerModelBrokenFix()
{
2021-06-18 12:49:11 -04:00
CPlayerPed* pPlayer = FindPlayerPed();
2021-06-18 12:49:11 -04:00
if (pPlayer->m_nModelIndex == 0)
Call<0x5A81E0>(0, pPlayer->m_pPlayerData->m_pPedClothesDesc, 0xBC1C78, false);
}
2020-12-02 16:19:16 -05:00
Player::Player()
{
2021-02-24 16:54:45 -05:00
// Fix player model being broken after rebuild
patch::RedirectCall(0x5A834D, &PlayerModelBrokenFix);
2021-06-18 12:49:11 -04:00
m_bAimSkinChanger = config.GetValue("aim_skin_changer", false);
2020-12-02 16:19:16 -05:00
2021-02-24 16:54:45 -05:00
// Custom skins setup
if (GetModuleHandle("modloader.asi"))
{
if (fs::is_directory(m_CustomSkins::m_Path))
2020-12-02 16:19:16 -05:00
{
for (auto& p : fs::recursive_directory_iterator(m_CustomSkins::m_Path))
2020-12-02 16:19:16 -05:00
{
2021-02-24 16:54:45 -05:00
if (p.path().extension() == ".dff")
2020-12-02 16:19:16 -05:00
{
2021-02-24 16:54:45 -05:00
std::string file_name = p.path().stem().string();
2020-12-02 16:19:16 -05:00
2021-02-24 16:54:45 -05:00
if (file_name.size() < 9)
m_CustomSkins::m_List.push_back(file_name);
2021-02-24 16:54:45 -05:00
else
2021-02-25 17:45:41 -05:00
flog << "Custom Skin longer than 8 characters " << file_name << std::endl;
2020-12-02 16:19:16 -05:00
}
}
}
else fs::create_directory(m_CustomSkins::m_Path);
2021-02-24 16:54:45 -05:00
2021-06-18 12:49:11 -04:00
m_bModloaderInstalled = true;
2021-02-24 16:54:45 -05:00
}
2020-12-02 16:19:16 -05:00
Events::processScriptsEvent += []
{
uint timer = CTimer::m_snTimeInMilliseconds;
static CPlayerPed* player = FindPlayerPed();
2021-06-18 12:49:11 -04:00
if (!m_bImagesLoaded)
2021-02-24 16:54:45 -05:00
{
2021-06-18 12:49:11 -04:00
Util::LoadTexturesInDirRecursive(
PLUGIN_PATH((char*)"CheatMenu\\clothes\\"), ".jpg", m_ClothData.m_Categories, m_ClothData.m_ImagesList);
m_bImagesLoaded = true;
2021-02-24 16:54:45 -05:00
}
if (m_KeepPosition::m_bEnabled)
2020-12-02 16:19:16 -05:00
{
if (!player->IsAlive())
{
m_KeepPosition::m_fPos = player->GetPosition();
2020-12-02 16:19:16 -05:00
}
else
{
CVector cur_pos = player->GetPosition();
if (m_KeepPosition::m_fPos.x != 0 && m_KeepPosition::m_fPos.x != cur_pos.x
&& m_KeepPosition::m_fPos.y != 0 && m_KeepPosition::m_fPos.y != cur_pos.y)
2020-12-02 16:19:16 -05:00
{
player->Teleport(m_KeepPosition::m_fPos, false);
m_KeepPosition::m_fPos = CVector(0, 0, 0);
2020-12-02 16:19:16 -05:00
}
}
}
2021-06-18 12:49:11 -04:00
if (m_bGodMode)
2020-12-02 16:19:16 -05:00
{
patch::Set<bool>(0x96916D, 1, false);
player->m_nPhysicalFlags.bBulletProof = 1;
player->m_nPhysicalFlags.bCollisionProof = 1;
player->m_nPhysicalFlags.bExplosionProof = 1;
player->m_nPhysicalFlags.bFireProof = 1;
player->m_nPhysicalFlags.bMeeleProof = 1;
}
2021-02-24 16:54:45 -05:00
if (m_bAimSkinChanger && Ui::HotKeyPressed(Menu::m_HotKeys::aimSkinChanger))
2020-12-02 16:19:16 -05:00
{
2021-02-24 16:54:45 -05:00
CPed* target_ped = player->m_pPlayerTargettedPed;
2020-12-02 16:19:16 -05:00
if (target_ped)
{
player->SetModelIndex(target_ped->m_nModelIndex);
Util::ClearCharTasksVehCheck(player);
}
}
if (Ui::HotKeyPressed(Menu::m_HotKeys::godMode))
{
2021-06-18 12:49:11 -04:00
if (m_bGodMode)
{
2021-02-24 16:54:45 -05:00
CHud::SetHelpMessage("God mode disabled", false, false, false);
2021-06-18 12:49:11 -04:00
patch::Set<bool>(0x96916D, m_bGodMode, false);
player->m_nPhysicalFlags.bBulletProof = false;
player->m_nPhysicalFlags.bCollisionProof = false;
player->m_nPhysicalFlags.bExplosionProof = false;
player->m_nPhysicalFlags.bFireProof = false;
player->m_nPhysicalFlags.bMeeleProof = false;
2021-06-18 12:49:11 -04:00
m_bGodMode = false;
}
else
{
2021-02-24 16:54:45 -05:00
CHud::SetHelpMessage("God mode enabled", false, false, false);
2021-06-18 12:49:11 -04:00
m_bGodMode = true;
}
}
2020-12-02 16:19:16 -05:00
};
}
2021-03-16 03:12:59 -04:00
Player::~Player()
{
2021-06-18 12:49:11 -04:00
Util::ReleaseTextures(m_ClothData.m_ImagesList);
2021-03-16 03:12:59 -04:00
}
2021-02-24 16:54:45 -05:00
void Player::ChangePlayerCloth(std::string& name)
2020-12-02 16:19:16 -05:00
{
std::stringstream ss(name);
std::string temp;
getline(ss, temp, '$');
int body_part = std::stoi(temp);
getline(ss, temp, '$');
std::string model = temp.c_str();
getline(ss, temp, '$');
std::string texture9 = temp.c_str();
2021-02-24 16:54:45 -05:00
CPlayerPed* player = FindPlayerPed();
2020-12-02 16:19:16 -05:00
if (texture9 == "cutoffchinosblue")
{
player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(-697413025, 744365350, body_part);
}
else
{
if (texture9 == "sneakerbincblue")
{
player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(-915574819, 2099005073, body_part);
}
else
{
if (texture9 == "12myfac")
player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(-1750049245, 1393983095, body_part);
else
2021-06-18 12:49:11 -04:00
player->m_pPlayerData->m_pPedClothesDesc->
SetTextureAndModel(texture9.c_str(), model.c_str(), body_part);
2020-12-02 16:19:16 -05:00
}
}
CClothes::RebuildPlayer(player, false);
}
void Player::ChangePlayerModel(std::string& model)
{
bool custom_skin = std::find(m_CustomSkins::m_List.begin(), m_CustomSkins::m_List.end(), model) !=
m_CustomSkins::m_List.end();
2021-06-18 12:49:11 -04:00
if (Ped::m_PedData.m_Json.m_Data.contains(model) || custom_skin)
2020-12-02 16:19:16 -05:00
{
2021-02-24 16:54:45 -05:00
CPlayerPed* player = FindPlayerPed();
2021-06-18 12:49:11 -04:00
if (Ped::m_SpecialPedJson.m_Data.contains(model) || custom_skin)
2020-12-02 16:19:16 -05:00
{
std::string name;
2021-06-18 12:49:11 -04:00
if (Ped::m_SpecialPedJson.m_Data.contains(model))
name = Ped::m_SpecialPedJson.m_Data[model].get<std::string>().c_str();
2020-12-02 16:19:16 -05:00
else
name = model;
CStreaming::RequestSpecialChar(1, name.c_str(), PRIORITY_REQUEST);
CStreaming::LoadAllRequestedModels(true);
player->SetModelIndex(291);
CStreaming::SetSpecialCharIsDeletable(291);
}
else
{
int imodel = std::stoi(model);
2021-02-24 16:54:45 -05:00
CStreaming::RequestModel(imodel, eStreamingFlags::PRIORITY_REQUEST);
2020-12-02 16:19:16 -05:00
CStreaming::LoadAllRequestedModels(false);
player->SetModelIndex(imodel);
CStreaming::SetModelIsDeletable(imodel);
}
}
}
2021-02-24 16:54:45 -05:00
void Player::Draw()
2020-12-02 16:19:16 -05:00
{
2021-06-18 12:49:11 -04:00
CPlayerPed* pPlayer = FindPlayerPed();
int hplayer = CPools::GetPedRef(pPlayer);
CPad* pad = pPlayer->GetPadFromPlayer();
2020-12-02 16:19:16 -05:00
if (ImGui::Button("Copy coordinates", ImVec2(Ui::GetSize(2))))
{
2021-06-18 12:49:11 -04:00
CVector pos = pPlayer->GetPosition();
2020-12-02 16:19:16 -05:00
std::string text = std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " + std::to_string(pos.z);
ImGui::SetClipboardText(text.c_str());
CHud::SetHelpMessage("Coordinates copied", false, false, false);
}
ImGui::SameLine();
if (ImGui::Button("Suicide", ImVec2(Ui::GetSize(2))))
2021-06-18 12:49:11 -04:00
pPlayer->m_fHealth = 0.0;
2021-02-24 16:54:45 -05:00
2020-12-02 16:19:16 -05:00
ImGui::Spacing();
if (ImGui::BeginTabBar("Player", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{
if (ImGui::BeginTabItem("Checkboxes"))
{
ImGui::Spacing();
ImGui::BeginChild("CheckboxesChild");
ImGui::Columns(2, 0, false);
Ui::CheckboxAddress("Bounty on yourself", 0x96913F);
2021-06-18 12:49:11 -04:00
if (Ui::CheckboxWithHint("God mode", &m_bGodMode))
2020-12-02 16:19:16 -05:00
{
2021-06-18 12:49:11 -04:00
patch::Set<bool>(0x96916D, m_bGodMode, false);
pPlayer->m_nPhysicalFlags.bBulletProof = m_bGodMode;
pPlayer->m_nPhysicalFlags.bCollisionProof = m_bGodMode;
pPlayer->m_nPhysicalFlags.bExplosionProof = m_bGodMode;
pPlayer->m_nPhysicalFlags.bFireProof = m_bGodMode;
pPlayer->m_nPhysicalFlags.bMeeleProof = m_bGodMode;
2020-12-02 16:19:16 -05:00
}
Ui::CheckboxAddress("Higher cycle jumps", 0x969161);
Ui::CheckboxAddress("Infinite oxygen", 0x96916E);
Ui::CheckboxAddress("Infinite run", 0xB7CEE4);
2021-06-18 12:49:11 -04:00
if (Ui::CheckboxBitFlag("Invisible player", pPlayer->m_nPedFlags.bDontRender))
pPlayer->m_nPedFlags.bDontRender = (pPlayer->m_nPedFlags.bDontRender == 1) ? 0 : 1;
2021-02-24 16:54:45 -05:00
2020-12-02 16:19:16 -05:00
ImGui::NextColumn();
Ui::CheckboxWithHint("Keep position", &m_KeepPosition::m_bEnabled, "Teleport to the position you died from");
2020-12-02 16:19:16 -05:00
if (Ui::CheckboxBitFlag("Lock control", pad->bPlayerSafe))
pad->bPlayerSafe = (pad->bPlayerSafe == 1) ? 0 : 1;
Ui::CheckboxAddress("Mega jump", 0x96916C);
Ui::CheckboxAddress("Mega punch", 0x969173);
Ui::CheckboxAddress("Never get hungry", 0x969174);
2021-02-24 16:54:45 -05:00
bool never_wanted = patch::Get<bool>(0x969171, false);
2020-12-02 16:19:16 -05:00
if (Ui::CheckboxWithHint("Never wanted", &never_wanted))
CCheat::NotWantedCheat();
2021-02-24 16:54:45 -05:00
2020-12-02 16:19:16 -05:00
ImGui::Columns(1);
ImGui::EndChild();
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Menus"))
{
ImGui::BeginChild("PlayerMenus");
2021-06-18 12:49:11 -04:00
Ui::EditReference("Armour", pPlayer->m_fArmour, 0, 100, 150);
2020-12-02 16:19:16 -05:00
if (ImGui::CollapsingHeader("Body"))
{
2021-06-18 12:49:11 -04:00
if (pPlayer->m_nModelIndex == 0)
2020-12-02 16:19:16 -05:00
{
ImGui::Columns(3, 0, false);
2021-06-18 12:49:11 -04:00
if (ImGui::RadioButton("Fat", &m_nUiBodyState, 2))
2020-12-02 16:19:16 -05:00
CCheat::FatCheat();
ImGui::NextColumn();
2021-06-18 12:49:11 -04:00
if (ImGui::RadioButton("Muscle", &m_nUiBodyState, 1))
2020-12-02 16:19:16 -05:00
CCheat::MuscleCheat();
ImGui::NextColumn();
2021-06-18 12:49:11 -04:00
if (ImGui::RadioButton("Skinny", &m_nUiBodyState, 0))
2020-12-02 16:19:16 -05:00
CCheat::SkinnyCheat();
ImGui::Columns(1);
}
else
{
ImGui::TextWrapped("You need to be in CJ skin.");
ImGui::Spacing();
if (ImGui::Button("Change to CJ skin", ImVec2(Ui::GetSize(1))))
{
2021-06-18 12:49:11 -04:00
pPlayer->SetModelIndex(0);
Util::ClearCharTasksVehCheck(pPlayer);
2020-12-02 16:19:16 -05:00
}
}
ImGui::Spacing();
ImGui::Separator();
}
Ui::EditStat("Energy", STAT_ENERGY);
Ui::EditStat("Fat", STAT_FAT);
2021-06-18 12:49:11 -04:00
Ui::EditReference("Health", pPlayer->m_fHealth, 0, 100, static_cast<int>(pPlayer->m_fMaxHealth));
2020-12-02 16:19:16 -05:00
Ui::EditStat("Lung capacity", STAT_LUNG_CAPACITY);
2021-02-24 16:54:45 -05:00
Ui::EditStat("Max health", STAT_MAX_HEALTH, 0, 569, 1450);
2020-12-02 16:19:16 -05:00
Ui::EditAddress<int>("Money", 0xB7CE50, -99999999, 0, 99999999);
Ui::EditStat("Muscle", STAT_MUSCLE);
Ui::EditStat("Respect", STAT_RESPECT);
Ui::EditStat("Stamina", STAT_STAMINA);
if (ImGui::CollapsingHeader("Wanted level"))
{
2021-06-18 12:49:11 -04:00
int val = pPlayer->m_pPlayerData->m_pWanted->m_nWantedLevel;
int max_wl = pPlayer->m_pPlayerData->m_pWanted->MaximumWantedLevel;
2020-12-02 16:19:16 -05:00
ImGui::Columns(3, 0, false);
ImGui::Text("Min: 0");
ImGui::NextColumn();
ImGui::Text("Def: 0");
ImGui::NextColumn();
2021-02-24 16:54:45 -05:00
ImGui::Text("Max: %d", max_wl);
2020-12-02 16:19:16 -05:00
ImGui::Columns(1);
ImGui::Spacing();
if (ImGui::InputInt("Set value##Wanted level", &val))
2021-06-18 12:49:11 -04:00
pPlayer->CheatWantedLevel(val);
2021-02-24 16:54:45 -05:00
2020-12-02 16:19:16 -05:00
ImGui::Spacing();
if (ImGui::Button("Minimum##Wanted level", Ui::GetSize(3)))
2021-06-18 12:49:11 -04:00
pPlayer->CheatWantedLevel(0);
2020-12-02 16:19:16 -05:00
ImGui::SameLine();
if (ImGui::Button("Default##Wanted level", Ui::GetSize(3)))
2021-06-18 12:49:11 -04:00
pPlayer->CheatWantedLevel(0);
2020-12-02 16:19:16 -05:00
ImGui::SameLine();
if (ImGui::Button("Maximum##Wanted level", Ui::GetSize(3)))
2021-06-18 12:49:11 -04:00
pPlayer->CheatWantedLevel(max_wl);
2020-12-02 16:19:16 -05:00
ImGui::Spacing();
ImGui::Separator();
}
ImGui::EndChild();
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Appearance"))
{
ImGui::Spacing();
2021-06-18 12:49:11 -04:00
if (Ui::CheckboxWithHint("Aim skin changer", &m_bAimSkinChanger,
(("Changes to the ped, player is targeting with a weapon.\nTo use aim a ped with a weapon and press ")
+ Ui::GetHotKeyNameString(Menu::m_HotKeys::aimSkinChanger)).c_str()))
2021-06-18 12:49:11 -04:00
config.SetValue("aim_skin_changer", m_bAimSkinChanger);
2020-12-02 16:19:16 -05:00
if (ImGui::BeginTabBar("AppearanceTabBar"))
{
if (ImGui::BeginTabItem("Clothes"))
{
ImGui::Spacing();
2021-06-18 12:49:11 -04:00
if (pPlayer->m_nModelIndex == 0)
2020-12-02 16:19:16 -05:00
{
if (ImGui::Button("Remove clothes", ImVec2(Ui::GetSize())))
{
2021-02-24 16:54:45 -05:00
CPlayerPed* player = FindPlayerPed();
2020-12-02 16:19:16 -05:00
int temp = 0;
for (uint i = 0; i < 18; i++)
player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(temp, temp, i);
CClothes::RebuildPlayer(player, false);
}
ImGui::Spacing();
2021-06-18 12:49:11 -04:00
Ui::DrawImages(m_ClothData.m_ImagesList, ImVec2(70, 100), m_ClothData.m_Categories, m_ClothData.m_Selected,
m_ClothData.m_Filter, ChangePlayerCloth, nullptr,
[](std::string str)
{
std::stringstream ss(str);
std::string temp;
2020-12-02 16:19:16 -05:00
2021-06-18 12:49:11 -04:00
getline(ss, temp, '$');
getline(ss, temp, '$');
2020-12-02 16:19:16 -05:00
2021-06-18 12:49:11 -04:00
return temp;
});
2020-12-02 16:19:16 -05:00
}
else
{
ImGui::TextWrapped("You need to be in CJ skin.");
ImGui::Spacing();
if (ImGui::Button("Change to CJ skin", ImVec2(Ui::GetSize(1))))
{
2021-06-18 12:49:11 -04:00
pPlayer->SetModelIndex(0);
Util::ClearCharTasksVehCheck(pPlayer);
2020-12-02 16:19:16 -05:00
}
}
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Ped skins"))
{
2021-06-18 12:49:11 -04:00
Ui::DrawImages(Ped::m_PedData.m_ImagesList, ImVec2(65, 110), Ped::m_PedData.m_Categories,
Ped::m_PedData.m_Selected, Ped::m_PedData.m_Filter, ChangePlayerModel, nullptr,
[](std::string str) { return Ped::m_PedData.m_Json.m_Data[str].get<std::string>(); });
2020-12-02 16:19:16 -05:00
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Custom skins"))
{
ImGui::Spacing();
2021-02-24 16:54:45 -05:00
2021-06-18 12:49:11 -04:00
if (m_bModloaderInstalled)
2021-02-24 16:54:45 -05:00
{
2021-06-18 12:49:11 -04:00
Ui::FilterWithHint("Search", m_ClothData.m_Filter,
std::string("Total skins: " + std::to_string(m_CustomSkins::m_List.size()))
2021-06-18 12:49:11 -04:00
.c_str());
2021-02-08 05:25:06 -05:00
Ui::ShowTooltip("Place your dff & txd files inside 'modloader/Custom Skins'");
ImGui::Spacing();
2021-06-18 12:49:11 -04:00
ImGui::TextWrapped(
"Note: Your txd & dff names can't exceed 8 characters. Don't change names while the game is running.");
2021-02-08 05:25:06 -05:00
ImGui::Spacing();
for (std::string name : m_CustomSkins::m_List)
2020-12-02 16:19:16 -05:00
{
if (m_CustomSkins::m_Filter.PassFilter(name.c_str()))
2020-12-02 16:19:16 -05:00
{
2021-02-24 16:54:45 -05:00
if (ImGui::MenuItem(name.c_str()))
2020-12-02 16:19:16 -05:00
{
ChangePlayerModel(name);
}
}
}
}
else
{
2021-06-18 12:49:11 -04:00
ImGui::TextWrapped(
"Custom skin allows to change player skins without replacing any existing game ped skins.\n\
2021-06-17 09:00:32 -04:00
Steps to enable 'Custom Skins',\n\n\
1. Download & install modloader\n\
2. Create a folder inside 'modloader' folder with the name 'Custom Skins'\n\
3. Download ped skins online ( .dff & .txd files) and put them inside.\n\
4. Restart your game.\n\n\n\
Limitations:\n\
1. Your .dff & .txd file names must not exceed 8 characters.\n\
2. Do not rename them while the game is running\n\
\nDoing so will crash your game.");
2020-12-02 16:19:16 -05:00
ImGui::Spacing();
if (ImGui::Button("Download Modloader", ImVec2(Ui::GetSize(1))))
2021-06-18 12:49:11 -04:00
ShellExecute(NULL, "open", "https://gtaforums.com/topic/669520-mod-loader/", NULL, NULL,
SW_SHOWNORMAL);
2020-12-02 16:19:16 -05:00
}
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
}