This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
Files
YimMenu/src/views/players/player/player_info.cpp

199 lines
6.4 KiB
C++
Raw Normal View History

2022-12-06 16:12:02 +00:00
#include "views/view.hpp"
#include "services/player_database/player_database_service.hpp"
#include "core/data/command_access_levels.hpp"
#include "core/scr_globals.hpp"
#include "core/data/language_codes.hpp"
#include <script/globals/GlobalPlayerBD.hpp>
#include <script/globals/GPBD_FM_3.hpp>
#include <script/globals/GPBD_FM.hpp>
2022-12-06 16:12:02 +00:00
namespace big
{
void view::player_info()
{
if (ImGui::TreeNode("INFO"_T.data()))
2022-12-06 16:12:02 +00:00
{
ImGui::Text("PLAYER_INFO_ID"_T.data(), g_player_service->get_selected()->id());
2022-12-06 16:12:02 +00:00
ImGui::Text("PLAYER_INFO_SESSION_HOST"_T.data(), g_player_service->get_selected()->is_host() ? "YES"_T.data() : "NO"_T.data());
2022-12-06 16:12:02 +00:00
ImGui::Separator();
if (CPlayerInfo* player_info = g_player_service->get_selected()->get_player_info(); player_info != nullptr)
{
ImGui::Text("PLAYER_INFO_WANTED_LEVEL"_T.data(), player_info->m_wanted_level);
2022-12-06 16:12:02 +00:00
}
uint32_t ped_damage_bits = 0;
uint32_t ped_task_flag = 0;
uint32_t ped_health = 0;
uint32_t ped_maxhealth = 0;
2022-12-06 16:12:02 +00:00
uint32_t veh_damage_bits = 0;
std::string mode_str = "";
if (CPed* ped = g_player_service->get_selected()->get_ped(); ped != nullptr)
{
ped_damage_bits = ped->m_damage_bits;
ped_task_flag = ped->m_ped_task_flag;
ped_health = ped->m_health;
ped_maxhealth = ped->m_maxhealth;
2022-12-06 16:12:02 +00:00
}
if (ped_damage_bits & (uint32_t)eEntityProofs::GOD)
{
mode_str = "PLAYER_INFO_GOD"_T;
2022-12-06 16:12:02 +00:00
}
else
{
if (ped_damage_bits & (uint32_t)eEntityProofs::BULLET)
{
mode_str += "PLAYER_INFO_BULLET"_T;
2022-12-06 16:12:02 +00:00
}
if (ped_damage_bits & (uint32_t)eEntityProofs::EXPLOSION)
{
mode_str += "PLAYER_INFO_EXPLOSION"_T;
2022-12-06 16:12:02 +00:00
}
if (ped_health > 328 || ped_maxhealth > 328 && !(uint32_t)eEntityProofs::EXPLOSION && !(uint32_t)eEntityProofs::BULLET)
{
mode_str += "Unnatural Health";
}
2022-12-06 16:12:02 +00:00
}
if (mode_str.empty())
{
mode_str = "NO"_T;
2022-12-06 16:12:02 +00:00
}
ImGui::Text("PLAYER_INFO_PROOFS"_T.data(), mode_str.c_str());
2022-12-06 16:12:02 +00:00
mode_str = "";
if (auto vehicle = g_player_service->get_selected()->get_current_vehicle(); vehicle != nullptr)
{
veh_damage_bits = vehicle->m_damage_bits;
}
if (ped_task_flag & (uint8_t)ePedTask::TASK_DRIVING)
{
if (veh_damage_bits & (uint32_t)eEntityProofs::GOD)
{
mode_str = "PLAYER_INFO_GOD"_T;
2022-12-06 16:12:02 +00:00
}
else
{
if (veh_damage_bits & (uint32_t)eEntityProofs::COLLISION)
{
mode_str += "PLAYER_INFO_COLLISION"_T;
2022-12-06 16:12:02 +00:00
}
if (veh_damage_bits & (uint32_t)eEntityProofs::EXPLOSION)
{
mode_str += "PLAYER_INFO_EXPLOSION"_T;
2022-12-06 16:12:02 +00:00
}
}
if (mode_str.empty())
{
mode_str = "NO"_T;
2022-12-06 16:12:02 +00:00
}
}
else
{
mode_str = "PLAYER_INFO_NO_VEHICLE"_T;
2022-12-06 16:12:02 +00:00
}
ImGui::Text("PLAYER_INFO_VEHICLE_PROOFS"_T.data(), mode_str.c_str());
2022-12-06 16:12:02 +00:00
ImGui::Separator();
if (auto net_player_data = g_player_service->get_selected()->get_net_data(); net_player_data != nullptr)
{
ImGui::Text("PLAYER_INFO_RID"_T.data(), net_player_data->m_gamer_handle_2.m_rockstar_id);
2022-12-06 16:12:02 +00:00
ImGui::SameLine();
ImGui::PushID("##rid");
if (ImGui::Button("COPY"_T.data())) ImGui::SetClipboardText(std::to_string(net_player_data->m_gamer_handle_2.m_rockstar_id).data());
ImGui::PopID();
2022-12-06 16:12:02 +00:00
ImGui::Text(
"PLAYER_INFO_IP"_T.data(),
2022-12-06 16:12:02 +00:00
net_player_data->m_external_ip.m_field1,
net_player_data->m_external_ip.m_field2,
net_player_data->m_external_ip.m_field3,
net_player_data->m_external_ip.m_field4,
net_player_data->m_external_port
);
ImGui::SameLine();
ImGui::PushID("##ip");
if (ImGui::Button("COPY"_T.data())) ImGui::SetClipboardText(std::format("{}.{}.{}.{}:{}", net_player_data->m_external_ip.m_field1,
2022-12-06 16:12:02 +00:00
net_player_data->m_external_ip.m_field2,
net_player_data->m_external_ip.m_field3,
net_player_data->m_external_ip.m_field4,
net_player_data->m_external_port).data());
ImGui::PopID();
2022-12-06 16:12:02 +00:00
}
ImGui::Separator();
auto id = g_player_service->get_selected()->id();
if (id != -1)
{
auto& stats = scr_globals::gpbd_fm_1.as<GPBD_FM*>()->Entries[id].PlayerStats;
auto& boss_goon = scr_globals::gpbd_fm_3.as<GPBD_FM_3*>()->Entries[id].BossGoon;
if (boss_goon.Language >= 0 && boss_goon.Language < 13)
ImGui::Text("PLAYER_INFO_LANGUAGE"_T.data(), languages[boss_goon.Language].name);
ImGui::Text("PLAYER_INFO_CEO_NAME"_T.data(), boss_goon.GangName);
ImGui::Text("PLAYER_INFO_MC_NAME"_T.data(), boss_goon.ClubhouseName);
ImGui::Text("PLAYER_INFO_WALLET"_T.data(), stats.WalletBalance);
ImGui::Text("PLAYER_INFO_BANK"_T.data(), stats.Money - stats.WalletBalance);
ImGui::Text("PLAYER_INFO_TOTAL_MONEY"_T.data(), stats.Money);
ImGui::Text("PLAYER_INFO_RANK"_T.data(), stats.Rank, stats.RP);
ImGui::Text("Health: %d (MaxHealth: %d)", ped_health, ped_maxhealth); // TODO: translate
ImGui::Text("PLAYER_INFO_KD"_T.data(), stats.KdRatio);
ImGui::Text("PLAYER_INFO_KILLS"_T.data(), stats.KillsOnPlayers);
ImGui::Text("PLAYER_INFO_DEATHS"_T.data(), stats.DeathsByPlayers);
ImGui::Text("PLAYER_INFO_PROSTITUTES"_T.data(), stats.ProstitutesFrequented);
ImGui::Text("PLAYER_INFO_LAP_DANCES"_T.data(), stats.LapDancesBought);
ImGui::Text("PLAYER_INFO_MISSIONS_CREATED"_T.data(), stats.MissionsCreated);
ImGui::Text("PLAYER_INFO_METLDOWN_COMPLETE"_T.data(), scr_globals::gpbd_fm_1.as<GPBD_FM*>()->Entries[id].MeltdownComplete ? "YES"_T.data() : "NO"_T.data()); // curious to see if anyone has actually played singleplayer
ImGui::Separator();
}
2022-12-06 16:12:02 +00:00
if (ImGui::BeginCombo("CHAT_COMMAND_PERMISSIONS"_T.data(), COMMAND_ACCESS_LEVELS[g_player_service->get_selected()->command_access_level.value_or(g.session.chat_command_default_access_level)]))
{
for (const auto& [type, name] : COMMAND_ACCESS_LEVELS)
{
if (ImGui::Selectable(name, type == g_player_service->get_selected()->command_access_level.value_or(g.session.chat_command_default_access_level)))
{
g.session.chat_command_default_access_level = type;
g_player_database_service->get_or_create_player(g_player_service->get_selected())->command_access_level = type;
g_player_database_service->save();
}
if (type == g_player_service->get_selected()->command_access_level.value_or(g.session.chat_command_default_access_level))
{
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
if (ImGui::Button("PLAYER_INFO_ADD_TO_DB"_T.data()))
2022-12-06 16:12:02 +00:00
{
g_player_database_service->get_or_create_player(g_player_service->get_selected());
}
ImGui::TreePop();
}
}
}