Improve protections again and player database (#606)

This commit is contained in:
maybegreat48
2022-11-19 01:49:36 +00:00
committed by GitHub
parent ffa2d74b60
commit ab49103171
49 changed files with 1416 additions and 803 deletions

View File

@ -19,6 +19,11 @@ namespace big
NETWORK::NETWORK_BAIL(16, 0, 0);
});
if (g_local_player && g_local_player->m_player_info)
{
ImGui::InputScalar("Rockstar ID", ImGuiDataType_S64, &g_local_player->m_player_info->m_net_player_data.m_gamer_handle_2.m_rockstar_id, nullptr, nullptr, nullptr, ImGuiInputTextFlags_ReadOnly);
}
ImGui::EndTabItem();
}
}

View File

@ -0,0 +1,152 @@
#include "views/view.hpp"
#include "fiber_pool.hpp"
#include "pointers.hpp"
#include "services/players/player_service.hpp"
#include "services/player_database/player_database_service.hpp"
#include "core/data/block_join_reasons.hpp"
#include "core/data/infractions.hpp"
#include "util/session.hpp"
namespace big
{
persistent_player current_player;
void view::player_database()
{
static char name_buf[32];
static char search[64];
ImGui::SetNextItemWidth(300.f);
components::input_text_with_hint("Player", "Search", search, sizeof(search), ImGuiInputTextFlags_None);
if (ImGui::ListBoxHeader("###players", { 180, static_cast<float>(*g_pointers->m_resolution_y - 400 - 38 * 4) }))
{
auto& item_arr = g_player_database_service->get_players();
if (item_arr.size() > 0)
{
std::string lower_search = search;
std::transform(lower_search.begin(), lower_search.end(), lower_search.begin(), tolower);
for (auto& item : item_arr)
{
auto& player = item.second;
std::string name = player.name;
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
if (lower_search.empty() || name.find(lower_search) != std::string::npos)
{
ImGui::PushID(item.first);
if (components::selectable(player.name, &player == g_player_database_service->get_selected()))
{
g_player_database_service->set_selected(&player);
current_player = player;
strncpy(name_buf, current_player.name.data(), sizeof(name_buf));
}
ImGui::PopID();
}
}
}
else
{
ImGui::Text("No stored players");
}
ImGui::ListBoxFooter();
}
if (auto selected = g_player_database_service->get_selected())
{
ImGui::SameLine();
if (ImGui::BeginChild("###selected_player", { 500, static_cast<float>(*g_pointers->m_resolution_y - 388 - 38 * 4) }, false, ImGuiWindowFlags_NoBackground))
{
if (ImGui::InputText("Name", name_buf, sizeof(name_buf)))
{
current_player.name = name_buf;
}
ImGui::InputScalar("Rockstar ID", ImGuiDataType_S64, &current_player.rockstar_id);
ImGui::Checkbox("Is Modder", &current_player.is_modder);
ImGui::Checkbox("Block Join", &current_player.block_join);
if (ImGui::BeginCombo("Block Join Alert", block_join_reasons[current_player.block_join_reason]))
{
for (const auto& reason : block_join_reasons)
{
if (ImGui::Selectable(reason.second, reason.first == current_player.block_join_reason))
{
current_player.block_join_reason = reason.first;
}
if (reason.first == current_player.block_join_reason)
{
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Only works as host");
if (!current_player.infractions.empty())
{
ImGui::Text("Infractions:");
for (auto& infraction : current_player.infractions)
{
ImGui::BulletText(infraction_desc[(Infraction)infraction]);
}
}
components::button("Join Session", []
{
session::join_by_rockstar_id(current_player.rockstar_id);
});
if (ImGui::Button("Save"))
{
if (current_player.rockstar_id != selected->rockstar_id)
g_player_database_service->update_rockstar_id(selected->rockstar_id, current_player.rockstar_id);
*selected = current_player;
g_player_database_service->save();
}
ImGui::SameLine();
if (ImGui::Button("Remove"))
{
g_player_database_service->remove_rockstar_id(selected->rockstar_id);
}
}
ImGui::EndChild();
}
if (ImGui::Button("Remove All"))
{
g_player_database_service->set_selected(nullptr);
g_player_database_service->get_players().clear();
g_player_database_service->save();
}
ImGui::Separator();
components::sub_title("New Entry");
static char new_name[64];
static int64_t new_rockstar_id;
ImGui::InputText("Name", new_name, sizeof(new_name));
ImGui::InputScalar("Rockstar ID", ImGuiDataType_S64, &new_rockstar_id);
if (ImGui::Button("Add"))
{
g_player_database_service->get_players()[new_rockstar_id] = persistent_player(new_name, new_rockstar_id);
g_player_database_service->save();
}
}
}

View File

@ -42,6 +42,13 @@ namespace big
ImGui::EndListBox();
}
components::sub_title("Player Magnet");
ImGui::Checkbox("Enabled", &g->session.player_magnet_enabled);
if (g->session.player_magnet_enabled)
{
ImGui::InputInt("Player Count", &g->session.player_magnet_count);
}
components::sub_title("Chat");
ImGui::Checkbox("Disable Filter", &g->session.disable_chat_filter);
ImGui::Checkbox("Log Chat Messages", &g->session.log_chat_messages);

View File

@ -1,6 +1,7 @@
#include "gta_util.hpp"
#include "services/pickups/pickup_service.hpp"
#include "services/players/player_service.hpp"
#include "services/player_database/player_database_service.hpp"
#include "util/globals.hpp"
#include "util/misc.hpp"
#include "util/ped.hpp"
@ -18,53 +19,6 @@ namespace big
if (g_player_service->get_selected()->is_valid())
{
if (ImGui::TreeNode("Misc"))
{
components::button("Steal Outfit", [] {
ped::steal_outfit(
PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player_service->get_selected()->id())
);
});
ImGui::SameLine();
components::button("Steal Identity", [] {
ped::steal_identity(
PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player_service->get_selected()->id())
);
});
components::button("Clear Wanted Level", [] {
globals::clear_wanted_player(g_player_service->get_selected()->id());
});
ImGui::SameLine();
ImGui::Checkbox("Never Wanted", &g_player_service->get_selected()->never_wanted);
components::button("Give Health", [] {
g_pickup_service->give_player_health(g_player_service->get_selected()->id());
});
ImGui::SameLine();
components::button("Give Armour", [] {
g_pickup_service->give_player_armour(g_player_service->get_selected()->id());
});
components::button("Give Ammo", [] {
g_pickup_service->give_player_ammo(g_player_service->get_selected()->id());
});
ImGui::SameLine();
components::button("Give Weapons", [] {
g_pickup_service->give_player_weapons(g_player_service->get_selected()->id());
});
ImGui::TreePop();
}
if (ImGui::TreeNode("Info")) {
ImGui::Text("Player ID: %d", g_player_service->get_selected()->id());
@ -164,6 +118,11 @@ namespace big
);
}
if (ImGui::Button("Add To Database"))
{
g_player_database_service->get_or_create_player(g_player_service->get_selected());
}
ImGui::TreePop();
}
@ -187,6 +146,60 @@ namespace big
ImGui::TreePop();
}
if (ImGui::TreeNode("Misc"))
{
components::button("Steal Outfit", []
{
ped::steal_outfit(
PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player_service->get_selected()->id())
);
});
ImGui::SameLine();
components::button("Steal Identity", []
{
ped::steal_identity(
PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player_service->get_selected()->id())
);
});
components::button("Clear Wanted Level", []
{
globals::clear_wanted_player(g_player_service->get_selected()->id());
});
ImGui::SameLine();
ImGui::Checkbox("Never Wanted", &g_player_service->get_selected()->never_wanted);
components::button("Give Health", []
{
g_pickup_service->give_player_health(g_player_service->get_selected()->id());
});
ImGui::SameLine();
components::button("Give Armour", []
{
g_pickup_service->give_player_armour(g_player_service->get_selected()->id());
});
components::button("Give Ammo", []
{
g_pickup_service->give_player_ammo(g_player_service->get_selected()->id());
});
ImGui::SameLine();
components::button("Give Weapons", []
{
g_pickup_service->give_player_weapons(g_player_service->get_selected()->id());
});
ImGui::TreePop();
}
}
}
}

View File

@ -36,6 +36,9 @@ namespace big
const ImRect icons_box(icons_pos, icons_pos + icons_size);
ImGui::PopFont();
if (plyr->is_modder)
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1.f, 0.1f, 0.1f, 1.f));
if (selected_player)
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.29f, 0.45f, 0.69f, 1.f));
@ -53,6 +56,9 @@ namespace big
if (selected_player)
ImGui::PopStyleColor();
if (plyr->is_modder)
ImGui::PopStyleColor();
// render icons on top of the player button
ImGui::PushFont(g->window.font_icon);
ImGui::RenderTextWrapped(icons_box.Min, player_iconsc, player_icons_end, icons_size.x);

View File

@ -28,6 +28,7 @@ namespace big
static void root();
static void self();
static void session();
static void player_database();
static void settings();
static void vehicle();
static void lsc();