From 59d4c281439e0a00539a7612491bca46e2a1c4b2 Mon Sep 17 00:00:00 2001 From: Gaben <102860272+GabenManPowered@users.noreply.github.com> Date: Sat, 2 Apr 2022 13:59:38 +0200 Subject: [PATCH 1/7] Allow ROOT flag to call public votes This patch allow ROOT flag to call votes even if a delay is set. Its nice to have the possibility to set a delay betweens votes to limit public votes. Generally, we do this when we have lots of admins. But as a ROOT flag this limit shall no be set. --- plugins/funvotes.sp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/funvotes.sp b/plugins/funvotes.sp index 7aaabc95e6..6f1f85e3dc 100644 --- a/plugins/funvotes.sp +++ b/plugins/funvotes.sp @@ -308,8 +308,13 @@ void VoteSelect(Menu menu, int param1, int param2 = 0) bool TestVoteDelay(int client) { + if (CheckCommandAccess(client, "sm_vote_access", ADMFLAG_ROOT, true)) + { + return true; + } + int delay = CheckVoteDelay(); - + if (delay > 0) { if (delay > 60) From cdd41639dab4994d271f01a7546b1b9cb6c8f92d Mon Sep 17 00:00:00 2001 From: Gaben <102860272+GabenManPowered@users.noreply.github.com> Date: Sat, 2 Apr 2022 14:01:14 +0200 Subject: [PATCH 2/7] Allow ROOT flag to call public votes This patch allow ROOT flag to call votes even if a delay is set. Its nice to have the possibility to set a delay betweens votes to limit public votes. Generally, we do this when we have lots of admins. But as a ROOT flag this limit shall no be set. --- plugins/basevotes.sp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/basevotes.sp b/plugins/basevotes.sp index c09f16d9be..a6c9d677ff 100644 --- a/plugins/basevotes.sp +++ b/plugins/basevotes.sp @@ -406,8 +406,13 @@ void VoteSelect(Menu menu, int param1, int param2 = 0) bool TestVoteDelay(int client) { + if (CheckCommandAccess(client, "sm_vote_access", ADMFLAG_ROOT, true)) + { + return true; + } + int delay = CheckVoteDelay(); - + if (delay > 0) { if (delay > 60) From 3388fc73b199f88a34bc14a4e92e0feca10984af Mon Sep 17 00:00:00 2001 From: Gaben <102860272+GabenManPowered@users.noreply.github.com> Date: Sun, 10 Apr 2022 21:39:48 +0200 Subject: [PATCH 3/7] Update funvotes.sp --- plugins/funvotes.sp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/funvotes.sp b/plugins/funvotes.sp index 6f1f85e3dc..6edbe42a56 100644 --- a/plugins/funvotes.sp +++ b/plugins/funvotes.sp @@ -308,7 +308,7 @@ void VoteSelect(Menu menu, int param1, int param2 = 0) bool TestVoteDelay(int client) { - if (CheckCommandAccess(client, "sm_vote_access", ADMFLAG_ROOT, true)) + if (CheckCommandAccess(client, "sm_vote_delay_bypass", ADMFLAG_CONVARS, true)) { return true; } From ee6343d5ef3f9ec09386fd383d59e38ff43c9f60 Mon Sep 17 00:00:00 2001 From: Gaben <102860272+GabenManPowered@users.noreply.github.com> Date: Sun, 10 Apr 2022 21:39:53 +0200 Subject: [PATCH 4/7] Update basevotes.sp --- plugins/basevotes.sp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/basevotes.sp b/plugins/basevotes.sp index a6c9d677ff..f19bd07ab4 100644 --- a/plugins/basevotes.sp +++ b/plugins/basevotes.sp @@ -406,7 +406,7 @@ void VoteSelect(Menu menu, int param1, int param2 = 0) bool TestVoteDelay(int client) { - if (CheckCommandAccess(client, "sm_vote_access", ADMFLAG_ROOT, true)) + if (CheckCommandAccess(client, "sm_vote_delay_bypass", ADMFLAG_CONVARS, true)) { return true; } From 05d75726ce8f536d6b98929b50b30a1f4b682340 Mon Sep 17 00:00:00 2001 From: Gaben <102860272+GabenManPowered@users.noreply.github.com> Date: Mon, 18 Apr 2022 18:49:08 +0200 Subject: [PATCH 5/7] Add OnKickClient() forward This forward allow kick to be detected (ie catch kick reason) or block kicking process. --- plugins/include/clients.inc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/include/clients.inc b/plugins/include/clients.inc index e9f43ef7fe..8fec6d590c 100644 --- a/plugins/include/clients.inc +++ b/plugins/include/clients.inc @@ -234,6 +234,15 @@ forward void OnClientPostAdminCheck(int client); */ forward void OnClientLanguageChanged(int client, int language); +/** + * Called for calls to KickClient(). + * + * @param client Client being kicked. + * @param reason Reason passed via KickClient(). + * @return Plugin_Handled to block the actual server kicking. + */ +forward Action OnKickClient(int client, const char[] reason); + /** * This function is deprecated. Use the MaxClients variable instead. * From ebe68f8d3952fda7b80cc0eaa4b94db9fd8e2bae Mon Sep 17 00:00:00 2001 From: Gaben <102860272+GabenManPowered@users.noreply.github.com> Date: Mon, 18 Apr 2022 18:54:14 +0200 Subject: [PATCH 6/7] Add OnKickClient() forward This forward allow kick to be detected (ie catch kick reason) or block kicking process. --- core/PlayerManager.cpp | 44 ++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index 95b92ee9e0..103c36292a 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -59,6 +59,7 @@ bool g_OnMapStarted = false; IForward *PreAdminCheck = NULL; IForward *PostAdminCheck = NULL; IForward *PostAdminFilter = NULL; +IForward *OnKickClient = NULL; const unsigned int *g_NumPlayersToAuth = NULL; int lifestate_offset = -1; @@ -203,6 +204,8 @@ void PlayerManager::OnSourceModAllInitialized() PreAdminCheck = forwardsys->CreateForward("OnClientPreAdminCheck", ET_Event, 1, p1); PostAdminCheck = forwardsys->CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1); PostAdminFilter = forwardsys->CreateForward("OnClientPostAdminFilter", ET_Ignore, 1, p1); + + OnKickClient = forwardsys->CreateForward("OnKickClient", ET_Event, 2, NULL, Param_Cell, Param_String); m_bIsListenServer = !engine->IsDedicatedServer(); m_ListenClient = 0; @@ -254,6 +257,8 @@ void PlayerManager::OnSourceModShutdown() forwardsys->ReleaseForward(PreAdminCheck); forwardsys->ReleaseForward(PostAdminCheck); forwardsys->ReleaseForward(PostAdminFilter); + + forwardsys->ReleaseForward(OnKickClient); delete [] m_Players; @@ -2468,25 +2473,40 @@ void CPlayer::DumpAdmin(bool deleting) void CPlayer::Kick(const char *str) { - MarkAsBeingKicked(); IClient *pClient = GetIClient(); - if (pClient == nullptr) + + int userid = GetUserId(); + + cell_t handled = 0; + + if (OnKickClient->GetFunctionCount() > 0) { - int userid = GetUserId(); - if (userid > 0) - { - char buffer[255]; - ke::SafeSprintf(buffer, sizeof(buffer), "kickid %d %s\n", userid, str); - engine->ServerCommand(buffer); - } + OnKickClient->PushCell(g_Players.GetClientOfUserId(userid)); + OnKickClient->PushString(str); + OnKickClient->Execute(&handled); } - else + + if (!handled) { + MarkAsBeingKicked(); + + if (pClient == nullptr) + { + if (userid > 0) + { + char buffer[255]; + ke::SafeSprintf(buffer, sizeof(buffer), "kickid %d %s\n", userid, str); + engine->ServerCommand(buffer); + } + } + else + { #if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE - pClient->Disconnect(str); + pClient->Disconnect(str); #else - pClient->Disconnect("%s", str); + pClient->Disconnect("%s", str); #endif + } } } From 8151e1e2c649d85849616ce0a053a9f73af38678 Mon Sep 17 00:00:00 2001 From: Gaben <102860272+GabenManPowered@users.noreply.github.com> Date: Mon, 18 Apr 2022 19:07:02 +0200 Subject: [PATCH 7/7] Use KickClient instead of kickid Use KickClient instead of kickid --- plugins/basevotes.sp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/basevotes.sp b/plugins/basevotes.sp index f19bd07ab4..2b87db1349 100644 --- a/plugins/basevotes.sp +++ b/plugins/basevotes.sp @@ -346,7 +346,7 @@ public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int pa PrintToChatAll("[SM] %t", "Kicked target", "_s", g_voteInfo[VOTE_NAME]); LogAction(-1, voteTarget, "Vote kick successful, kicked \"%L\" (reason \"%s\")", voteTarget, g_voteArg); - ServerCommand("kickid %d \"%s\"", g_voteTarget, g_voteArg); + KickClient(voteTarget, "%s", g_voteArg); } }