diff --git a/src/backend/context/chat_command_context.cpp b/src/backend/context/chat_command_context.cpp index 5e7f88c9..1c851685 100644 --- a/src/backend/context/chat_command_context.cpp +++ b/src/backend/context/chat_command_context.cpp @@ -26,7 +26,7 @@ namespace big void chat_command_context::report_output(const std::string& output) const { - chat::send_message(output); + chat::send_message(output, this->get_sender(), true, true); } void chat_command_context::report_error(const std::string& error) const diff --git a/src/util/chat.hpp b/src/util/chat.hpp index db38f0e8..d4b7274e 100644 --- a/src/util/chat.hpp +++ b/src/util/chat.hpp @@ -216,18 +216,29 @@ namespace big::chat // set target to send to a specific player inline void send_message(const std::string& message, player_ptr target = nullptr, bool draw = true, bool is_team = false) { + if (!*g_pointers->m_gta.m_is_session_started) + return; + packet msg{}; msg.write_message(rage::eNetMessage::MsgTextMessage); msg.m_buffer.WriteString(message.c_str(), 256); gamer_handle_serialize(g_player_service->get_self()->get_net_data()->m_gamer_handle, msg.m_buffer); msg.write(is_team, 1); - if (*g_pointers->m_gta.m_is_session_started) - for (auto& player : g_player_service->players()) - if (player.second && player.second->is_valid() - && (!target || target->get_net_game_player() == player.second->get_net_game_player()) - && (!is_team || is_on_same_team(player.second->get_net_game_player()))) - msg.send(player.second->get_net_game_player()->m_msg_id); + + for (auto& player : g_player_service->players()) + { + if (player.second && player.second->is_valid()) + { + if (target && player.second != target) + continue; + + if (!target && is_team && !is_on_same_team(player.second->get_net_game_player())) + continue; + + msg.send(player.second->get_net_game_player()->m_msg_id); + } + } if (draw) if (rage::tlsContext::get()->m_is_script_thread_active)