1 // =========================================================
2 // Server side networked commands code, reworked by Samual
3 // Last updated: December 11th, 2011
4 // =========================================================
6 // move any necessary sprint statements to "print_to"
8 // ============================
9 // Misc. Supporting Functions
10 // ============================
12 float SV_ParseClientCommand_floodcheck()
14 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)
16 if(time <= (self.cmd_floodtime + autocvar_sv_clientcommand_antispam_time))
18 self.cmd_floodcount += 1;
19 if(self.cmd_floodcount > autocvar_sv_clientcommand_antispam_count) { return FALSE; } // too much spam, halt
23 self.cmd_floodtime = time;
24 self.cmd_floodcount = 1;
27 return TRUE; // continue, as we're not flooding yet
31 // =======================
32 // Command Sub-Functions
33 // =======================
35 void ClientCommand_autoswitch(float request, float argc)
39 case CC_REQUEST_COMMAND:
41 self.autoswitch = ("0" != argv(1));
42 sprint(self, strcat("^1autoswitch is currently turned ", (self.autoswitch ? "on" : "off"), ".\n"));
43 return; // never fall through to usage
47 case CC_REQUEST_USAGE:
49 sprint(self, "\nUsage:^3 cmd autoswitch selection\n");
50 sprint(self, " Where 'selection' is 1 or 0 for on or off.\n");
56 void ClientCommand_checkfail(float request, string command) // used only by client side code
60 case CC_REQUEST_COMMAND:
62 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))));
64 return; // never fall through to usage
68 case CC_REQUEST_USAGE:
70 sprint(self, "\nUsage:^3 cmd checkfail message\n");
71 sprint(self, " Where 'message' is the message reported by client about the fail.\n");
77 void ClientCommand_clientversion(float request, float argc) // used only by client side code
81 case CC_REQUEST_COMMAND:
83 if(self.flags & FL_CLIENT)
85 self.version = ((argv(1) == "$gameversion") ? 1 : stof(argv(1)));
87 if(self.version < autocvar_gameversion_min || self.version > autocvar_gameversion_max)
89 self.version_mismatch = 1;
90 ClientKill_TeamChange(-2); // observe
92 else if(autocvar_g_campaign || autocvar_g_balance_teams || autocvar_g_balance_teams_force)
94 //JoinBestTeam(self, FALSE, TRUE);
96 else if(teamplay && !autocvar_sv_spectate && !(self.team_forced > 0))
98 self.classname = "observer"; // really?
99 stuffcmd(self, "menu_showteamselect\n");
102 return; // never fall through to usage
106 case CC_REQUEST_USAGE:
108 sprint(self, "\nUsage:^3 cmd clientversion version\n");
109 sprint(self, " Where 'version' is the game version reported by self.\n");
115 void ClientCommand_cvar_changes(float request)
119 case CC_REQUEST_COMMAND:
121 sprint(self, cvar_changes);
122 return; // never fall through to usage
126 case CC_REQUEST_USAGE:
128 sprint(self, "\nUsage:^3 sv_cmd cvar_changes\n");
129 sprint(self, " No arguments required.\n");
130 //sprint(self, "See also: ^2cvar_purechanges^7\n");
136 void ClientCommand_cvar_purechanges(float request)
140 case CC_REQUEST_COMMAND:
142 sprint(self, cvar_purechanges);
143 return; // never fall through to usage
147 case CC_REQUEST_USAGE:
149 sprint(self, "\nUsage:^3 sv_cmd cvar_purechanges\n");
150 sprint(self, " No arguments required.\n");
151 //sprint(self, "See also: ^2cvar_changes^7\n");
157 void ClientCommand_getmapvotepic(float request, float argc)
161 case CC_REQUEST_COMMAND:
163 if(intermission_running)
164 MapVote_SendPicture(stof(argv(1)));
166 return; // never fall through to usage
170 case CC_REQUEST_USAGE:
172 sprint(self, "\nUsage:^3 cmd getmapvotepic mapid\n");
173 sprint(self, " Where 'mapid' is the id number of the map to request an image of on the map vote selection menu.\n");
179 void ClientCommand_info(float request, float argc)
183 case CC_REQUEST_COMMAND:
187 command = builtin_cvar_string(strcat("sv_info_", argv(1)));
189 wordwrap_sprint(command, 1111); // why 1111?
191 sprint(self, "ERROR: unsupported info command\n");
193 return; // never fall through to usage
197 case CC_REQUEST_USAGE:
199 sprint(self, "\nUsage:^3 cmd info request\n");
200 sprint(self, " Where 'request' is the suffixed string appended onto the request for cvar.\n");
206 void ClientCommand_join(float request)
210 case CC_REQUEST_COMMAND:
212 if(self.flags & FL_CLIENT)
214 if(self.classname != "player" && !lockteams && !g_arena)
218 if(g_ca) { self.caplayer = 1; }
219 if(autocvar_g_campaign) { campaign_bots_may_start = 1; }
221 self.classname = "player";
222 PlayerScore_Clear(self);
223 bprint ("^4", self.netname, "^4 is playing now\n");
228 //player may not join because of g_maxplayers is set
229 centerprint(self, PREVENT_JOIN_TEXT);
233 return; // never fall through to usage
237 case CC_REQUEST_USAGE:
239 sprint(self, "\nUsage:^3 cmd join\n");
240 sprint(self, " No arguments required.\n");
246 void ClientCommand_ladder(float request)
250 case CC_REQUEST_COMMAND:
252 sprint(self, ladder_reply);
253 return; // never fall through to usage
257 case CC_REQUEST_USAGE:
259 sprint(self, "\nUsage:^3 cmd ladder\n");
260 sprint(self, " No arguments required.\n");
266 void ClientCommand_lsmaps(float request)
270 case CC_REQUEST_COMMAND:
272 sprint(self, lsmaps_reply);
273 return; // never fall through to usage
277 case CC_REQUEST_USAGE:
279 sprint(self, "\nUsage:^3 cmd lsmaps\n");
280 sprint(self, " No arguments required.\n");
286 void ClientCommand_lsnewmaps(float request)
290 case CC_REQUEST_COMMAND:
292 sprint(self, lsnewmaps_reply);
293 return; // never fall through to usage
297 case CC_REQUEST_USAGE:
299 sprint(self, "\nUsage:^3 cmd lsnewmaps\n");
300 sprint(self, " No arguments required.\n");
306 void ClientCommand_maplist(float request)
310 case CC_REQUEST_COMMAND:
312 sprint(self, maplist_reply);
313 return; // never fall through to usage
317 case CC_REQUEST_USAGE:
319 sprint(self, "\nUsage:^3 cmd maplist\n");
320 sprint(self, " No arguments required.\n");
326 void ClientCommand_rankings(float request)
330 case CC_REQUEST_COMMAND:
332 sprint(self, rankings_reply);
333 return; // never fall through to usage
337 case CC_REQUEST_USAGE:
339 sprint(self, "\nUsage:^3 cmd rankings\n");
340 sprint(self, " No arguments required.\n");
346 void ClientCommand_ready(float request)
350 case CC_REQUEST_COMMAND:
352 if(self.flags & FL_CLIENT)
354 if(inWarmupStage || autocvar_sv_ready_restart || g_race_qualifying == 2)
356 if(!readyrestart_happened || autocvar_sv_ready_restart_repeatable)
358 if (self.ready) // toggle
361 bprint(self.netname, "^2 is ^1NOT^2 ready\n");
366 bprint(self.netname, "^2 is ready\n");
369 // cannot reset the game while a timeout is active!
373 sprint(self, "^1Game has already been restarted\n");
377 return; // never fall through to usage
381 case CC_REQUEST_USAGE:
383 sprint(self, "\nUsage:^3 cmd ready\n");
384 sprint(self, " No arguments required.\n");
390 void ClientCommand_records(float request) // TODO: Isn't this flooding with the sprint messages? Old code, but perhaps bad?
394 case CC_REQUEST_COMMAND:
398 for(i = 0; i < 10; ++i)
399 sprint(self, records_reply[i]);
401 return; // never fall through to usage
405 case CC_REQUEST_USAGE:
407 sprint(self, "\nUsage:^3 cmd records\n");
408 sprint(self, " No arguments required.\n");
414 void ClientCommand_reportcvar(float request, float argc, string command) // TODO: confirm this works
418 case CC_REQUEST_COMMAND:
423 if(substring(argv(2), 0, 1) == "$") // undefined cvar: use the default value on the server then
425 s = strcat(substring(command, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\"");
426 tokens = tokenize_console(s);
429 return; // never fall through to usage
433 case CC_REQUEST_USAGE:
435 sprint(self, "\nUsage:^3 cmd reportcvar <cvar>\n");
436 sprint(self, " Where 'cvar' is the cvar plus arguments to send to the server.\n");
442 void ClientCommand_say(float request, float argc, string command)
446 case CC_REQUEST_COMMAND:
448 if(argc >= 2) { Say(self, FALSE, world, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1); }
449 return; // never fall through to usage
453 case CC_REQUEST_USAGE:
455 sprint(self, "\nUsage:^3 cmd say <message>\n");
456 sprint(self, " Where 'message' is the string of text to say.\n");
462 void ClientCommand_say_team(float request, float argc, string command)
466 case CC_REQUEST_COMMAND:
468 if(argc >= 2) { Say(self, TRUE, world, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1); }
469 return; // never fall through to usage
473 case CC_REQUEST_USAGE:
475 sprint(self, "\nUsage:^3 cmd say_team <message>\n");
476 sprint(self, " Where 'message' is the string of text to say.\n");
482 void ClientCommand_selectteam(float request, float argc) // TODO: Update the messages for this command
486 case CC_REQUEST_COMMAND:
490 if (self.flags & FL_CLIENT)
493 if not(self.team_forced > 0)
498 case "red": selection = COLOR_TEAM1; break;
499 case "blue": selection = COLOR_TEAM2; break;
500 case "yellow": selection = COLOR_TEAM3; break;
501 case "pink": selection = COLOR_TEAM4; break;
502 case "auto": selection = (-1); break;
509 if(self.team == selection && self.deadflag == DEAD_NO)
510 sprint(self, "^7You already are on that team.\n");
511 else if(self.wasplayer && autocvar_g_changeteam_banned)
512 sprint(self, "^1You cannot change team, forbidden by the server.\n");
514 ClientKill_TeamChange(selection);
518 sprint(self, "^7The game has already begun, you must wait until the next map to be able to join a team.\n");
520 sprint(self, "^7selectteam can not be used as your team is forced\n");
522 sprint(self, "^7selectteam can only be used in teamgames\n");
524 return; // never fall through to usage
528 case CC_REQUEST_USAGE:
530 //sprint(self, strcat( "selectteam none/red/blue/yellow/pink/auto - \"", argv(1), "\" not recognised\n" ) );
531 sprint(self, "\nUsage:^3 cmd selectteam team\n");
532 sprint(self, " Where 'team' is the prefered team to try and join.\n");
533 sprint(self, " Full list of options here: \"red, blue, yellow, pink, auto\"\n");
539 void ClientCommand_selfstuff(float request, string command)
543 case CC_REQUEST_COMMAND:
545 stuffcmd(self, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
546 return; // never fall through to usage
550 case CC_REQUEST_USAGE:
552 sprint(self, "\nUsage:^3 cmd selfstuff command\n");
553 sprint(self, " Where 'command' is the string to be stuffed to your client.\n");
559 void ClientCommand_sentcvar(float request, float argc, string command)
563 case CC_REQUEST_COMMAND:
568 if(argc == 2) // undefined cvar: use the default value on the server then
570 s = strcat(substring(command, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\"");
571 tokens = tokenize_console(s);
574 return; // never fall through to usage
578 case CC_REQUEST_USAGE:
580 sprint(self, "\nUsage:^3 cmd sentcvar <cvar>\n");
581 sprint(self, " Where 'cvar' is the cvar plus arguments to send to the server.\n");
587 void ClientCommand_spectate(float request)
591 case CC_REQUEST_COMMAND:
593 if(self.flags & FL_CLIENT)
595 if(g_arena) { return; }
598 if(self.lms_spectate_warning)
600 // mark player as spectator
601 PlayerScore_Add(self, SP_LMS_RANK, 666 - PlayerScore_Add(self, SP_LMS_RANK, 0));
605 self.lms_spectate_warning = 1;
606 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");
611 if(self.classname == "player" && autocvar_sv_spectate == 1)
612 ClientKill_TeamChange(-2); // observe
614 // in CA, allow a dead player to move to spectatators (without that, caplayer!=0 will be moved back to the player list)
615 // note: if arena game mode is ever done properly, this needs to be removed.
616 if(g_ca && self.caplayer && (self.classname == "spectator" || self.classname == "observer"))
618 sprint(self, "WARNING: you will spectate in the next round.\n");
622 return; // never fall through to usage
626 case CC_REQUEST_USAGE:
628 sprint(self, "\nUsage:^3 cmd spectate\n");
629 sprint(self, " No arguments required.\n");
635 void ClientCommand_suggestmap(float request, float argc)
639 case CC_REQUEST_COMMAND:
641 sprint(self, strcat(MapVote_Suggest(argv(1)), "\n"));
642 return; // never fall through to usage
646 case CC_REQUEST_USAGE:
648 sprint(self, "\nUsage:^3 cmd suggestmap map\n");
649 sprint(self, " Where 'map' is the name of the map to suggest.\n");
655 void ClientCommand_teamstatus(float request)
659 case CC_REQUEST_COMMAND:
661 Score_NicePrint(self);
662 return; // never fall through to usage
666 case CC_REQUEST_USAGE:
668 sprint(self, "\nUsage:^3 cmd teamstatus\n");
669 sprint(self, " No arguments required.\n");
675 void ClientCommand_tell(float request, float argc, string command)
679 case CC_REQUEST_COMMAND:
681 entity e = GetCommandPlayerSlotTargetFromTokenizedCommand(argc, 1);
683 if(e && argc > ParseCommandPlayerSlotTarget_firsttoken)
685 Say(self, FALSE, e, substring(command, argv_start_index(ParseCommandPlayerSlotTarget_firsttoken), argv_end_index(-1) - argv_start_index(ParseCommandPlayerSlotTarget_firsttoken)), TRUE);
689 if(argc > ParseCommandPlayerSlotTarget_firsttoken)
690 trigger_magicear_processmessage_forallears(self, -1, world, substring(command, argv_start_index(ParseCommandPlayerSlotTarget_firsttoken), argv_end_index(-1) - argv_start_index(ParseCommandPlayerSlotTarget_firsttoken)));
692 return; // never fall through to usage
696 case CC_REQUEST_USAGE:
698 sprint(self, "\nUsage:^3 cmd tell playerid <message>\n");
699 sprint(self, " Where 'playerid' is the entity number of the player to send the 'message' to.\n");
705 void ClientCommand_timein(float request)
709 case CC_REQUEST_COMMAND:
711 if(self.flags & FL_CLIENT)
713 if(autocvar_sv_timeout)
716 return sprint(self, "^7Error: There is no active timeout which could be aborted!\n");
717 if (self != timeoutInitiator)
718 return sprint(self, "^7Error: You may not abort the active timeout. Only the player who called it can do that!\n");
720 if (timeoutStatus == 1)
722 remainingTimeoutTime = timeoutStatus = 0;
723 timeoutHandler.nextthink = time; //timeoutHandler has to take care of it immediately
724 bprint(strcat("^7The timeout was aborted by ", self.netname, " !\n"));
726 else if (timeoutStatus == 2)
728 //only shorten the remainingTimeoutTime if it makes sense
729 if( remainingTimeoutTime > (autocvar_sv_timeout_resumetime + 1) )
731 bprint(strcat("^1Attention: ^7", self.netname, " resumed the game! Prepare for battle!\n"));
732 remainingTimeoutTime = autocvar_sv_timeout_resumetime;
733 timeoutHandler.nextthink = time; //timeoutHandler has to take care of it immediately
736 sprint(self, "^7Error: Your resumegame call was discarded!\n");
740 return; // never fall through to usage
744 case CC_REQUEST_USAGE:
746 sprint(self, "\nUsage:^3 cmd timein\n");
747 sprint(self, " No arguments required.\n");
753 void ClientCommand_timeout(float request) // DEAR GOD THIS COMMAND IS TERRIBLE.
757 case CC_REQUEST_COMMAND:
759 if(self.flags & FL_CLIENT)
761 if(autocvar_sv_timeout)
763 if(self.classname == "player")
766 sprint(self, "^7Error: you can not call a timeout while a vote is active!\n");
769 if (inWarmupStage && !g_warmup_allow_timeout)
770 return sprint(self, "^7Error: You can not call a timeout in warmup-stage!\n");
771 if (time < game_starttime )
772 return sprint(self, "^7Error: You can not call a timeout while the map is being restarted!\n");
774 if (timeoutStatus != 2) {
775 //if the map uses a timelimit make sure that timeout cannot be called right before the map ends
776 if (autocvar_timelimit) {
777 //a timelimit was used
779 myTl = autocvar_timelimit;
781 float lastPossibleTimeout;
782 lastPossibleTimeout = (myTl*60) - autocvar_sv_timeout_leadtime - 1;
784 if (lastPossibleTimeout < time - game_starttime)
785 return sprint(self, "^7Error: It is too late to call a timeout now!\n");
789 //player may not call a timeout if he has no calls left
790 if (self.allowedTimeouts < 1)
791 return sprint(self, "^7Error: You already used all your timeout calls for this map!\n");
794 //now all required checks are passed
795 self.allowedTimeouts -= 1;
796 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)
797 remainingTimeoutTime = autocvar_sv_timeout_length;
798 remainingLeadTime = autocvar_sv_timeout_leadtime;
799 timeoutInitiator = self;
800 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
802 //create the timeout indicator which centerprints the information to all players and takes care of pausing/unpausing
803 timeoutHandler = spawn();
804 timeoutHandler.think = timeoutHandler_Think;
806 timeoutHandler.nextthink = time; //always let the entity think asap
808 //inform all connected clients about the timeout call
809 Announce("timeoutcalled");
813 sprint(self, "^7Error: only players can call a timeout!\n");
816 return; // never fall through to usage
820 case CC_REQUEST_USAGE:
822 sprint(self, "\nUsage:^3 cmd timeout\n");
823 sprint(self, " No arguments required.\n");
829 void ClientCommand_voice(float request, float argc, string command)
833 case CC_REQUEST_COMMAND:
836 VoiceMessage(argv(1), substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2)));
838 VoiceMessage(argv(1), "");
839 return; // never fall through to usage
843 case CC_REQUEST_USAGE:
845 sprint(self, "\nUsage:^3 cmd voice\n");
846 sprint(self, " FIXME ARGUMENTS UNKNOWN.\n");
852 void ClientCommand_who(float request)
856 case CC_REQUEST_COMMAND:
858 float total_listed_players, tmp_hours, tmp_minutes, tmp_seconds;
860 //string tmp_player_name;
862 sprint(self, strcat("List of client information", (autocvar_sv_status_privacy ? " (some data is hidden for privacy)" : string_null), ":\n"));
863 sprint(self, sprintf(" %-4s %-20s %-5s %-3s %-9s %-16s %s\n", "ent", "nickname", "ping", "pl", "time", "ip", "crypto_id"));
865 FOR_EACH_CLIENT(tmp_player)
867 //tmp_player_name = strlimitedlen(tmp_player.netname, TRUE, 20);
869 tmp_hours = tmp_minutes = tmp_seconds = 0;
871 tmp_seconds = (time - tmp_player.jointime);
872 tmp_minutes = (tmp_seconds / 60);
876 tmp_seconds -= (tmp_minutes * 60);
877 tmp_hours = (tmp_minutes / 60);
879 if(tmp_hours) { tmp_minutes -= (tmp_hours * 60); }
882 sprint(self, sprintf(" %-4s %-20s %-5d %-3d %-9s %-16s %s\n",
883 strcat("#", ftos(num_for_edict(tmp_player))),
884 tmp_player.netname, //strcat(tmp_player_name, sprintf("%*s", (20 - strlen(strdecolorize(tmp_player_name))), "")),
885 tmp_player.ping, tmp_player.ping_packetloss,
886 sprintf("%02d:%02d:%02d", tmp_hours, tmp_minutes, tmp_seconds),
887 (autocvar_sv_status_privacy ? "hidden" : tmp_player.netaddress),
888 (autocvar_sv_status_privacy ? "hidden" : tmp_player.crypto_idfp)));
890 ++total_listed_players;
893 sprint(self, strcat("Finished listing ", ftos(total_listed_players), " client(s). \n"));
895 return; // never fall through to usage
899 case CC_REQUEST_USAGE:
901 sprint(self, "\nUsage:^3 cmd who\n");
902 sprint(self, " No arguments required.\n");
908 /* use this when creating a new command, making sure to place it in alphabetical order.
909 void ClientCommand_(float request)
913 case CC_REQUEST_COMMAND:
916 return; // never fall through to usage
920 case CC_REQUEST_USAGE:
922 sprint(self, "\nUsage:^3 cmd \n");
923 sprint(self, " No arguments required.\n");
931 // =====================================
932 // Macro system for networked commands
933 // =====================================
935 // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
936 #define CLIENT_COMMANDS(request,arguments,command) \
937 CLIENT_COMMAND("autoswitch", ClientCommand_autoswitch(request, arguments), "Whether or not to switch automatically when getting a better weapon") \
938 CLIENT_COMMAND("checkfail", ClientCommand_checkfail(request, command), "Report if a client-side check failed") \
939 CLIENT_COMMAND("clientversion", ClientCommand_clientversion(request, arguments), "Release version of the game") \
940 CLIENT_COMMAND("cvar_changes", ClientCommand_cvar_changes(request), "Prints a list of all changed server cvars") \
941 CLIENT_COMMAND("cvar_purechanges", ClientCommand_cvar_purechanges(request), "Prints a list of all changed gameplay cvars") \
942 CLIENT_COMMAND("getmapvotepic", ClientCommand_getmapvotepic(request, arguments), "Retrieve mapshot picture from the server") \
943 CLIENT_COMMAND("info", ClientCommand_info(request, arguments), "Request for unique server information set up by admin") \
944 CLIENT_COMMAND("join", ClientCommand_join(request), "Become a player in the game") \
945 CLIENT_COMMAND("ladder", ClientCommand_ladder(request), "Get information about top players if supported") \
946 CLIENT_COMMAND("lsmaps", ClientCommand_lsmaps(request), "List maps which can be used with the current game mode") \
947 CLIENT_COMMAND("lsnewmaps", ClientCommand_lsnewmaps(request), "List maps which TODO") \
948 CLIENT_COMMAND("maplist", ClientCommand_maplist(request), "Full server maplist reply") \
949 CLIENT_COMMAND("rankings", ClientCommand_rankings(request), "Print information about rankings") \
950 CLIENT_COMMAND("ready", ClientCommand_ready(request), "Qualify as ready to end warmup stage (or restart server if allowed)") \
951 CLIENT_COMMAND("records", ClientCommand_records(request), "List top 10 records for the current map") \
952 CLIENT_COMMAND("reportcvar", ClientCommand_reportcvar(request, arguments, command), "Old system for sending a client cvar to the server") \
953 CLIENT_COMMAND("say", ClientCommand_say(request, arguments, command), "Print a message to chat to all players") \
954 CLIENT_COMMAND("say_team", ClientCommand_say_team(request, arguments, command), "Print a message to chat to all team mates") \
955 CLIENT_COMMAND("selectteam", ClientCommand_selectteam(request, arguments), "Attempt to choose a team to join into") \
956 CLIENT_COMMAND("selfstuff", ClientCommand_selfstuff(request, command), "Stuffcmd a command to your own client") \
957 CLIENT_COMMAND("sentcvar", ClientCommand_sentcvar(request, arguments, command), "New system for sending a client cvar to the server") \
958 CLIENT_COMMAND("spectate", ClientCommand_spectate(request), "Become an observer") \
959 CLIENT_COMMAND("suggestmap", ClientCommand_suggestmap(request, arguments), "Suggest a map to the mapvote at match end") \
960 CLIENT_COMMAND("teamstatus", ClientCommand_teamstatus(request), "Print detailed score information for all players") \
961 CLIENT_COMMAND("tell", ClientCommand_tell(request, arguments, command), "Send a message directly to a player") \
962 CLIENT_COMMAND("timein", ClientCommand_timein(request), "Resume the game from being paused with a timeout") \
963 CLIENT_COMMAND("timeout", ClientCommand_timeout(request), "Call a timeout which pauses the game for certain amount of time unless unpaused") \
964 CLIENT_COMMAND("voice", ClientCommand_voice(request, arguments, command), "Send voice message via sound") \
965 CLIENT_COMMAND("vote", VoteCommand(request, self, arguments, command), "Request an action to be voted upon by players") \
966 CLIENT_COMMAND("who", ClientCommand_who(request), "Display detailed client information about all players") \
969 void ClientCommand_macro_help()
971 #define CLIENT_COMMAND(name,function,description) \
972 { print(" ^2", name, "^7: ", description, "\n"); }
974 CLIENT_COMMANDS(0, 0, "")
975 #undef CLIENT_COMMAND
980 float ClientCommand_macro_command(float argc, string command)
982 #define CLIENT_COMMAND(name,function,description) \
983 { if(name == strtolower(argv(0))) { function; return TRUE; } }
985 CLIENT_COMMANDS(CC_REQUEST_COMMAND, argc, command)
986 #undef CLIENT_COMMAND
991 float ClientCommand_macro_usage(float argc, string command)
993 #define CLIENT_COMMAND(name,function,description) \
994 { if(name == strtolower(argv(1))) { function; return TRUE; } }
996 CLIENT_COMMANDS(CC_REQUEST_USAGE, argc, command)
997 #undef CLIENT_COMMAND
1003 // ======================================
1004 // Main Function Called By Engine (cmd)
1005 // ======================================
1006 // If this function exists, server game code parses clientcommand before the engine code gets it.
1008 void SV_ParseClientCommand(string command)
1010 float argc = tokenize_console(command);
1013 switch(strtolower(argv(0)))
1015 // exempt commands which are not subject to floodcheck
1016 case "begin": break; // handled by engine in host_cmd.c
1017 case "getmapvotepic": break; // handled by server in this file
1018 case "pause": break; // handled by engine in host_cmd.c
1019 case "prespawn": break; // handled by engine in host_cmd.c
1020 case "reportcvar": break; // handled by server in this file
1021 case "sentcvar": break; // handled by server in this file
1022 case "spawn": break; // handled by engine in host_cmd.c
1025 if(SV_ParseClientCommand_floodcheck())
1026 break; // "TRUE": continue, as we're not flooding yet
1028 return; // "FALSE": not allowed to continue, halt
1031 /* NOTE: totally disabled for now, however the functionality and descriptions are there if we ever want it.
1032 if(argv(0) == "help")
1036 sprint(self, "\nUsage:^3 cmd COMMAND...^7, where possible commands are:\n");
1037 ClientCommand_macro_help;
1038 sprint(self, "For help about specific commands, type cmd help COMMAND\n");
1041 else if(ClientCommand_macro_usage(argc, command)) // Instead of trying to call a command, we're going to see detailed information about it
1046 else*/ if(MUTATOR_CALLHOOK(SV_ParseClientCommand))
1048 return; // handled by a mutator
1050 else if(CheatCommand(argc))
1052 return; // handled by server/cheats.qc
1054 else if(ClientCommand_macro_command(argc, command)) // continue as usual and scan for normal commands
1056 return; // handled by one of the above GameCommand_* functions
1059 clientcommand(self, command);