]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Own Kick implementation (just to show a notification, really)
authorz411 <z411@omaera.org>
Mon, 19 Apr 2021 05:09:02 +0000 (01:09 -0400)
committerz411 <z411@omaera.org>
Mon, 19 Apr 2021 05:09:02 +0000 (01:09 -0400)
qcsrc/server/command/banning.qc
qcsrc/server/command/vote.qc
qcsrc/server/ipban.qc

index a73b09646f983467c7d5efa59d1ebc7896db5d1b..b38b13510eb204ebbbc092632ec581942c0f9409 100644 (file)
@@ -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 <client> [<reason>]");
+                       LOG_HELP("  <client> is the entity number or name of the player to kick,");
+                       LOG_HELP("  and <reason> 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") \
index 032f871df84a94efc1773f77ef2b72513b50f18b..602fe36cecbf86efa66cbf5884987d46e129cc18 100644 (file)
@@ -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; }
index b9ad08873ee005a5be54b9413a4adda6062fcb13..a889e6b929368e535169fff52ec7d9b00f973f03 100644 (file)
@@ -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;
        }