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)
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;
}
{
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
{
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
{
// 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
{
}
}
}
- 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
}