]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
spec command: add support for "0" argument
authorbones_was_here <bones_was_here@xonotic.au>
Fri, 11 Apr 2025 08:20:28 +0000 (18:20 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Fri, 2 May 2025 09:07:33 +0000 (19:07 +1000)
This returns to observing without leaving the join queue or CA team
(like +attack2).

qcsrc/server/command/cmd.qc

index bb118f888aa86045bbf751662aa13c2c6403b7e2..1663fe17bde1879d72e2c51babf47480558763fd 100644 (file)
@@ -752,7 +752,17 @@ void ClientCommand_spectate(entity caller, int request)
                        {
                                if(argv(1) != "")
                                {
-                                       if(IS_SPEC(caller) || IS_OBSERVER(caller))
+                                       if (!(IS_SPEC(caller) || IS_OBSERVER(caller)))
+                                               sprint(caller, "cmd spectate <client> only works when you are spectator/observer\n");
+                                       else if (argv(1) == "0")
+                                       { // switch back to observing without leaving the CA team or join queue (like +attack2)
+                                               if (!IS_OBSERVER(caller))
+                                               {
+                                                       TRANSMUTE(Observer, caller);
+                                                       PutClientInServer(caller);
+                                               }
+                                       }
+                                       else
                                        {
                                                entity client = GetFilteredEntity(argv(1));
                                                float spec_accepted = VerifyClientEntity(client, false, false);
@@ -766,8 +776,6 @@ void ClientCommand_spectate(entity caller, int request)
                                                else
                                                        sprint(caller, "Can't spectate ", argv(1), "^7\n");
                                        }
-                                       else
-                                               sprint(caller, "cmd spectate <client> only works when you are spectator/observer\n");
                                        return;
                                }