]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add an argument to spectate command, to allow spectating specific players
authorMario <mario@smbclan.net>
Wed, 8 Feb 2017 17:26:04 +0000 (03:26 +1000)
committerMario <mario@smbclan.net>
Wed, 8 Feb 2017 17:26:04 +0000 (03:26 +1000)
commands.cfg
qcsrc/server/command/cmd.qc

index a8de9b95cb842512272a49bed77a2c1e4b026d6a..93b68f901e57154ec7512a2d98830fce7ec168ad 100644 (file)
@@ -172,7 +172,7 @@ alias team_pink "cmd selectteam pink; cmd join"
 alias team_yellow "cmd selectteam yellow; cmd join"
 alias team_auto "cmd selectteam auto; cmd join"
 
-alias spec "spectate"
+alias spec "spectate ${* ?}"
 
 // mutator aliases
 alias sandbox "cmd g_sandbox ${* ?}"
index 1fa600e65f784cab827dfce8507255157fef8eb2..a4145abef0b10cfd658667fbadb3b6bf36600563 100644 (file)
@@ -473,6 +473,17 @@ void ClientCommand_spectate(entity caller, float request)
                {
                        if (!intermission_running && IS_CLIENT(caller))
                        {
+                               if((IS_SPEC(caller) || IS_OBSERVER(caller)) && argv(1) != "")
+                               {
+                                       entity client = GetFilteredEntity(argv(1));
+                                       int spec_accepted = VerifyClientEntity(client, false, false);
+                                       if(spec_accepted > 0 && IS_PLAYER(client))
+                                       {
+                                               if(Spectate(caller, client))
+                                                       return; // fall back to regular handling
+                                       }
+                               }
+
                                int mutator_returnvalue = MUTATOR_CALLHOOK(ClientCommand_Spectate, caller);
 
                                if (mutator_returnvalue == MUT_SPECCMD_RETURN) return;
@@ -487,8 +498,8 @@ void ClientCommand_spectate(entity caller, float request)
                default:
                case CMD_REQUEST_USAGE:
                {
-                       sprint(caller, "\nUsage:^3 cmd spectate\n");
-                       sprint(caller, "  No arguments required.\n");
+                       sprint(caller, "\nUsage:^3 cmd spectate <client>\n");
+                       sprint(caller, "  Where 'client' can be the player to spectate.\n");
                        return;
                }
        }