diff --git a/BigBaseV2/src/core/globals.hpp b/BigBaseV2/src/core/globals.hpp index c46dc700..bb5e473c 100644 --- a/BigBaseV2/src/core/globals.hpp +++ b/BigBaseV2/src/core/globals.hpp @@ -21,7 +21,15 @@ namespace big { bool metric_logs{}; - bool script_event_logs = false; + bool script_hook_logs{}; + + struct + { + bool logs = false; + + bool filter_player = true; + std::int8_t player_id = -1; + } script_event{}; } logs{}; }; @@ -395,7 +403,7 @@ namespace big void from_json(const nlohmann::json& j) { this->debug.logs.metric_logs = j["debug"]["logs"]["metric_logs"]; - this->debug.logs.script_event_logs = j["debug"]["logs"]["script_event_logs"]; + this->debug.logs.script_hook_logs = j["debug"]["logs"]["script_hook_logs"]; g->notifications.gta_thread_kill.log = j["notifications"]["gta_thread_kill"]["log"]; g->notifications.gta_thread_kill.notify = j["notifications"]["gta_thread_kill"]["notify"]; @@ -688,7 +696,7 @@ namespace big "logs", { { "metric_logs", this->debug.logs.metric_logs }, - { "script_event_logs", this->debug.logs.script_event_logs } + { "script_hook_logs", this->debug.logs.script_hook_logs } } } } diff --git a/BigBaseV2/src/hooks/protections/script_event_handler.cpp b/BigBaseV2/src/hooks/protections/script_event_handler.cpp index f18b3e74..aaa3d546 100644 --- a/BigBaseV2/src/hooks/protections/script_event_handler.cpp +++ b/BigBaseV2/src/hooks/protections/script_event_handler.cpp @@ -323,16 +323,21 @@ namespace big } - if (g->debug.logs.script_event_logs) + if (g->debug.logs.script_event.logs && (!g->debug.logs.script_event.filter_player || g->debug.logs.script_event.player_id == player->m_player_id)) { - LOG(INFO) << "== Begin of Script Event =="; - LOG(INFO) << "Player: " << player->get_name(); - LOG(INFO) << "Hash/Arg #0: " << (int)hash; + std::string script_args = "{ "; + for (std::size_t i = 0; i < scripted_game_event->m_args_size; i++) + { + if (i) + script_args += ", "; - for (std::size_t i = 1; i < sizeof(args); i++) - LOG(INFO) << "Arg #" << i << ": " << args[i]; + script_args += std::to_string(args[i]); + } + script_args += " };"; - LOG(INFO) << "== End of Script Event =="; + LOG(G3LOG_DEBUG) << "Script Event:\n" + << "\tPlayer: " << player->get_name() << "\n" + << "\tArgs: " << script_args; } return false; diff --git a/BigBaseV2/src/native_hooks/native_hooks.cpp b/BigBaseV2/src/native_hooks/native_hooks.cpp index 5903059b..a81035b0 100644 --- a/BigBaseV2/src/native_hooks/native_hooks.cpp +++ b/BigBaseV2/src/native_hooks/native_hooks.cpp @@ -68,7 +68,7 @@ namespace big if (m_script_hooks.find(gta_thread->m_script_hash) != m_script_hooks.end()) { // this should never happen but if it does we catch it - LOG(INFO) << "Dynamic native script hook still active for script, cleaning up..."; + LOG_IF(G3LOG_DEBUG, g->debug.logs.script_hook_logs) << "Dynamic native script hook still active for script, cleaning up..."; m_script_hooks.erase(gta_thread->m_script_hash); } @@ -87,7 +87,7 @@ namespace big { if (m_script_hooks.erase(gta_thread->m_script_hash)) { - LOG(INFO) << gta_thread->m_name << " script terminated, cleaning up native hooks"; + LOG_IF(G3LOG_DEBUG, g->debug.logs.script_hook_logs) << gta_thread->m_name << " script terminated, cleaning up native hooks"; } } } \ No newline at end of file diff --git a/BigBaseV2/src/script_hook.cpp b/BigBaseV2/src/script_hook.cpp index ded10bcc..4f1573ac 100644 --- a/BigBaseV2/src/script_hook.cpp +++ b/BigBaseV2/src/script_hook.cpp @@ -58,7 +58,7 @@ namespace big if (program->is_valid()) { hook_instance(program); - LOG(INFO) << "Hooked " << program->m_name << " script (" << HEX_TO_UPPER(static_cast(program)) << ")"; + LOG_IF(G3LOG_DEBUG, g->debug.logs.script_hook_logs) << "Hooked " << program->m_name << " script (" << HEX_TO_UPPER(static_cast(program)) << ")"; } } } diff --git a/BigBaseV2/src/views/debug/views_debug_log.cpp b/BigBaseV2/src/views/debug/views_debug_log.cpp deleted file mode 100644 index 1241c089..00000000 --- a/BigBaseV2/src/views/debug/views_debug_log.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "view_debug.hpp" - -namespace big -{ - void debug::logs() - { - if (ImGui::BeginTabItem("Logs")) - { - ImGui::Checkbox("Log Metrics", &g->debug.logs.metric_logs); - - ImGui::EndTabItem(); - } - } -} \ No newline at end of file diff --git a/BigBaseV2/src/views/debug/views_debug_logs.cpp b/BigBaseV2/src/views/debug/views_debug_logs.cpp new file mode 100644 index 00000000..aad66bdd --- /dev/null +++ b/BigBaseV2/src/views/debug/views_debug_logs.cpp @@ -0,0 +1,41 @@ +#include "gui/components/components.hpp" +#include "services/players/player_service.hpp" +#include "view_debug.hpp" + +namespace big +{ + void debug::logs() + { + if (ImGui::BeginTabItem("Logs")) + { + ImGui::Checkbox("Log Metrics", &g->debug.logs.metric_logs); + + ImGui::Checkbox("Native Script Hooks", &g->debug.logs.script_hook_logs); + + if (ImGui::TreeNode("Script Event Logging")) + { + ImGui::Checkbox("Enable Script Event Logging", &g->debug.logs.script_event.logs); + ImGui::Separator(); + + ImGui::Checkbox("Filter by Player", &g->debug.logs.script_event.filter_player); + + if (g->debug.logs.script_event.filter_player) + { + ImGui::ListBoxHeader("##filter_player"); + for (const auto& [_, player] : g_player_service->players()) + { + if (components::selectable(player->get_name(), g->debug.logs.script_event.player_id == player->id())) + { + g->debug.logs.script_event.player_id = player->id(); + } + } + ImGui::EndListBox(); + } + + ImGui::TreePop(); + } + + ImGui::EndTabItem(); + } + } +} \ No newline at end of file