Fixed send chat logic (#2874)
Command reports will now only be sent to the command user
This commit is contained in:
parent
cfb011d192
commit
a5a5b07984
@ -26,7 +26,7 @@ namespace big
|
|||||||
|
|
||||||
void chat_command_context::report_output(const std::string& output) const
|
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
|
void chat_command_context::report_error(const std::string& error) const
|
||||||
|
@ -216,18 +216,29 @@ namespace big::chat
|
|||||||
// set target to send to a specific player
|
// 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)
|
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{};
|
packet msg{};
|
||||||
msg.write_message(rage::eNetMessage::MsgTextMessage);
|
msg.write_message(rage::eNetMessage::MsgTextMessage);
|
||||||
msg.m_buffer.WriteString(message.c_str(), 256);
|
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);
|
gamer_handle_serialize(g_player_service->get_self()->get_net_data()->m_gamer_handle, msg.m_buffer);
|
||||||
msg.write<bool>(is_team, 1);
|
msg.write<bool>(is_team, 1);
|
||||||
|
|
||||||
if (*g_pointers->m_gta.m_is_session_started)
|
|
||||||
for (auto& player : g_player_service->players())
|
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())
|
if (player.second && player.second->is_valid())
|
||||||
&& (!is_team || is_on_same_team(player.second->get_net_game_player())))
|
{
|
||||||
|
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);
|
msg.send(player.second->get_net_game_player()->m_msg_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (draw)
|
if (draw)
|
||||||
if (rage::tlsContext::get()->m_is_script_thread_active)
|
if (rage::tlsContext::get()->m_is_script_thread_active)
|
||||||
|
Reference in New Issue
Block a user