Less noticeable multi-kick => smart-kick (#3066)

This commit is contained in:
Muhammad007228 2024-05-10 12:51:14 +03:00 committed by GitHub
parent 3a7cad7f72
commit dada469c55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 23 additions and 22 deletions

View File

@ -20,7 +20,7 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{ {
if (!player || !g_player_service->get_self()->is_host() || !player->get_net_data()) if (!player || !g_player_service->get_self()->is_host() || !player->get_net_data() || !player->is_valid())
return; return;
rage::snMsgRemoveGamersFromSessionCmd cmd{}; rage::snMsgRemoveGamersFromSessionCmd cmd{};

View File

@ -17,7 +17,7 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{ {
if (!player) if (!player || !player->is_valid())
return; return;
if (!scripts::force_host("freemode"_J)) if (!scripts::force_host("freemode"_J))
{ {

View File

@ -14,7 +14,7 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{ {
if (!player) if (!player || !player->is_valid())
return; return;
if (!g_player_service->get_self()->is_host()) if (!g_player_service->get_self()->is_host())
{ {

View File

@ -20,7 +20,7 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{ {
if (!player) if (!player || !player->is_valid())
return; return;
packet msg{}; packet msg{};

View File

@ -17,7 +17,7 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{ {
if (!player) if (!player || !player->is_valid())
return; return;
if (!scripts::force_host("freemode"_J)) if (!scripts::force_host("freemode"_J))
{ {

View File

@ -6,7 +6,7 @@
namespace big namespace big
{ {
class multi_kick : player_command class smart_kick : player_command
{ {
using player_command::player_command; using player_command::player_command;
@ -18,17 +18,18 @@ namespace big
virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override virtual void execute(player_ptr player, const command_arguments& _args, const std::shared_ptr<command_context> ctx) override
{ {
if (g_player_service->get_self()->is_host()) if (g_player_service->get_self()->is_host())
dynamic_cast<player_command*>(command::get("breakup"_J))->call(player, {}), {
dynamic_cast<player_command*>(command::get("hostkick"_J))->call(player, {}); dynamic_cast<player_command*>(command::get("breakup"_J))->call(player, {});
}
dynamic_cast<player_command*>(command::get("oomkick"_J))->call(player, {}); else
script::get_current()->yield(700ms); {
if (player->is_host())
dynamic_cast<player_command*>(command::get("oomkick"_J))->call(player, {});
if (player && !g_player_service->get_self()->is_host() && player->is_valid() && !player->is_host()) else
dynamic_cast<player_command*>(command::get("desync"_J))->call(player, {}); dynamic_cast<player_command*>(command::get("desync"_J))->call(player, {});
}
} }
}; };
multi_kick g_multi_kick("multikick", "MULTI_KICK", "MULTI_KICK_DESC", 0, false); smart_kick g_smart_kick("smartkick", "SMART_KICK", "SMART_KICK_DESC", 0, false);
} }

View File

@ -18,7 +18,7 @@ namespace big
if (plyr.second->is_host()) if (plyr.second->is_host())
{ {
dynamic_cast<player_command*>(command::get("multikick"_J))->call(plyr.second, {}); dynamic_cast<player_command*>(command::get("smartkick"_J))->call(plyr.second, {});
} }
}); });
} }

View File

@ -33,7 +33,7 @@ namespace big
if (kick) if (kick)
{ {
g_fiber_pool->queue_job([player] { g_fiber_pool->queue_job([player] {
dynamic_cast<player_command*>(command::get("multikick"_J))->call(player, {}); dynamic_cast<player_command*>(command::get("smartkick"_J))->call(player, {});
}); });
} }

View File

@ -136,7 +136,7 @@ namespace big
} }
else else
{ {
dynamic_cast<player_command*>(command::get("multikick"_J))->call(plyr, {}); dynamic_cast<player_command*>(command::get("smartkick"_J))->call(plyr, {});
g_notification_service.push_warning("LOBBY_LOCK"_T.data(), g_notification_service.push_warning("LOBBY_LOCK"_T.data(),
std::vformat("LOBBY_LOCK_DENIED"_T.data(), std::make_format_args(plyr->get_net_data()->m_name))); std::vformat("LOBBY_LOCK_DENIED"_T.data(), std::make_format_args(plyr->get_net_data()->m_name)));
} }

View File

@ -129,7 +129,7 @@ namespace big
if (g.session.kick_chat_spammers if (g.session.kick_chat_spammers
&& !(player->is_trusted || (player->is_friend() && g.session.trust_friends) || g.session.trust_session)) && !(player->is_trusted || (player->is_friend() && g.session.trust_friends) || g.session.trust_session))
{ {
dynamic_cast<player_command*>(command::get("multikick"_J))->call(player, {}); dynamic_cast<player_command*>(command::get("smartkick"_J))->call(player, {});
} }
return true; return true;
} }

View File

@ -204,7 +204,7 @@ namespace big
}}, }},
{"KICK", {"KICK",
[this] { [this] {
static player_command* command = dynamic_cast<player_command*>(command::get("multikick"_J)); static player_command* command = dynamic_cast<player_command*>(command::get("smartkick"_J));
command->call(ped::get_player_from_ped(m_handle), {}); command->call(ped::get_player_from_ped(m_handle), {});
script::get_current()->yield(500ms); script::get_current()->yield(500ms);
}}, }},

View File

@ -27,7 +27,7 @@ namespace big
ImGui::SameLine(); ImGui::SameLine();
components::command_checkbox<"breakupcheating">(); components::command_checkbox<"breakupcheating">();
components::player_command_button<"multikick">(g_player_service->get_selected()); components::player_command_button<"smartkick">(g_player_service->get_selected());
ImGui::SameLine(); ImGui::SameLine();
components::player_command_button<"oomkick">(g_player_service->get_selected()); components::player_command_button<"oomkick">(g_player_service->get_selected());