From 6c50a1a66a228832ce927247df1faf0471009ea5 Mon Sep 17 00:00:00 2001 From: Samual Date: Sat, 5 Nov 2011 13:54:31 -0400 Subject: [PATCH] Updates to moveplayer command, plus beginning of new feature which allows players to supply both #1 and 1 to refer to entity 1. --- qcsrc/server/gamecommand.qc | 36 ++++++++++++++++++++++++----------- qcsrc/server/miscfunctions.qc | 13 +++++++++++++ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/qcsrc/server/gamecommand.qc b/qcsrc/server/gamecommand.qc index bc2191333..cb93e3ef3 100644 --- a/qcsrc/server/gamecommand.qc +++ b/qcsrc/server/gamecommand.qc @@ -1005,10 +1005,14 @@ void GameCommand_modelbug(float request) // UNTESTED // is this even needed anym void GameCommand_moveplayer(float request, float argc) { entity client; + string targets = argv(1); string destination = argv(2); string notify = argv(3); + string successful; + float i; + argc = tokenizebyseparator(targets, ","); // re-use argc for the targets switch(request) @@ -1024,15 +1028,15 @@ void GameCommand_moveplayer(float request, float argc) for(i = 0; i < argc; ++i) { // Check to see if the player is a valid target - if((stof(argv(i)) < 1) | (stof(argv(i)) > maxclients)) // player_id is out of range + if((GetFilteredNumber(argv(i)) < 1) || (GetFilteredNumber(argv(i)) > maxclients)) // player_id is out of range { - print(strcat("Player ", argv(i), " doesn't exist", (((i + 1) < argc) ? ", skipping to next player.\n" : ".\n"))); + print("Player ", ftos(GetFilteredNumber(argv(i))), " doesn't exist (out of range)", (((i + 1) < argc) ? ", skipping to next player.\n" : ".\n")); continue; } - client = edict_num(stof(argv(i))); + client = edict_num(GetFilteredNumber(argv(i))); if not(client.flags & FL_CLIENT) // player entity is not a client { - print(strcat("Player ", argv(i), " doesn't exist", (((i + 1) < argc) ? ", skipping to next player.\n" : ".\n"))); + print("Player ", ftos(GetFilteredNumber(argv(i))), " doesn't exist (not a client)", (((i + 1) < argc) ? ", skipping to next player.\n" : ".\n")); continue; } @@ -1043,12 +1047,14 @@ void GameCommand_moveplayer(float request, float argc) { self = client; PutObserverInServer(); + + successful = strcat(successful, (successful ? ", " : ""), client.netname); } else { - print("Player ", argv(i), " (", client.netname, ") is already spectating.\n"); + print("Player ", ftos(GetFilteredNumber(argv(i))), " (", client.netname, ") is already spectating.\n"); } - return; + continue; } else { @@ -1066,8 +1072,8 @@ void GameCommand_moveplayer(float request, float argc) if(team_color == client.team) // already on the destination team { // keep the forcing undone - print("Player ", argv(i), " (", client.netname, ") is already on the ", ColoredTeamName(client.team), ".\n"); - return; + print("Player ", ftos(GetFilteredNumber(argv(i))), " (", client.netname, ") is already on the ", ColoredTeamName(client.team), (((i + 1) < argc) ? ", skipping to next player.\n" : ".\n")); + continue; } else if(team_color == 0) // auto team { @@ -1118,8 +1124,11 @@ void GameCommand_moveplayer(float request, float argc) // If so, lets continue and finally move the player client.team_forced = 0; MoveToTeam(client, team_color, 6, stof(notify)); - print("Player ", argv(i), " (", client.netname, ") has been moved to the ", ColoredTeamName(team_color), ".\n"); - return; + print("Player ", ftos(GetFilteredNumber(argv(i))), " (", client.netname, ") has been moved to the ", ColoredTeamName(team_color), ".\n"); + + successful = strcat(successful, (successful ? ", " : ""), client.netname); + + //if((i + 1) < argc) { continue; } // keep going with the loop, there are more players to parse through } else { @@ -1134,7 +1143,12 @@ void GameCommand_moveplayer(float request, float argc) } } } - print("No acceptable players given, aborting.\n"); + + if(successful) + print("Successfully moved players ", successful, " to destination ", destination, ".\n"); + else + print("No players given (", targets, ") are able to move.\n"); + return; // still correct parameters so return to avoid usage print } diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 2fe562774..d9c5589a7 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -3135,3 +3135,16 @@ float isPushable(entity e) return TRUE; return FALSE; } + +float GetFilteredNumber(string input) +{ + float output; + + if(substring(input, 0, 1) == "#") + output = stof(substring(input, 1, -1)); + else + output = stof(input); + + print(strcat("input: ", input, ", output: ", ftos(output), ",\n")); + return output; +} -- 2.39.2