1 // =========================================================
2 // Server side networked commands code, reworked by Samual
3 // Last updated: December 11th, 2011
4 // =========================================================
6 #define CC_REQUEST_COMMAND 1
7 #define CC_REQUEST_USAGE 2
10 .float cmd_floodcount;
12 .float lms_spectate_warning;
14 string MapVote_Suggest(string m);
15 //void MapVote_SendPicture(float id)
17 // move any necessary sprint statements to "print_to"
19 // ============================
20 // Misc. Supporting Functions
21 // ============================
23 float SV_ParseClientCommand_floodcheck()
25 if (timeoutStatus != 2) // if the game is not paused... but wait, doesn't that mean it could be dos'd by pausing it? eh? (old code)
27 if(time <= (self.cmd_floodtime + autocvar_sv_clientcommand_antispam_time))
29 self.cmd_floodcount += 1;
30 if(self.cmd_floodcount > autocvar_sv_clientcommand_antispam_count) { return FALSE; } // too much spam, halt
34 self.cmd_floodtime = time;
35 self.cmd_floodcount = 1;
38 return TRUE; // continue, as we're not flooding yet
42 // =======================
43 // Command Sub-Functions
44 // =======================
46 void ClientCommand_autoswitch(float request, float argc)
50 case CC_REQUEST_COMMAND:
52 self.autoswitch = ("0" != argv(1));
53 sprint(self, strcat("^1autoswitch is currently turned ", (self.autoswitch ? "on" : "off"), ".\n"));
54 return; // never fall through to usage
58 case CC_REQUEST_USAGE:
60 sprint(self, "\nUsage:^3 cmd autoswitch selection\n");
61 sprint(self, " Where 'selection' is 1 or 0 for on or off.\n");
67 void ClientCommand_checkfail(float request, string command) // used only by client side code
71 case CC_REQUEST_COMMAND:
73 print(sprintf("CHECKFAIL: %s (%s) epically failed check %s\n", self.netname, self.netaddress, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1))));
75 return; // never fall through to usage
79 case CC_REQUEST_USAGE:
81 sprint(self, "\nUsage:^3 cmd checkfail message\n");
82 sprint(self, " Where 'message' is the message reported by client about the fail.\n");
88 void ClientCommand_clientversion(float request, float argc) // used only by client side code
92 case CC_REQUEST_COMMAND:
94 if(self.flags & FL_CLIENT)
96 self.version = ((argv(1) == "$gameversion") ? 1 : stof(argv(1)));
98 if(self.version < autocvar_gameversion_min || self.version > autocvar_gameversion_max)
100 self.version_mismatch = 1;
101 ClientKill_TeamChange(-2); // observe
103 else if(autocvar_g_campaign || autocvar_g_balance_teams || autocvar_g_balance_teams_force)
105 //JoinBestTeam(self, FALSE, TRUE);
107 else if(teamplay && !autocvar_sv_spectate && !(self.team_forced > 0))
109 self.classname = "observer"; // really?
110 stuffcmd(self, "menu_showteamselect\n");
113 return; // never fall through to usage
117 case CC_REQUEST_USAGE:
119 sprint(self, "\nUsage:^3 cmd clientversion version\n");
120 sprint(self, " Where 'version' is the game version reported by self.\n");
126 void ClientCommand_cvar_changes(float request)
130 case CC_REQUEST_COMMAND:
132 sprint(self, cvar_changes);
133 return; // never fall through to usage
137 case CC_REQUEST_USAGE:
139 sprint(self, "\nUsage:^3 sv_cmd cvar_changes\n");
140 sprint(self, " No arguments required.\n");
141 //sprint(self, "See also: ^2cvar_purechanges^7\n");
147 void ClientCommand_cvar_purechanges(float request)
151 case CC_REQUEST_COMMAND:
153 sprint(self, cvar_purechanges);
154 return; // never fall through to usage
158 case CC_REQUEST_USAGE:
160 sprint(self, "\nUsage:^3 sv_cmd cvar_purechanges\n");
161 sprint(self, " No arguments required.\n");
162 //sprint(self, "See also: ^2cvar_changes^7\n");
168 void ClientCommand_getmapvotepic(float request, float argc)
172 case CC_REQUEST_COMMAND:
174 if(intermission_running)
175 MapVote_SendPicture(stof(argv(1)));
177 return; // never fall through to usage
181 case CC_REQUEST_USAGE:
183 sprint(self, "\nUsage:^3 cmd getmapvotepic mapid\n");
184 sprint(self, " Where 'mapid' is the id number of the map to request an image of on the map vote selection menu.\n");
190 void ClientCommand_info(float request, float argc)
194 case CC_REQUEST_COMMAND:
198 command = builtin_cvar_string(strcat("sv_info_", argv(1)));
200 wordwrap_sprint(command, 1111); // why 1111?
202 sprint(self, "ERROR: unsupported info command\n");
204 return; // never fall through to usage
208 case CC_REQUEST_USAGE:
210 sprint(self, "\nUsage:^3 cmd info request\n");
211 sprint(self, " Where 'request' is the suffixed string appended onto the request for cvar.\n");
217 void ClientCommand_join(float request)
221 case CC_REQUEST_COMMAND:
223 if(self.flags & FL_CLIENT)
225 if(self.classname != "player" && !lockteams && !g_arena)
229 if(g_ca) { self.caplayer = 1; }
230 if(autocvar_g_campaign) { campaign_bots_may_start = 1; }
232 self.classname = "player";
233 PlayerScore_Clear(self);
234 bprint ("^4", self.netname, "^4 is playing now\n");
239 //player may not join because of g_maxplayers is set
240 centerprint(self, PREVENT_JOIN_TEXT);
244 return; // never fall through to usage
248 case CC_REQUEST_USAGE:
250 sprint(self, "\nUsage:^3 cmd join\n");
251 sprint(self, " No arguments required.\n");
257 void ClientCommand_ladder(float request)
261 case CC_REQUEST_COMMAND:
263 sprint(self, ladder_reply);
264 return; // never fall through to usage
268 case CC_REQUEST_USAGE:
270 sprint(self, "\nUsage:^3 cmd ladder\n");
271 sprint(self, " No arguments required.\n");
277 void ClientCommand_lsmaps(float request)
281 case CC_REQUEST_COMMAND:
283 sprint(self, lsmaps_reply);
284 return; // never fall through to usage
288 case CC_REQUEST_USAGE:
290 sprint(self, "\nUsage:^3 cmd lsmaps\n");
291 sprint(self, " No arguments required.\n");
297 void ClientCommand_lsnewmaps(float request)
301 case CC_REQUEST_COMMAND:
303 sprint(self, lsnewmaps_reply);
304 return; // never fall through to usage
308 case CC_REQUEST_USAGE:
310 sprint(self, "\nUsage:^3 cmd lsnewmaps\n");
311 sprint(self, " No arguments required.\n");
317 void ClientCommand_maplist(float request)
321 case CC_REQUEST_COMMAND:
323 sprint(self, maplist_reply);
324 return; // never fall through to usage
328 case CC_REQUEST_USAGE:
330 sprint(self, "\nUsage:^3 cmd maplist\n");
331 sprint(self, " No arguments required.\n");
337 void ClientCommand_rankings(float request)
341 case CC_REQUEST_COMMAND:
343 sprint(self, rankings_reply);
344 return; // never fall through to usage
348 case CC_REQUEST_USAGE:
350 sprint(self, "\nUsage:^3 cmd rankings\n");
351 sprint(self, " No arguments required.\n");
357 void ClientCommand_ready(float request)
361 case CC_REQUEST_COMMAND:
363 if(self.flags & FL_CLIENT)
365 if(inWarmupStage || autocvar_sv_ready_restart || g_race_qualifying == 2)
367 if(!readyrestart_happened || autocvar_sv_ready_restart_repeatable)
369 if (self.ready) // toggle
372 bprint(self.netname, "^2 is ^1NOT^2 ready\n");
377 bprint(self.netname, "^2 is ready\n");
380 // cannot reset the game while a timeout is active!
384 sprint(self, "^1Game has already been restarted\n");
388 return; // never fall through to usage
392 case CC_REQUEST_USAGE:
394 sprint(self, "\nUsage:^3 cmd ready\n");
395 sprint(self, " No arguments required.\n");
401 void ClientCommand_records(float request) // TODO: Isn't this flooding with the sprint messages? Old code, but perhaps bad?
405 case CC_REQUEST_COMMAND:
409 for(i = 0; i < 10; ++i)
410 sprint(self, records_reply[i]);
412 return; // never fall through to usage
416 case CC_REQUEST_USAGE:
418 sprint(self, "\nUsage:^3 cmd records\n");
419 sprint(self, " No arguments required.\n");
425 void ClientCommand_reportcvar(float request, float argc, string command) // TODO: confirm this works
429 case CC_REQUEST_COMMAND:
434 if(substring(argv(2), 0, 1) == "$") // undefined cvar: use the default value on the server then
436 s = strcat(substring(command, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\"");
437 tokens = tokenize_console(s);
440 return; // never fall through to usage
444 case CC_REQUEST_USAGE:
446 sprint(self, "\nUsage:^3 cmd reportcvar <cvar>\n");
447 sprint(self, " Where 'cvar' is the cvar plus arguments to send to the server.\n");
453 void ClientCommand_say(float request, float argc, string command)
457 case CC_REQUEST_COMMAND:
459 if(argc >= 2) { Say(self, FALSE, world, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1); }
460 return; // never fall through to usage
464 case CC_REQUEST_USAGE:
466 sprint(self, "\nUsage:^3 cmd say <message>\n");
467 sprint(self, " Where 'message' is the string of text to say.\n");
473 void ClientCommand_say_team(float request, float argc, string command)
477 case CC_REQUEST_COMMAND:
479 if(argc >= 2) { Say(self, TRUE, world, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1); }
480 return; // never fall through to usage
484 case CC_REQUEST_USAGE:
486 sprint(self, "\nUsage:^3 cmd say_team <message>\n");
487 sprint(self, " Where 'message' is the string of text to say.\n");
493 void ClientCommand_selectteam(float request, float argc) // TODO: Update the messages for this command
497 case CC_REQUEST_COMMAND:
501 if (self.flags & FL_CLIENT)
504 if not(self.team_forced > 0)
509 case "red": selection = COLOR_TEAM1; break;
510 case "blue": selection = COLOR_TEAM2; break;
511 case "yellow": selection = COLOR_TEAM3; break;
512 case "pink": selection = COLOR_TEAM4; break;
513 case "auto": selection = (-1); break;
520 if(self.team == selection && self.deadflag == DEAD_NO)
521 sprint(self, "^7You already are on that team.\n");
522 else if(self.wasplayer && autocvar_g_changeteam_banned)
523 sprint(self, "^1You cannot change team, forbidden by the server.\n");
525 ClientKill_TeamChange(selection);
529 sprint(self, "^7The game has already begun, you must wait until the next map to be able to join a team.\n");
531 sprint(self, "^7selectteam can not be used as your team is forced\n");
533 sprint(self, "^7selectteam can only be used in teamgames\n");
535 return; // never fall through to usage
539 case CC_REQUEST_USAGE:
541 //sprint(self, strcat( "selectteam none/red/blue/yellow/pink/auto - \"", argv(1), "\" not recognised\n" ) );
542 sprint(self, "\nUsage:^3 cmd selectteam team\n");
543 sprint(self, " Where 'team' is the prefered team to try and join.\n");
544 sprint(self, " Full list of options here: \"red, blue, yellow, pink, auto\"\n");
550 void ClientCommand_selfstuff(float request, string command)
554 case CC_REQUEST_COMMAND:
556 stuffcmd(self, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
557 return; // never fall through to usage
561 case CC_REQUEST_USAGE:
563 sprint(self, "\nUsage:^3 cmd selfstuff command\n");
564 sprint(self, " Where 'command' is the string to be stuffed to your client.\n");
570 void ClientCommand_sentcvar(float request, float argc, string command)
574 case CC_REQUEST_COMMAND:
579 if(argc == 2) // undefined cvar: use the default value on the server then
581 s = strcat(substring(command, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\"");
582 tokens = tokenize_console(s);
585 return; // never fall through to usage
589 case CC_REQUEST_USAGE:
591 sprint(self, "\nUsage:^3 cmd sentcvar <cvar>\n");
592 sprint(self, " Where 'cvar' is the cvar plus arguments to send to the server.\n");
598 void ClientCommand_spectate(float request)
602 case CC_REQUEST_COMMAND:
604 if(self.flags & FL_CLIENT)
606 if(g_arena) { return; }
609 if(self.lms_spectate_warning)
611 // mark player as spectator
612 PlayerScore_Add(self, SP_LMS_RANK, 666 - PlayerScore_Add(self, SP_LMS_RANK, 0));
616 self.lms_spectate_warning = 1;
617 sprint(self, "WARNING: you won't be able to enter the game again after spectating in LMS. Use the same command again to spectate anyway.\n");
622 if(self.classname == "player" && autocvar_sv_spectate == 1)
623 ClientKill_TeamChange(-2); // observe
625 // in CA, allow a dead player to move to spectatators (without that, caplayer!=0 will be moved back to the player list)
626 // note: if arena game mode is ever done properly, this needs to be removed.
627 if(g_ca && self.caplayer && (self.classname == "spectator" || self.classname == "observer"))
629 sprint(self, "WARNING: you will spectate in the next round.\n");
633 return; // never fall through to usage
637 case CC_REQUEST_USAGE:
639 sprint(self, "\nUsage:^3 cmd spectate\n");
640 sprint(self, " No arguments required.\n");
646 void ClientCommand_suggestmap(float request, float argc)
650 case CC_REQUEST_COMMAND:
652 sprint(self, strcat(MapVote_Suggest(argv(1)), "\n"));
653 return; // never fall through to usage
657 case CC_REQUEST_USAGE:
659 sprint(self, "\nUsage:^3 cmd suggestmap map\n");
660 sprint(self, " Where 'map' is the name of the map to suggest.\n");
666 void ClientCommand_teamstatus(float request)
670 case CC_REQUEST_COMMAND:
672 Score_NicePrint(self);
673 return; // never fall through to usage
677 case CC_REQUEST_USAGE:
679 sprint(self, "\nUsage:^3 cmd teamstatus\n");
680 sprint(self, " No arguments required.\n");
686 void ClientCommand_tell(float request, float argc, string command)
690 case CC_REQUEST_COMMAND:
692 entity e = GetCommandPlayerSlotTargetFromTokenizedCommand(argc, 1);
694 if(e && argc > ParseCommandPlayerSlotTarget_firsttoken)
696 Say(self, FALSE, e, substring(command, argv_start_index(ParseCommandPlayerSlotTarget_firsttoken), argv_end_index(-1) - argv_start_index(ParseCommandPlayerSlotTarget_firsttoken)), TRUE);
700 if(argc > ParseCommandPlayerSlotTarget_firsttoken)
701 trigger_magicear_processmessage_forallears(self, -1, world, substring(command, argv_start_index(ParseCommandPlayerSlotTarget_firsttoken), argv_end_index(-1) - argv_start_index(ParseCommandPlayerSlotTarget_firsttoken)));
703 return; // never fall through to usage
707 case CC_REQUEST_USAGE:
709 sprint(self, "\nUsage:^3 cmd tell playerid <message>\n");
710 sprint(self, " Where 'playerid' is the entity number of the player to send the 'message' to.\n");
716 void ClientCommand_timein(float request)
720 case CC_REQUEST_COMMAND:
722 if(self.flags & FL_CLIENT)
724 if(autocvar_sv_timeout)
727 return sprint(self, "^7Error: There is no active timeout which could be aborted!\n");
728 if (self != timeoutInitiator)
729 return sprint(self, "^7Error: You may not abort the active timeout. Only the player who called it can do that!\n");
731 if (timeoutStatus == 1)
733 remainingTimeoutTime = timeoutStatus = 0;
734 timeoutHandler.nextthink = time; //timeoutHandler has to take care of it immediately
735 bprint(strcat("^7The timeout was aborted by ", self.netname, " !\n"));
737 else if (timeoutStatus == 2)
739 //only shorten the remainingTimeoutTime if it makes sense
740 if( remainingTimeoutTime > (autocvar_sv_timeout_resumetime + 1) )
742 bprint(strcat("^1Attention: ^7", self.netname, " resumed the game! Prepare for battle!\n"));
743 remainingTimeoutTime = autocvar_sv_timeout_resumetime;
744 timeoutHandler.nextthink = time; //timeoutHandler has to take care of it immediately
747 sprint(self, "^7Error: Your resumegame call was discarded!\n");
751 return; // never fall through to usage
755 case CC_REQUEST_USAGE:
757 sprint(self, "\nUsage:^3 cmd timein\n");
758 sprint(self, " No arguments required.\n");
764 void ClientCommand_timeout(float request) // DEAR GOD THIS COMMAND IS TERRIBLE.
768 case CC_REQUEST_COMMAND:
770 if(self.flags & FL_CLIENT)
772 if(autocvar_sv_timeout)
774 if(self.classname == "player")
777 sprint(self, "^7Error: you can not call a timeout while a vote is active!\n");
780 if (inWarmupStage && !g_warmup_allow_timeout)
781 return sprint(self, "^7Error: You can not call a timeout in warmup-stage!\n");
782 if (time < game_starttime )
783 return sprint(self, "^7Error: You can not call a timeout while the map is being restarted!\n");
785 if (timeoutStatus != 2) {
786 //if the map uses a timelimit make sure that timeout cannot be called right before the map ends
787 if (autocvar_timelimit) {
788 //a timelimit was used
790 myTl = autocvar_timelimit;
792 float lastPossibleTimeout;
793 lastPossibleTimeout = (myTl*60) - autocvar_sv_timeout_leadtime - 1;
795 if (lastPossibleTimeout < time - game_starttime)
796 return sprint(self, "^7Error: It is too late to call a timeout now!\n");
800 //player may not call a timeout if he has no calls left
801 if (self.allowedTimeouts < 1)
802 return sprint(self, "^7Error: You already used all your timeout calls for this map!\n");
805 //now all required checks are passed
806 self.allowedTimeouts -= 1;
807 bprint(self.netname, " ^7called a timeout (", ftos(self.allowedTimeouts), " timeouts left)!\n"); //write a bprint who started the timeout (and how many he has left)
808 remainingTimeoutTime = autocvar_sv_timeout_length;
809 remainingLeadTime = autocvar_sv_timeout_leadtime;
810 timeoutInitiator = self;
811 if (timeoutStatus == 0) { //if another timeout was already active, don't change its status (which was 1 or 2) to 1, only change it to 1 if no timeout was active yet
813 //create the timeout indicator which centerprints the information to all players and takes care of pausing/unpausing
814 timeoutHandler = spawn();
815 timeoutHandler.think = timeoutHandler_Think;
817 timeoutHandler.nextthink = time; //always let the entity think asap
819 //inform all connected clients about the timeout call
820 Announce("timeoutcalled");
824 sprint(self, "^7Error: only players can call a timeout!\n");
827 return; // never fall through to usage
831 case CC_REQUEST_USAGE:
833 sprint(self, "\nUsage:^3 cmd timeout\n");
834 sprint(self, " No arguments required.\n");
840 void ClientCommand_voice(float request, float argc, string command)
844 case CC_REQUEST_COMMAND:
847 VoiceMessage(argv(1), substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2)));
849 VoiceMessage(argv(1), "");
850 return; // never fall through to usage
854 case CC_REQUEST_USAGE:
856 sprint(self, "\nUsage:^3 cmd voice\n");
857 sprint(self, " FIXME ARGUMENTS UNKNOWN.\n");
863 string strlimitedlen(string input, float strip_colors, float limit)
865 if(strlen((strip_colors ? strdecolorize(input) : input)) <= limit)
868 return strcat(substring(input, 0, (strlen(input) - 3)), "...");
871 void ClientCommand_who(float request)
875 case CC_REQUEST_COMMAND:
877 float total_listed_players, tmp_hours, tmp_minutes, tmp_seconds;
879 string tmp_player_name;
881 sprint(self, strcat("List of client information", (autocvar_sv_status_privacy ? " (some data is hidden for privacy)" : string_null), ":\n"));
882 sprint(self, sprintf(" %-4s %-20s %-5s %-3s %-9s %-16s %s\n", "ent", "nickname", "ping", "pl", "time", "ip", "crypto_id"));
884 FOR_EACH_CLIENT(tmp_player)
886 tmp_player_name = strlimitedlen(tmp_player.netname, TRUE, 20);
888 tmp_hours = tmp_minutes = tmp_seconds = 0;
890 tmp_seconds = (time - tmp_player.jointime);
891 tmp_minutes = (tmp_seconds / 60);
895 tmp_seconds -= (tmp_minutes * 60);
896 tmp_hours = (tmp_minutes / 60);
898 if(tmp_hours) { tmp_minutes -= (tmp_hours * 60); }
901 sprint(self, sprintf(" %-4s %-20s %-5d %-3d %-9s %-16s %s\n",
902 strcat("#", ftos(num_for_edict(tmp_player))),
903 tmp_player.netname, //strcat(tmp_player_name, sprintf("%*s", (20 - strlen(strdecolorize(tmp_player_name))), "")),
904 tmp_player.ping, tmp_player.ping_packetloss,
905 sprintf("%02d:%02d:%02d", tmp_hours, tmp_minutes, tmp_seconds),
906 (autocvar_sv_status_privacy ? "hidden" : tmp_player.netaddress),
907 (autocvar_sv_status_privacy ? "hidden" : tmp_player.crypto_idfp)));
909 ++total_listed_players;
912 sprint(self, strcat("Finished listing ", ftos(total_listed_players), " client(s). \n"));
914 return; // never fall through to usage
918 case CC_REQUEST_USAGE:
920 sprint(self, "\nUsage:^3 cmd who\n");
921 sprint(self, " No arguments required.\n");
927 /* use this when creating a new command, making sure to place it in alphabetical order.
928 void ClientCommand_(float request)
932 case CC_REQUEST_COMMAND:
935 return; // never fall through to usage
939 case CC_REQUEST_USAGE:
941 sprint(self, "\nUsage:^3 cmd \n");
942 sprint(self, " No arguments required.\n");
950 // =====================================
951 // Macro system for networked commands
952 // =====================================
954 // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
955 #define CLIENT_COMMANDS(request,arguments,command) \
956 CLIENT_COMMAND("autoswitch", ClientCommand_autoswitch(request, arguments), "Whether or not to switch automatically when getting a better weapon") \
957 CLIENT_COMMAND("checkfail", ClientCommand_checkfail(request, command), "Report if a client-side check failed") \
958 CLIENT_COMMAND("clientversion", ClientCommand_clientversion(request, arguments), "Release version of the game") \
959 CLIENT_COMMAND("cvar_changes", ClientCommand_cvar_changes(request), "Prints a list of all changed server cvars") \
960 CLIENT_COMMAND("cvar_purechanges", ClientCommand_cvar_purechanges(request), "Prints a list of all changed gameplay cvars") \
961 CLIENT_COMMAND("getmapvotepic", ClientCommand_getmapvotepic(request, arguments), "Retrieve mapshot picture from the server") \
962 CLIENT_COMMAND("info", ClientCommand_info(request, arguments), "Request for unique server information set up by admin") \
963 CLIENT_COMMAND("join", ClientCommand_join(request), "Become a player in the game") \
964 CLIENT_COMMAND("ladder", ClientCommand_ladder(request), "Get information about top players if supported") \
965 CLIENT_COMMAND("lsmaps", ClientCommand_lsmaps(request), "List maps which can be used with the current game mode") \
966 CLIENT_COMMAND("lsnewmaps", ClientCommand_lsnewmaps(request), "List maps which TODO") \
967 CLIENT_COMMAND("maplist", ClientCommand_maplist(request), "Full server maplist reply") \
968 CLIENT_COMMAND("rankings", ClientCommand_rankings(request), "Print information about rankings") \
969 CLIENT_COMMAND("ready", ClientCommand_ready(request), "Qualify as ready to end warmup stage (or restart server if allowed)") \
970 CLIENT_COMMAND("records", ClientCommand_records(request), "List top 10 records for the current map") \
971 CLIENT_COMMAND("reportcvar", ClientCommand_reportcvar(request, arguments, command), "Old system for sending a client cvar to the server") \
972 CLIENT_COMMAND("say", ClientCommand_say(request, arguments, command), "Print a message to chat to all players") \
973 CLIENT_COMMAND("say_team", ClientCommand_say_team(request, arguments, command), "Print a message to chat to all team mates") \
974 CLIENT_COMMAND("selectteam", ClientCommand_selectteam(request, arguments), "Attempt to choose a team to join into") \
975 CLIENT_COMMAND("selfstuff", ClientCommand_selfstuff(request, command), "Stuffcmd a command to your own client") \
976 CLIENT_COMMAND("sentcvar", ClientCommand_sentcvar(request, arguments, command), "New system for sending a client cvar to the server") \
977 CLIENT_COMMAND("spectate", ClientCommand_spectate(request), "Become an observer") \
978 CLIENT_COMMAND("suggestmap", ClientCommand_suggestmap(request, arguments), "Suggest a map to the mapvote at match end") \
979 CLIENT_COMMAND("teamstatus", ClientCommand_teamstatus(request), "Print detailed score information for all players") \
980 CLIENT_COMMAND("tell", ClientCommand_tell(request, arguments, command), "Send a message directly to a player") \
981 CLIENT_COMMAND("timein", ClientCommand_timein(request), "Resume the game from being paused with a timeout") \
982 CLIENT_COMMAND("timeout", ClientCommand_timeout(request), "Call a timeout which pauses the game for certain amount of time unless unpaused") \
983 CLIENT_COMMAND("voice", ClientCommand_voice(request, arguments, command), "Send voice message via sound") \
984 CLIENT_COMMAND("vote", VoteCommand(request, self, arguments, command), "Request an action to be voted upon by players") \
985 CLIENT_COMMAND("who", ClientCommand_who(request), "Display detailed client information about all players") \
988 void ClientCommand_macro_help()
990 #define CLIENT_COMMAND(name,function,description) \
991 { print(" ^2", name, "^7: ", description, "\n"); }
993 CLIENT_COMMANDS(0, 0, "")
994 #undef CLIENT_COMMAND
999 float ClientCommand_macro_command(float argc, string command)
1001 #define CLIENT_COMMAND(name,function,description) \
1002 { if(name == strtolower(argv(0))) { function; return TRUE; } }
1004 CLIENT_COMMANDS(CC_REQUEST_COMMAND, argc, command)
1005 #undef CLIENT_COMMAND
1010 float ClientCommand_macro_usage(float argc, string command)
1012 #define CLIENT_COMMAND(name,function,description) \
1013 { if(name == strtolower(argv(1))) { function; return TRUE; } }
1015 CLIENT_COMMANDS(CC_REQUEST_USAGE, argc, command)
1016 #undef CLIENT_COMMAND
1022 // ======================================
1023 // Main Function Called By Engine (cmd)
1024 // ======================================
1025 // If this function exists, server game code parses clientcommand before the engine code gets it.
1027 void SV_ParseClientCommand(string command)
1029 float argc = tokenize_console(command);
1032 switch(strtolower(argv(0)))
1034 // exempt commands which are not subject to floodcheck
1035 case "begin": break; // handled by engine in host_cmd.c
1036 case "getmapvotepic": break; // handled by server in this file
1037 case "pause": break; // handled by engine in host_cmd.c
1038 case "prespawn": break; // handled by engine in host_cmd.c
1039 case "reportcvar": break; // handled by server in this file
1040 case "sentcvar": break; // handled by server in this file
1041 case "spawn": break; // handled by engine in host_cmd.c
1044 if(SV_ParseClientCommand_floodcheck())
1045 break; // "TRUE": continue, as we're not flooding yet
1047 return; // "FALSE": not allowed to continue, halt
1050 /* NOTE: totally disabled for now, however the functionality and descriptions are there if we ever want it.
1051 if(argv(0) == "help")
1055 sprint(self, "\nUsage:^3 cmd COMMAND...^7, where possible commands are:\n");
1056 ClientCommand_macro_help;
1057 sprint(self, "For help about specific commands, type cmd help COMMAND\n");
1060 else if(ClientCommand_macro_usage(argc, command)) // Instead of trying to call a command, we're going to see detailed information about it
1065 else*/ if(MUTATOR_CALLHOOK(SV_ParseClientCommand))
1067 return; // handled by a mutator
1069 else if(CheatCommand(argc))
1071 return; // handled by server/cheats.qc
1073 else if(ClientCommand_macro_command(argc, command)) // continue as usual and scan for normal commands
1075 return; // handled by one of the above GameCommand_* functions
1078 clientcommand(self, command);