From abfe61a1a783f07b7f98bddf25476b5e619317ab Mon Sep 17 00:00:00 2001 From: z411 Date: Mon, 19 Apr 2021 01:09:02 -0400 Subject: [PATCH] Own Kick implementation (just to show a notification, really) --- qcsrc/server/command/banning.qc | 44 +++++++++++++++++++++++++++++++++ qcsrc/server/command/vote.qc | 6 ++++- qcsrc/server/ipban.qc | 8 ++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/qcsrc/server/command/banning.qc b/qcsrc/server/command/banning.qc index a73b09646..b38b13510 100644 --- a/qcsrc/server/command/banning.qc +++ b/qcsrc/server/command/banning.qc @@ -72,6 +72,49 @@ void BanCommand_banlist(int request) } } +void BanCommand_kickkick(int request, int argc, string command) +{ + switch (request) + { + case CMD_REQUEST_COMMAND: + { + if (argc >= 2) + { + entity client = GetIndexedEntity(argc, 1); + float accepted = VerifyKickableEntity(client); + float reason_arg; + string reason; + + if (accepted > 0) + { + reason_arg = next_token; + + GET_BAN_REASON(reason, "No reason provided"); + + Ban_KickClient(client, reason); + + return; + } + else + { + LOG_INFO("kick: ", GetClientErrorString(accepted, argv(1)), "."); + } + } + } + + default: + LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0)); + case CMD_REQUEST_USAGE: + { + LOG_HELP("Usage:^3 sv_cmd kickkick []"); + LOG_HELP(" is the entity number or name of the player to kick,"); + LOG_HELP(" and is the string to label the ban with as reason for kicking."); + LOG_HELP("See also: ^2kick^7"); + return; + } + } +} + void BanCommand_kickban(int request, int argc, string command) { switch (request) @@ -267,6 +310,7 @@ void BanCommand_(int request) #define BAN_COMMANDS(request, arguments, command) \ BAN_COMMAND("ban", BanCommand_ban(request, arguments, command), "Ban an IP address or a range of addresses (like 1.2.3)") \ BAN_COMMAND("banlist", BanCommand_banlist(request), "List all existing bans") \ + BAN_COMMAND("kickkick", BanCommand_kickkick(request, arguments, command), "Disconnect a client") \ BAN_COMMAND("kickban", BanCommand_kickban(request, arguments, command), "Disconnect a client and ban it at the same time") \ BAN_COMMAND("mute", BanCommand_mute(request, arguments, command), "Disallow a client from talking by muting them") \ BAN_COMMAND("unban", BanCommand_unban(request, arguments), "Remove an existing ban") \ diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 032f871df..602fe36ce 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -726,7 +726,11 @@ int VoteCommand_parse(entity caller, string vote_command, string vote_list, floa if (first_command == "kickban") command_arguments = strcat(ftos(autocvar_g_ban_default_bantime), " ", ftos(autocvar_g_ban_default_masksize), " ~"); - vote_parsed_command = strcat("defer 2 \"", first_command, " # ", ftos(etof(victim)), " ", command_arguments, "\""); + if (first_command == "kick") // z411 : Use our kick implementation - kind of hacky... + vote_parsed_command = strcat("defer 2 \"sv_cmd kickkick # ", ftos(etof(victim)), " ", command_arguments, "\""); + else + vote_parsed_command = strcat("defer 2 \"", first_command, " # ", ftos(etof(victim)), " ", command_arguments, "\""); + vote_parsed_display = sprintf("^1%s #%d ^7%s^1 %s", first_command, etof(victim), victim.netname, reason); } else { print_to(caller, strcat("vcall: ", GetClientErrorString(accepted, argv(startpos + 1)), ".\n")); return 0; } diff --git a/qcsrc/server/ipban.qc b/qcsrc/server/ipban.qc index b9ad08873..a889e6b92 100644 --- a/qcsrc/server/ipban.qc +++ b/qcsrc/server/ipban.qc @@ -579,12 +579,20 @@ float Ban_Insert(string ip, float bantime, string reason, float dosync) return true; } +void Ban_KickClient(entity client, string reason) +{ + sprint(client, strcat("Kicked: ", reason, "\n")); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_KICK, client.netname); + dropclient(client); +} + void Ban_KickBanClient(entity client, float bantime, float masksize, string reason) { string ip, id; if(!Ban_GetClientIP(client)) { sprint(client, strcat("Kickbanned: ", reason, "\n")); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_KICK, client.netname); dropclient(client); return; } -- 2.39.2