3 #include <common/constants.qh>
4 #include <common/effects/all.qh>
5 #include <common/gamemodes/_mod.qh>
6 #include <common/mapinfo.qh>
7 #include <common/monsters/sv_monsters.qh>
8 #include <common/net_linked.qh>
9 #include <common/notifications/all.qh>
10 #include <common/teams.qh>
11 #include <common/util.qh>
12 #include <server/anticheat.qh>
13 #include <server/bot/api.qh>
14 #include <server/campaign.qh>
15 #include <server/client.qh>
16 #include <server/command/_mod.qh>
17 #include <server/command/banning.qh>
18 #include <server/command/cmd.qh>
19 #include <server/command/common.qh>
20 #include <server/command/getreplies.qh>
21 #include <server/command/radarmap.qh>
22 #include <server/intermission.qh>
23 #include <server/ipban.qh>
24 #include <server/mutators/_mod.qh>
25 #include <server/player.qh>
26 #include <server/teamplay.qh>
27 #include <server/world.qh>
29 // used by GameCommand_make_mapinfo()
30 void make_mapinfo_Think(entity this)
32 if (_MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
34 LOG_INFO("Done rebuiling mapinfos.");
35 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
40 setthink(this, make_mapinfo_Think);
41 this.nextthink = time;
45 // used by GameCommand_extendmatchtime() and GameCommand_reducematchtime()
46 void changematchtime(float delta, float mi, float ma)
52 if (delta == 0) return;
53 if (autocvar_timelimit < 0) return;
55 if (mi <= 10) mi = 10; // at least ten sec in the future
56 cur = time - game_starttime;
57 if (cur > 0) mi += cur; // from current time!
59 lim = autocvar_timelimit * 60;
63 if (lim == 0) return; // cannot increase any further
64 else if (lim < ma) update = min(ma, lim + delta);
65 else // already above maximum: FAIL
70 if (lim == 0) // infinite: try reducing to max, if we are allowed to
72 else if (lim > mi) // above minimum: decrease
73 update = max(mi, lim + delta);
74 else // already below minimum: FAIL
78 cvar_set("timelimit", ftos(update / 60));
82 // =======================
83 // Command Sub-Functions
84 // =======================
86 void GameCommand_adminmsg(int request, int argc)
90 case CMD_REQUEST_COMMAND:
95 string targets = strreplace(",", " ", argv(1));
96 string original_targets = strreplace(" ", ", ", targets);
97 string admin_message = argv(2);
98 float infobartime = stof(argv(3));
100 string successful, t;
101 successful = string_null;
103 if ((targets) && (admin_message))
108 targets = cdr(targets);
110 // Check to see if the player is a valid target
111 client = GetFilteredEntity(t);
112 accepted = VerifyClientEntity(client, true, false);
116 LOG_INFO("adminmsg: ", GetClientErrorString(accepted, t), (targets ? ", skipping to next player.\n" : "."));
120 // send the centerprint/console print or infomessage
123 stuffcmd(client, sprintf("\ninfobar %f \"%s\"\n", infobartime, MakeConsoleSafe(admin_message)));
127 centerprint(client, strcat("^3", GetCallerName(NULL), ":\n^7", admin_message));
128 sprint(client, strcat("\{1}\{13}^3", GetCallerName(NULL), "^7: ", admin_message, "\n"));
131 successful = strcat(successful, (successful ? ", " : ""), playername(client.netname, client.team, false));
132 LOG_TRACE("Message sent to ", playername(client.netname, client.team, false));
136 if (successful) bprint("Successfully sent message '", admin_message, "' to ", successful, ".\n");
137 else LOG_INFO("No players given (", original_targets, ") could receive the message.");
144 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
145 case CMD_REQUEST_USAGE:
147 LOG_HELP("Usage:^3 sv_cmd adminmsg <clients> \"<message>\" [<infobartime>]");
148 LOG_HELP(" <clients> is a list (separated by commas) of player entity ID's or nicknames");
149 LOG_HELP(" If <infobartime> is provided, the message will be sent to infobar.");
150 LOG_HELP(" Otherwise, it will just be sent as a centerprint message.");
151 LOG_HELP("Examples: adminmsg 2,4 \"this infomessage will last for ten seconds\" 10");
152 LOG_HELP(" adminmsg 2,5 \"this message will be a centerprint\"");
158 void GameCommand_teamname(int request, int argc)
162 case CMD_REQUEST_COMMAND:
170 LOG_INFO("selectteam can only be used in teamgames");
181 int tm = Team_ColorToTeam(argv(1));
183 cvar_set(strcat("g_teamnames_", argv(1)), argv(2));
184 bprintf("\{1}%s%s^7 team is now known as %s^7\n", Team_ColorCode(tm), Team_ColorName(tm), argv(2));
186 cvar_set(strcat("g_teamnames_", argv(1)), "");
187 bprintf("\{1}%s%s^7 team now doesn't have a team name\n", Team_ColorCode(tm), Team_ColorName(tm), argv(2));
198 send_TeamNames(MSG_BROADCAST, NULL);
203 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
204 case CMD_REQUEST_USAGE:
206 LOG_HELP("Usage:^3 sv_cmd sendteams");
207 LOG_HELP(" No arguments required.");
213 void GameCommand_allready(int request)
217 case CMD_REQUEST_COMMAND:
224 case CMD_REQUEST_USAGE:
226 LOG_HELP("Usage:^3 sv_cmd allready");
227 LOG_HELP(" No arguments required.");
233 void GameCommand_allspec(int request, int argc)
237 case CMD_REQUEST_COMMAND:
239 string reason = argv(1);
241 FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
242 if (it.caplayer) it.caplayer = 0;
243 PutObserverInServer(it);
246 if (n) bprint(strcat("Successfully forced all (", ftos(n), ") players to spectate", (reason ? strcat(" for reason: '", reason, "'") : ""), ".\n"));
247 else LOG_INFO("No players found to spectate.");
252 case CMD_REQUEST_USAGE:
254 LOG_HELP("Usage:^3 sv_cmd allspec [<reason>]");
255 LOG_HELP(" Where <reason> is an optional argument for explanation of allspec command.");
256 LOG_HELP("See also: ^2moveplayer, shuffleteams^7");
262 void GameCommand_anticheat(int request, int argc)
266 case CMD_REQUEST_COMMAND:
268 entity client = GetIndexedEntity(argc, 1);
269 float accepted = VerifyClientEntity(client, false, false);
273 anticheat_report_to_eventlog(client);
278 LOG_INFO("anticheat: ", GetClientErrorString(accepted, argv(1)), ".");
283 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
284 case CMD_REQUEST_USAGE:
286 LOG_HELP("Usage:^3 sv_cmd anticheat <client>");
287 LOG_HELP(" <client> is the entity number or name of the player.");
293 void GameCommand_bbox(int request)
297 case CMD_REQUEST_COMMAND:
299 vector size_min = '0 0 0';
300 vector size_max = '0 0 0';
301 tracebox('1 0 0' * world.absmin.x,
302 '0 1 0' * world.absmin.y + '0 0 1' * world.absmin.z,
303 '0 1 0' * world.absmax.y + '0 0 1' * world.absmax.z,
304 '1 0 0' * world.absmax.x,
307 size_min.x = (trace_startsolid) ? world.absmin.x : trace_endpos.x;
309 tracebox('0 1 0' * world.absmin.y,
310 '1 0 0' * world.absmin.x + '0 0 1' * world.absmin.z,
311 '1 0 0' * world.absmax.x + '0 0 1' * world.absmax.z,
312 '0 1 0' * world.absmax.y,
315 size_min.y = (trace_startsolid) ? world.absmin.y : trace_endpos.y;
317 tracebox('0 0 1' * world.absmin.z,
318 '1 0 0' * world.absmin.x + '0 1 0' * world.absmin.y,
319 '1 0 0' * world.absmax.x + '0 1 0' * world.absmax.y,
320 '0 0 1' * world.absmax.z,
323 size_min.z = (trace_startsolid) ? world.absmin.z : trace_endpos.z;
325 tracebox('1 0 0' * world.absmax.x,
326 '0 1 0' * world.absmin.y + '0 0 1' * world.absmin.z,
327 '0 1 0' * world.absmax.y + '0 0 1' * world.absmax.z,
328 '1 0 0' * world.absmin.x,
331 size_max.x = (trace_startsolid) ? world.absmax.x : trace_endpos.x;
333 tracebox('0 1 0' * world.absmax.y,
334 '1 0 0' * world.absmin.x + '0 0 1' * world.absmin.z,
335 '1 0 0' * world.absmax.x + '0 0 1' * world.absmax.z,
336 '0 1 0' * world.absmin.y,
339 size_max.y = (trace_startsolid) ? world.absmax.y : trace_endpos.y;
341 tracebox('0 0 1' * world.absmax.z,
342 '1 0 0' * world.absmin.x + '0 1 0' * world.absmin.y,
343 '1 0 0' * world.absmax.x + '0 1 0' * world.absmax.y,
344 '0 0 1' * world.absmin.z,
347 size_max.z = (trace_startsolid) ? world.absmax.z : trace_endpos.z;
349 LOG_INFOF("Original size: %v %v", world.absmin, world.absmax);
350 LOG_INFOF("Currently set size: %v %v", world.mins, world.maxs);
351 LOG_INFOF("Solid bounding box size: %v %v", size_min, size_max);
356 case CMD_REQUEST_USAGE:
358 LOG_HELP("Usage:^3 sv_cmd bbox");
359 LOG_HELP(" No arguments required.");
360 LOG_HELP("See also: ^2gettaginfo, trace^7");
366 void GameCommand_bot_cmd(int request, int argc, string command)
370 case CMD_REQUEST_COMMAND:
374 if (argv(1) == "reset")
379 else if (argv(1) == "setbots")
381 cvar_settemp("bot_vs_human", "0");
382 cvar_settemp("minplayers", "0");
383 cvar_settemp("minplayers_per_team", "0");
384 cvar_settemp("bot_number", "0");
386 cvar_settemp("bot_number", argv(2));
387 if (!bot_fixcount()) LOG_INFO("Sorry, could not set requested bot count");
390 else if (argv(1) == "load" && argc == 3)
394 fh = fopen(argv(2), FILE_READ);
397 LOG_INFO("cannot open the file");
402 while ((s = fgets(fh)))
404 argc = tokenize_console(s);
406 if (argc >= 3 && argv(0) == "sv_cmd" && argv(1) == "bot_cmd")
408 if (argv(2) == "reset")
412 else if (argv(2) == "setbots")
414 cvar_settemp("bot_vs_human", "0");
415 cvar_settemp("minplayers", "0");
416 cvar_settemp("minplayers_per_team", "0");
417 cvar_settemp("bot_number", "0");
419 cvar_settemp("bot_number", argv(3));
420 if (!bot_fixcount()) LOG_INFO("Sorry, could not set requested bot count");
424 if(argv(2) == "*" || argv(2) == "all")
425 FOREACH_CLIENT(IS_BOT_CLIENT(it), {
426 bot_queuecommand(it, substring(s, argv_start_index(3), -1));
430 bot = find_bot_by_number(stof(argv(2)));
431 if (bot == NULL) bot = find_bot_by_name(argv(2));
432 if (bot) bot_queuecommand(bot, substring(s, argv_start_index(3), -1));
438 localcmd(strcat(s, "\n"));
443 LOG_INFO(ftos(i), " commands read");
447 else if (argv(1) == "help")
449 if (argv(2)) bot_cmdhelp(argv(2));
450 else bot_list_commands();
453 else if (argc >= 3) // this comes last
455 if(argv(1) == "*" || argv(1) == "all")
458 FOREACH_CLIENT(IS_BOT_CLIENT(it), {
459 bot_queuecommand(it, substring(command, argv_start_index(2), -1));
463 LOG_INFO("Command '", substring(command, argv_start_index(2), -1), "' sent to all bots (", ftos(bot_num), ")");
468 bot = find_bot_by_number(stof(argv(1)));
469 if (bot == NULL) bot = find_bot_by_name(argv(1));
472 LOG_INFO("Command '", substring(command, argv_start_index(2), -1), "' sent to bot ", bot.netname);
473 bot_queuecommand(bot, substring(command, argv_start_index(2), -1));
478 LOG_INFO("Error: Can't find bot with the name or id '", argv(1), "' - Did you mistype the command?"); // don't return so that usage is shown
485 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
486 case CMD_REQUEST_USAGE:
488 LOG_HELP("Usage:^3 sv_cmd bot_cmd <client> <command> [<arguments>]");
489 LOG_HELP(" <client> can be either the name of the bot or a progressive number (not the entity number!)");
490 LOG_HELP(" can also be '*' or 'all' to allow sending the command to all the bots");
491 LOG_HELP(" For full list of commands, see bot_cmd help [<command>].");
492 LOG_HELP("Examples: sv_cmd bot_cmd 1 cc \"say something\"");
493 LOG_HELP(" sv_cmd bot_cmd 1 presskey jump");
494 LOG_HELP(" sv_cmd bot_cmd * pause");
500 void GameCommand_cointoss(int request, int argc)
504 case CMD_REQUEST_COMMAND:
506 string result1 = (argv(2) ? strcat("^7", argv(1)) : "^1HEADS");
507 string result2 = (argv(2) ? strcat("^7", argv(2)) : "^4TAILS");
508 string choice = ((random() > 0.5) ? result1 : result2);
510 Send_Notification(NOTIF_ALL, NULL, MSG_MULTI, MULTI_COINTOSS, choice);
515 case CMD_REQUEST_USAGE:
517 LOG_HELP("Usage:^3 sv_cmd cointoss [<result1> <result2>]");
518 LOG_HELP(" Where <result1> and <result2> are user created options.");
524 void GameCommand_database(int request, int argc)
528 case CMD_REQUEST_COMMAND:
532 if (argv(1) == "save")
534 db_save(ServerProgsDB, argv(2));
535 LOG_INFO("Copied serverprogs database to '", argv(2), "' in the data directory.");
538 else if (argv(1) == "dump")
540 db_dump(ServerProgsDB, argv(2));
541 LOG_INFO("DB dumped."); // wtf does this do?
544 else if (argv(1) == "load")
546 db_close(ServerProgsDB);
547 ServerProgsDB = db_load(argv(2));
548 LOG_INFO("Loaded '", argv(2), "' as new serverprogs database.");
555 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
556 case CMD_REQUEST_USAGE:
558 LOG_HELP("Usage:^3 sv_cmd database <action> <filename>");
559 LOG_HELP(" Where <action> is the command to complete,");
560 LOG_HELP(" and <filename> is what it acts upon.");
561 LOG_HELP(" Full list of commands here: save, dump, load.");
567 void GameCommand_defer_clear(int request, int argc)
571 case CMD_REQUEST_COMMAND:
578 client = GetIndexedEntity(argc, 1);
579 accepted = VerifyClientEntity(client, true, false);
583 stuffcmd(client, "defer clear\n");
584 LOG_INFO("defer clear stuffed to ", playername(client.netname, client.team, false));
586 else { LOG_INFO("defer_clear: ", GetClientErrorString(accepted, argv(1)), "."); }
593 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
594 case CMD_REQUEST_USAGE:
596 LOG_HELP("Usage:^3 sv_cmd defer_clear <client>");
597 LOG_HELP(" <client> is the entity number or name of the player.");
598 LOG_HELP("See also: ^2defer_clear_all^7");
604 void GameCommand_defer_clear_all(int request)
608 case CMD_REQUEST_COMMAND:
613 FOREACH_CLIENT(true, {
614 argc = tokenize_console(strcat("defer_clear ", ftos(etof(it))));
615 GameCommand_defer_clear(CMD_REQUEST_COMMAND, argc);
618 if (n) LOG_INFO("Successfully stuffed defer clear to all clients (", ftos(n), ")"); // should a message be added if no players were found?
623 case CMD_REQUEST_USAGE:
625 LOG_HELP("Usage:^3 sv_cmd defer_clear_all");
626 LOG_HELP(" No arguments required.");
627 LOG_HELP("See also: ^2defer_clear^7");
633 void GameCommand_delrec(int request, int argc) // perhaps merge later with records and printstats and such?
637 case CMD_REQUEST_COMMAND:
641 if (argv(2)) race_deleteTime(argv(2), stof(argv(1)));
642 else race_deleteTime(GetMapname(), stof(argv(1)));
648 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
649 case CMD_REQUEST_USAGE:
651 LOG_HELP("Usage:^3 sv_cmd delrec <ranking> [<map>]");
652 LOG_HELP(" <ranking> is which ranking level to clear up to, ");
653 LOG_HELP(" it will clear all records up to nth place.");
654 LOG_HELP(" if <map> is not provided it will use current map.");
660 void print_Effect_Index(int d, string effect_name)
662 // this is inside a function to avoid expanding it on compilation everytime
663 LOG_INFO("effect ", effect_name, " is ", ftos(_particleeffectnum(effect_name)), "\n");
664 db_put(d, effect_name, "1");
667 void GameCommand_effectindexdump(int request)
671 case CMD_REQUEST_COMMAND:
677 LOG_INFO("begin of effects list");
679 print_Effect_Index(d, "TE_GUNSHOT");
680 print_Effect_Index(d, "TE_GUNSHOTQUAD");
681 print_Effect_Index(d, "TE_SPIKE");
682 print_Effect_Index(d, "TE_SPIKEQUAD");
683 print_Effect_Index(d, "TE_SUPERSPIKE");
684 print_Effect_Index(d, "TE_SUPERSPIKEQUAD");
685 print_Effect_Index(d, "TE_WIZSPIKE");
686 print_Effect_Index(d, "TE_KNIGHTSPIKE");
687 print_Effect_Index(d, "TE_EXPLOSION");
688 print_Effect_Index(d, "TE_EXPLOSIONQUAD");
689 print_Effect_Index(d, "TE_TAREXPLOSION");
690 print_Effect_Index(d, "TE_TELEPORT");
691 print_Effect_Index(d, "TE_LAVASPLASH");
692 print_Effect_Index(d, "TE_SMALLFLASH");
693 print_Effect_Index(d, "TE_FLAMEJET");
694 print_Effect_Index(d, "EF_FLAME");
695 print_Effect_Index(d, "TE_BLOOD");
696 print_Effect_Index(d, "TE_SPARK");
697 print_Effect_Index(d, "TE_PLASMABURN");
698 print_Effect_Index(d, "TE_TEI_G3");
699 print_Effect_Index(d, "TE_TEI_SMOKE");
700 print_Effect_Index(d, "TE_TEI_BIGEXPLOSION");
701 print_Effect_Index(d, "TE_TEI_PLASMAHIT");
702 print_Effect_Index(d, "EF_STARDUST");
703 print_Effect_Index(d, "TR_ROCKET");
704 print_Effect_Index(d, "TR_GRENADE");
705 print_Effect_Index(d, "TR_BLOOD");
706 print_Effect_Index(d, "TR_WIZSPIKE");
707 print_Effect_Index(d, "TR_SLIGHTBLOOD");
708 print_Effect_Index(d, "TR_KNIGHTSPIKE");
709 print_Effect_Index(d, "TR_VORESPIKE");
710 print_Effect_Index(d, "TR_NEHAHRASMOKE");
711 print_Effect_Index(d, "TR_NEXUIZPLASMA");
712 print_Effect_Index(d, "TR_GLOWTRAIL");
713 print_Effect_Index(d, "TR_SEEKER");
714 print_Effect_Index(d, "SVC_PARTICLE");
716 fh = fopen("effectinfo.txt", FILE_READ);
717 while ((s = fgets(fh)))
720 if (argv(0) == "effect")
722 if (db_get(d, argv(1)) != "1")
724 int i = _particleeffectnum(argv(1));
725 if (i >= 0) LOG_INFO("effect ", argv(1), " is ", ftos(i));
726 db_put(d, argv(1), "1");
730 LOG_INFO("end of effects list");
737 case CMD_REQUEST_USAGE:
739 LOG_HELP("Usage:^3 sv_cmd effectindexdump");
740 LOG_HELP(" No arguments required.");
746 void GameCommand_extendmatchtime(int request)
750 case CMD_REQUEST_COMMAND:
752 changematchtime(autocvar_timelimit_increment * 60, autocvar_timelimit_min * 60, autocvar_timelimit_max * 60);
757 case CMD_REQUEST_USAGE:
759 LOG_HELP("Usage:^3 sv_cmd extendmatchtime");
760 LOG_HELP(" No arguments required.");
761 LOG_HELP("See also: ^2reducematchtime^7");
767 void GameCommand_gametype(int request, int argc)
771 case CMD_REQUEST_COMMAND:
773 if (!world_initialized)
775 LOG_INFOF("This command works only when the server is running.");
781 Gametype t = MapInfo_Type_FromString(s, false), tsave = MapInfo_CurrentGametype();
785 MapInfo_SwitchGameType(t);
786 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
787 if (MapInfo_count > 0)
789 // update lsmaps in case the gametype changed, this way people can easily list maps for it
790 if (lsmaps_reply != "") strunzone(lsmaps_reply);
791 lsmaps_reply = strzone(getlsmaps());
792 bprint("Game type successfully switched to ", s, "\n");
796 bprint("Cannot use this game type: no map for it found\n");
797 MapInfo_SwitchGameType(tsave);
798 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
803 bprint("Game type switch to ", s, " failed: this type does not exist!\n");
811 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
812 case CMD_REQUEST_USAGE:
814 LOG_HELP("Usage:^3 sv_cmd gametype <mode>");
815 LOG_HELP(" Where <mode> is the gametype mode to switch to.");
816 LOG_HELP("See also: ^2gotomap^7");
822 void GameCommand_gettaginfo(int request, int argc)
826 case CMD_REQUEST_COMMAND:
834 tmp_entity = spawn();
837 .entity weaponentity = weaponentities[0];
838 _setmodel(tmp_entity, (nextent(NULL)).(weaponentity).model);
842 precache_model(argv(1));
843 _setmodel(tmp_entity, argv(1));
845 tmp_entity.frame = stof(argv(2));
846 if (substring(argv(3), 0, 1) == "#") i = stof(substring(argv(3), 1, -1));
847 else i = gettagindex(tmp_entity, argv(3));
850 v = gettaginfo(tmp_entity, i);
851 LOG_HELPF("model %s frame %s tag %s index %s parent %s",
852 tmp_entity.model, ftos(tmp_entity.frame), gettaginfo_name, ftos(i), ftos(gettaginfo_parent)
854 LOG_HELPF(" vector = %s %s %s", ftos(v.x), ftos(v.y), ftos(v.z));
855 LOG_HELPF(" offset = %s %s %s", ftos(gettaginfo_offset.x), ftos(gettaginfo_offset.y), ftos(gettaginfo_offset.z));
856 LOG_HELPF(" forward = %s %s %s", ftos(gettaginfo_forward.x), ftos(gettaginfo_forward.y), ftos(gettaginfo_forward.z));
857 LOG_HELPF(" right = %s %s %s", ftos(gettaginfo_right.x), ftos(gettaginfo_right.y), ftos(gettaginfo_right.z));
858 LOG_HELPF(" up = %s %s %s", ftos(gettaginfo_up.x), ftos(gettaginfo_up.y), ftos(gettaginfo_up.z));
862 localcmd(strcat(argv(4), vtos(v), argv(5), "\n"));
867 LOG_INFO("bone not found");
876 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
877 case CMD_REQUEST_USAGE:
879 LOG_HELP("Usage:^3 sv_cmd gettaginfo <model> <frame> <index> [<command1>] [<command2>]");
880 LOG_HELP("See also: ^2bbox, trace^7");
886 void GameCommand_animbench(int request, int argc)
890 case CMD_REQUEST_COMMAND:
896 tmp_entity = spawn();
899 .entity weaponentity = weaponentities[0];
900 _setmodel(tmp_entity, (nextent(NULL)).(weaponentity).model);
904 precache_model(argv(1));
905 _setmodel(tmp_entity, argv(1));
907 float f1 = stof(argv(2));
908 float f2 = stof(argv(3));
916 tmp_entity.frame = f1;
917 t0 = gettime(GETTIME_HIRES);
918 getsurfacepoint(tmp_entity, 0, 0);
919 t1 += gettime(GETTIME_HIRES) - t0;
920 tmp_entity.frame = f2;
921 t0 = gettime(GETTIME_HIRES);
922 getsurfacepoint(tmp_entity, 0, 0);
923 t2 += gettime(GETTIME_HIRES) - t0;
926 LOG_INFO("model ", tmp_entity.model, " frame ", ftos(f1), " animtime ", ftos(n / t1), "/s");
927 LOG_INFO("model ", tmp_entity.model, " frame ", ftos(f2), " animtime ", ftos(n / t2), "/s");
935 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
936 case CMD_REQUEST_USAGE:
938 LOG_HELP("Usage:^3 sv_cmd animbench <model> <frame1> <frame2>");
939 LOG_HELP("See also: ^2bbox, trace^7");
945 void GameCommand_gotomap(int request, int argc)
949 case CMD_REQUEST_COMMAND:
951 if (!world_initialized)
953 LOG_INFOF("This command works only when the server is running.");
958 LOG_INFO(GotoMap(argv(1)));
964 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
965 case CMD_REQUEST_USAGE:
967 LOG_HELP("Usage:^3 sv_cmd gotomap <map>");
968 LOG_HELP(" Where <map> is the *.bsp file to change to.");
969 LOG_HELP("See also: ^2gametype^7");
975 void GameCommand_lockteams(int request)
979 case CMD_REQUEST_COMMAND:
984 bprint("\{1}^1The teams are now locked.\n");
988 bprint("lockteams command can only be used in a team-based gamemode.\n");
994 case CMD_REQUEST_USAGE:
996 LOG_HELP("Usage:^3 sv_cmd lockteams");
997 LOG_HELP(" No arguments required.");
998 LOG_HELP("See also: ^2unlockteams^7");
1004 void GameCommand_make_mapinfo(int request)
1008 case CMD_REQUEST_COMMAND:
1012 tmp_entity = new(make_mapinfo);
1013 setthink(tmp_entity, make_mapinfo_Think);
1014 tmp_entity.nextthink = time;
1015 MapInfo_Enumerate();
1020 case CMD_REQUEST_USAGE:
1022 LOG_HELP("Usage:^3 sv_cmd make_mapinfo");
1023 LOG_HELP(" No arguments required.");
1024 LOG_HELP("See also: ^2radarmap^7");
1030 void GameCommand_setflag(int request, int argc)
1034 case CMD_REQUEST_COMMAND:
1039 client = GetFilteredEntity(argv(1));
1040 accepted = VerifyClientEntity(client, false, false);
1044 LOG_INFO("^1ERROR^7: Couldn't set country flag");
1045 LOG_HELP("Usage:^3 sv_cmd setflag #client_id countrycode[0-249]");
1049 client.countrycode = stof(argv(2));
1050 LOG_INFO("^2SUCCESS^7: Country flag set!");
1054 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
1055 case CMD_REQUEST_USAGE:
1057 LOG_HELP("Usage:^3 sv_cmd setflag #client_id countrycode[0-249]");
1063 void GameCommand_moveplayer(int request, int argc)
1067 case CMD_REQUEST_COMMAND:
1072 string targets = strreplace(",", " ", argv(1));
1073 string original_targets = strreplace(" ", ", ", targets);
1074 string destination = argv(2);
1075 if (destination == "spec")
1076 destination = "spectator";
1078 if ((targets) && (destination))
1080 string successful = string_null;
1085 targets = cdr(targets);
1087 // Check to see if the player is a valid target
1088 client = GetFilteredEntity(t);
1089 accepted = VerifyClientEntity(client, false, false);
1093 LOG_INFO("moveplayer: ", GetClientErrorString(accepted, t), ".");
1095 else if (destination == "spectator")
1097 string pl_name = playername(client.netname, client.team, false);
1098 if (!IS_SPEC(client) && !IS_OBSERVER(client))
1100 if (client.caplayer) client.caplayer = 0;
1101 PutObserverInServer(client);
1103 successful = strcat(successful, (successful ? ", " : ""), pl_name);
1107 LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") is already spectating.");
1114 LOG_INFO("Can't change teams when currently not playing a team game.");
1118 string pl_name = playername(client.netname, client.team, false);
1119 if (IS_SPEC(client) || IS_OBSERVER(client))
1121 // well technically we could, but should we allow that? :P
1122 LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") is not in the game.");
1127 int save = Player_GetForcedTeamIndex(client);
1128 Player_SetForcedTeamIndex(client, TEAM_FORCE_DEFAULT);
1130 // find the team to move the player to
1131 int team_num = Team_ColorToTeam(destination);
1133 if (team_num == client.team) // already on the destination team
1135 // keep the forcing undone
1136 LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") is already on the ", Team_ColoredFullName(team_num), ".");
1139 else if (team_num == 0) // auto team
1141 balance = TeamBalance_CheckAllowedTeams(client);
1142 team_num = Team_IndexToTeam(TeamBalance_FindBestTeam(balance, client, false));
1146 balance = TeamBalance_CheckAllowedTeams(client);
1148 Player_SetForcedTeamIndex(client, save);
1150 // Check to see if the destination team is even available
1151 int team_id = Team_TeamToIndex(team_num);
1154 LOG_INFO("Sorry, can't move player here if team ", destination, " doesn't exist.");
1155 TeamBalance_Destroy(balance);
1158 if (!TeamBalance_IsTeamAllowed(balance, team_id))
1160 LOG_INFOF("Sorry, can't move player to %s team if it doesn't exist.", destination);
1161 TeamBalance_Destroy(balance);
1164 TeamBalance_Destroy(balance);
1166 // If so, lets continue and finally move the player
1167 Player_SetForcedTeamIndex(client, TEAM_FORCE_DEFAULT);
1168 if (MoveToTeam(client, team_id, 6))
1170 successful = strcat(successful, (successful ? ", " : ""), pl_name);
1171 LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") has been moved to the ", Team_ColoredFullName(team_num), "^7.");
1175 LOG_INFO("Unable to move player ", ftos(GetFilteredNumber(t)), " (", pl_name, ")");
1180 if (successful) bprint("Successfully moved players ", successful, " to destination ", destination, ".\n");
1181 else LOG_INFO("No players given (", original_targets, ") are able to move.");
1183 return; // still correct parameters so return to avoid usage print
1188 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
1189 case CMD_REQUEST_USAGE:
1191 LOG_HELP("Usage:^3 sv_cmd moveplayer <clients> <destination>");
1192 LOG_HELP(" <clients> is a list (separated by commas) of player entity ID's or nicknames");
1193 LOG_HELP(" <destination> is what to send the player to, be it team or spectating");
1194 LOG_HELP(" Full list of destinations here: spec, spectator, red, blue, yellow, pink, auto.");
1195 LOG_HELP("Examples: sv_cmd moveplayer 1,3,5 red");
1196 LOG_HELP(" sv_cmd moveplayer 2 spec");
1197 LOG_HELP("See also: ^2allspec, shuffleteams^7");
1203 void GameCommand_nospectators(int request)
1207 case CMD_REQUEST_COMMAND:
1209 blockSpectators = 1;
1210 // give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
1211 FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_SPEC(it) || IS_OBSERVER(it)) && !it.caplayer, {
1214 CS(it).spectatortime = time;
1215 Send_Notification(NOTIF_ONE_ONLY, it, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
1218 bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n"));
1223 case CMD_REQUEST_USAGE:
1225 LOG_HELP("Usage:^3 sv_cmd nospectators");
1226 LOG_HELP(" No arguments required.");
1232 void GameCommand_printstats(int request)
1236 case CMD_REQUEST_COMMAND:
1239 LOG_INFO("stats dumped.");
1244 case CMD_REQUEST_USAGE:
1246 LOG_HELP("Usage:^3 sv_cmd printstats");
1247 LOG_HELP(" No arguments required.");
1253 void GameCommand_radarmap(int request, int argc)
1257 case CMD_REQUEST_COMMAND:
1259 if (RadarMap_Make(argc)) return;
1263 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
1264 case CMD_REQUEST_USAGE:
1266 LOG_HELP("Usage:^3 sv_cmd radarmap [--force] [--loop] [--quit] [--block | --trace | --sample | --lineblock] [--sharpen N] [--res W H] [--qual Q]");
1267 LOG_HELP(" The quality factor Q is roughly proportional to the time taken.");
1268 LOG_HELP(" trace supports no quality factor; its result should look like --block with infinite quality factor.");
1269 LOG_HELP("See also: ^2make_mapinfo^7");
1275 void GameCommand_reducematchtime(int request)
1279 case CMD_REQUEST_COMMAND:
1281 changematchtime(autocvar_timelimit_decrement * -60, autocvar_timelimit_min * 60, autocvar_timelimit_max * 60);
1286 case CMD_REQUEST_USAGE:
1288 LOG_HELP("Usage:^3 sv_cmd reducematchtime");
1289 LOG_HELP(" No arguments required.");
1290 LOG_HELP("See also: ^2extendmatchtime^7");
1296 void GameCommand_setbots(int request, int argc)
1300 case CMD_REQUEST_COMMAND:
1304 cvar_settemp("minplayers", "0");
1305 cvar_settemp("minplayers_per_team", "0");
1306 cvar_settemp("bot_number", argv(1));
1313 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
1314 case CMD_REQUEST_USAGE:
1316 LOG_HELP("Usage:^3 sv_cmd setbots <botnumber>");
1317 LOG_HELP(" Where <botnumber> is the amount of bots to set bot_number cvar to.");
1318 LOG_HELP("See also: ^2bot_cmd^7");
1328 LOG_INFO("Can't shuffle teams when currently not playing a team game.");
1332 FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, {
1333 if (Player_HasRealForcedTeam(it)) {
1334 // we could theoretically assign forced players to their teams
1335 // and shuffle the rest to fill the empty spots but in practise
1336 // either all players or none are gonna have forced teams
1337 LOG_INFO("Can't shuffle teams because at least one player has a forced team.");
1342 int number_of_teams = 0;
1343 entity balance = TeamBalance_CheckAllowedTeams(NULL);
1344 for (int i = 1; i <= NUM_TEAMS; ++i)
1346 if (TeamBalance_IsTeamAllowed(balance, i))
1348 number_of_teams = max(i, number_of_teams);
1351 TeamBalance_Destroy(balance);
1354 FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, {
1355 int target_team_index = team_index + 1;
1356 if (Entity_GetTeamIndex(it) != target_team_index)
1358 MoveToTeam(it, target_team_index, 6);
1360 team_index = (team_index + 1) % number_of_teams;
1363 bprint("Successfully shuffled the players around randomly.\n");
1366 void GameCommand_shuffleteams(int request)
1370 case CMD_REQUEST_COMMAND:
1372 if (shuffleteams_on_reset_map)
1374 bprint("Players will be shuffled when this round is over.\n");
1375 shuffleteams_on_reset_map = true;
1383 case CMD_REQUEST_USAGE:
1385 LOG_HELP("Usage:^3 sv_cmd shuffleteams");
1386 LOG_HELP(" No arguments required.");
1387 LOG_HELP("See also: ^2moveplayer, allspec^7");
1393 void GameCommand_stuffto(int request, int argc)
1395 // This... is a fairly dangerous and powerful command... - It allows any arguments to be sent to a client via rcon.
1396 // Because of this, it is disabled by default and must be enabled by the server owner when doing compilation. That way,
1397 // we can be certain they understand the risks of it... So to enable, compile server with -DSTUFFTO_ENABLED argument.
1399 #ifdef STUFFTO_ENABLED
1402 case CMD_REQUEST_COMMAND:
1406 entity client = GetIndexedEntity(argc, 1);
1407 float accepted = VerifyClientEntity(client, true, false);
1411 stuffcmd(client, strcat("\n", argv(next_token), "\n"));
1412 LOG_INFO("Command: \"", argv(next_token), "\" sent to ", GetCallerName(client), " (", argv(1), ").");
1416 LOG_INFO("stuffto: ", GetClientErrorString(accepted, argv(1)), ".");
1424 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
1425 case CMD_REQUEST_USAGE:
1427 LOG_HELP("Usage:^3 sv_cmd stuffto <client> \"<command>\"");
1428 LOG_HELP(" <client> is the entity number or name of the player,");
1429 LOG_HELP(" and <command> is the command to be sent to that player.");
1436 LOG_HELP("stuffto command is not enabled on this server.");
1442 void GameCommand_trace(int request, int argc)
1446 case CMD_REQUEST_COMMAND:
1449 vector org, delta, start, end, p, q, q0, pos, vv, dv;
1450 float i, f, safe, unsafe, dq, dqf;
1457 LOG_INFO("TEST CASE. If this returns the runaway loop counter error, possibly everything is oaky.");
1458 float worst_endpos_bug = 0;
1462 delta = world.maxs - world.mins;
1464 start.x = org.x + random() * delta.x;
1465 start.y = org.y + random() * delta.y;
1466 start.z = org.z + random() * delta.z;
1468 end.x = org.x + random() * delta.x;
1469 end.y = org.y + random() * delta.y;
1470 end.z = org.z + random() * delta.z;
1472 start = stov(vtos(start));
1473 end = stov(vtos(end));
1475 tracebox(start, PL_MIN_CONST, PL_MAX_CONST, end, MOVE_NOMONSTERS, NULL);
1476 if (!trace_startsolid && trace_fraction < 1)
1479 tracebox(p, PL_MIN_CONST, PL_MAX_CONST, p, MOVE_NOMONSTERS, NULL);
1480 if (trace_startsolid)
1482 rint(42); // do an engine breakpoint on VM_rint so you can get the trace that errnoeously returns startsolid
1483 tracebox(start, PL_MIN_CONST, PL_MAX_CONST, end, MOVE_NOMONSTERS, NULL);
1485 // how much do we need to back off?
1490 pos = p * (1 - (safe + unsafe) * 0.5) + start * ((safe + unsafe) * 0.5);
1491 tracebox(pos, PL_MIN_CONST, PL_MAX_CONST, pos, MOVE_NOMONSTERS, NULL);
1492 if (trace_startsolid)
1494 if ((safe + unsafe) * 0.5 == unsafe) break;
1495 unsafe = (safe + unsafe) * 0.5;
1499 if ((safe + unsafe) * 0.5 == safe) break;
1500 safe = (safe + unsafe) * 0.5;
1504 LOG_INFO("safe distance to back off: ", ftos(safe * vlen(p - start)), "qu");
1505 LOG_INFO("unsafe distance to back off: ", ftos(unsafe * vlen(p - start)), "qu");
1507 tracebox(p, PL_MIN_CONST + '0.1 0.1 0.1', PL_MAX_CONST - '0.1 0.1 0.1', p, MOVE_NOMONSTERS, NULL);
1508 if (trace_startsolid) LOG_INFO("trace_endpos much in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p));
1509 else LOG_INFO("trace_endpos just in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p));
1510 if (++hitcount >= 10) break;
1519 q = p + normalize(end - p) * (dq + dqf);
1521 tracebox(p, PL_MIN_CONST, PL_MAX_CONST, q, MOVE_NOMONSTERS, NULL);
1522 if (trace_startsolid) error("THIS ONE cannot happen");
1523 if (trace_fraction > 0) dq += dqf * trace_fraction;
1527 if (dq > worst_endpos_bug)
1529 worst_endpos_bug = dq;
1530 LOG_INFO("trace_endpos still before solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p));
1531 LOG_INFO("could go ", ftos(dq), " units further to ", vtos(q));
1532 if (++hitcount >= 10) break;
1543 tracebox(e.origin + '0 0 32', e.mins, e.maxs, e.origin + '0 0 -1024', MOVE_NORMAL, e);
1545 if (trace_fraction == 1)
1547 LOG_INFO("not above ground, aborting");
1551 for (i = 0; i < 100000; ++i)
1554 if (dv.z > 0) dv = -1 * dv;
1555 tracebox(vv, e.mins, e.maxs, vv + dv, MOVE_NORMAL, e);
1556 if (trace_startsolid) LOG_INFO("bug 1");
1557 if (trace_fraction == 1)
1561 LOG_INFO("bug 2: ", ftos(dv.x), " ", ftos(dv.y), " ", ftos(dv.z));
1562 LOG_INFO(" (", ftos(asin(dv.z / vlen(dv)) * 180 / M_PI), " degrees)");
1567 LOG_INFO("highest possible dist: ", ftos(f));
1573 if (argc == 4 || argc == 5)
1576 int dphitcontentsmask_save = e.dphitcontentsmask;
1577 e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
1578 if (tracewalk(e, stov(argv(2)), e.mins, e.maxs, stov(argv(3)), stof(argv(4)), MOVE_NORMAL))
1579 LOG_INFO("can walk");
1581 LOG_INFO("cannot walk");
1582 e.dphitcontentsmask = dphitcontentsmask_save;
1593 traceline(vv, dv, MOVE_NORMAL, NULL);
1594 __trailparticles(NULL, particleeffectnum(EFFECT_TR_NEXUIZPLASMA), vv, trace_endpos);
1595 __trailparticles(NULL, particleeffectnum(EFFECT_TR_CRYLINKPLASMA), trace_endpos, dv);
1600 // no default case, just go straight to invalid
1605 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
1606 case CMD_REQUEST_USAGE:
1608 LOG_HELP("Usage:^3 sv_cmd trace <command> [<startpos> <endpos>] [<endpos_height>]");
1609 LOG_HELP(" Where <startpos> and <endpos> are parameters for the 'walk' and 'showline' commands,");
1610 LOG_HELP(" <endpos_height> is an optional parameter for the 'walk' command,");
1611 LOG_HELP(" Full list of commands here: debug, debug2, walk, showline.");
1612 LOG_HELP("See also: ^2bbox, gettaginfo^7");
1618 void GameCommand_unlockteams(int request)
1622 case CMD_REQUEST_COMMAND:
1627 bprint("\{1}^1The teams are now unlocked.\n");
1631 bprint("unlockteams command can only be used in a team-based gamemode.\n");
1637 case CMD_REQUEST_USAGE:
1639 LOG_HELP("Usage:^3 sv_cmd unlockteams");
1640 LOG_HELP(" No arguments required.");
1641 LOG_HELP("See also: ^2lockteams^7");
1647 void GameCommand_warp(int request, int argc)
1651 case CMD_REQUEST_COMMAND:
1653 if (autocvar_g_campaign)
1657 CampaignLevelWarp(stof(argv(1)));
1658 LOG_INFO("Successfully warped to campaign level ", argv(1), ".");
1662 CampaignLevelWarp(-1);
1663 LOG_INFO("Successfully warped to next campaign level.");
1668 LOG_INFO("Not in campaign, can't level warp");
1674 case CMD_REQUEST_USAGE:
1676 LOG_HELP("Usage:^3 sv_cmd warp [<level>]");
1677 LOG_HELP(" <level> is the level to change campaign mode to.");
1678 LOG_HELP(" if <level> is not provided it will change to the next level.");
1684 /* use this when creating a new command, making sure to place it in alphabetical order... also,
1685 ** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION!
1686 void GameCommand_(int request)
1690 case CMD_REQUEST_COMMAND:
1697 case CMD_REQUEST_USAGE:
1699 LOG_HELP("Usage:^3 sv_cmd ");
1700 LOG_HELP(" No arguments required.");
1708 // ==================================
1709 // Macro system for server commands
1710 // ==================================
1712 // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
1713 SERVER_COMMAND(setflag, "Set client flag") { GameCommand_setflag(request, arguments); }
1714 SERVER_COMMAND(teamname, "Set team name") { GameCommand_teamname(request, arguments); }
1716 SERVER_COMMAND(adminmsg, "Send an admin message to a client directly") { GameCommand_adminmsg(request, arguments); }
1717 SERVER_COMMAND(allready, "Restart the server and reset the players") { GameCommand_allready(request); }
1718 SERVER_COMMAND(allspec, "Force all players to spectate") { GameCommand_allspec(request, arguments); }
1719 SERVER_COMMAND(anticheat, "Create an anticheat report for a client") { GameCommand_anticheat(request, arguments); }
1720 SERVER_COMMAND(animbench, "Benchmark model animation (LAGS)") { GameCommand_animbench(request, arguments); }
1721 SERVER_COMMAND(bbox, "Print detailed information about world size") { GameCommand_bbox(request); }
1722 SERVER_COMMAND(bot_cmd, "Control and send commands to bots") { GameCommand_bot_cmd(request, arguments, command); }
1723 SERVER_COMMAND(cointoss, "Flip a virtual coin and give random result") { GameCommand_cointoss(request, arguments); }
1724 SERVER_COMMAND(database, "Extra controls of the serverprogs database") { GameCommand_database(request, arguments); }
1725 SERVER_COMMAND(defer_clear, "Clear all queued defer commands for a specific client") { GameCommand_defer_clear(request, arguments); }
1726 SERVER_COMMAND(defer_clear_all, "Clear all queued defer commands for all clients") { GameCommand_defer_clear_all(request); }
1727 SERVER_COMMAND(delrec, "Delete race time record for a map") { GameCommand_delrec(request, arguments); }
1728 SERVER_COMMAND(effectindexdump, "Dump list of effects from code and effectinfo.txt") { GameCommand_effectindexdump(request); }
1729 SERVER_COMMAND(extendmatchtime, "Increase the timelimit value incrementally") { GameCommand_extendmatchtime(request); }
1730 SERVER_COMMAND(gametype, "Simple command to change the active gametype") { GameCommand_gametype(request, arguments); }
1731 SERVER_COMMAND(gettaginfo, "Get specific information about a weapon model") { GameCommand_gettaginfo(request, arguments); }
1732 SERVER_COMMAND(gotomap, "Simple command to switch to another map") { GameCommand_gotomap(request, arguments); }
1733 SERVER_COMMAND(lockteams, "Disable the ability for players to switch or enter teams") { GameCommand_lockteams(request); }
1734 SERVER_COMMAND(make_mapinfo, "Automatically rebuild mapinfo files") { GameCommand_make_mapinfo(request); }
1735 SERVER_COMMAND(moveplayer, "Change the team/status of a player") { GameCommand_moveplayer(request, arguments); }
1736 SERVER_COMMAND(nospectators, "Automatically remove spectators from a match") { GameCommand_nospectators(request); }
1737 SERVER_COMMAND(printstats, "Dump eventlog player stats and other score information") { GameCommand_printstats(request); }
1738 SERVER_COMMAND(radarmap, "Generate a radar image of the map") { GameCommand_radarmap(request, arguments); }
1739 SERVER_COMMAND(reducematchtime, "Decrease the timelimit value incrementally") { GameCommand_reducematchtime(request); }
1740 SERVER_COMMAND(setbots, "Adjust how many bots are in the match") { GameCommand_setbots(request, arguments); }
1741 SERVER_COMMAND(shuffleteams, "Randomly move players to different teams") { GameCommand_shuffleteams(request); }
1742 SERVER_COMMAND(stuffto, "Send a command to be executed on a client") { GameCommand_stuffto(request, arguments); }
1743 SERVER_COMMAND(trace, "Various debugging tools with tracing") { GameCommand_trace(request, arguments); }
1744 SERVER_COMMAND(unlockteams, "Enable the ability for players to switch or enter teams") { GameCommand_unlockteams(request); }
1745 SERVER_COMMAND(warp, "Choose different level in campaign") { GameCommand_warp(request, arguments); }
1747 void GameCommand_macro_help()
1749 FOREACH(SERVER_COMMANDS, true, { LOG_HELPF(" ^2%s^7: %s", it.m_name, it.m_description); });
1752 float GameCommand_macro_command(int argc, string command)
1754 string c = strtolower(argv(0));
1755 FOREACH(SERVER_COMMANDS, it.m_name == c, {
1756 it.m_invokecmd(it, CMD_REQUEST_COMMAND, NULL, argc, command);
1762 float GameCommand_macro_usage(int argc)
1764 string c = strtolower(argv(1));
1765 FOREACH(SERVER_COMMANDS, it.m_name == c, {
1766 it.m_invokecmd(it, CMD_REQUEST_USAGE, NULL, argc, "");
1772 void GameCommand_macro_write_aliases(float fh)
1774 FOREACH(SERVER_COMMANDS, true, { CMD_Write_Alias("qc_cmd_sv", it.m_name, it.m_description); });
1778 // =========================================
1779 // Main Function Called By Engine (sv_cmd)
1780 // =========================================
1781 // If this function exists, game code handles gamecommand instead of the engine code.
1783 void GameCommand(string command)
1785 int argc = tokenize_console(command);
1787 // Guide for working with argc arguments by example:
1788 // argc: 1 - 2 - 3 - 4
1789 // argv: 0 - 1 - 2 - 3
1790 // cmd vote - master - login - password
1792 if (strtolower(argv(0)) == "help")
1796 LOG_HELP("Server console commands:");
1797 GameCommand_macro_help();
1799 LOG_HELP("\nBanning commands:");
1800 BanCommand_macro_help();
1802 LOG_HELP("\nCommon networked commands:");
1803 CommonCommand_macro_help(NULL);
1805 LOG_HELP("\nGeneric commands shared by all programs:");
1806 GenericCommand_macro_help();
1808 LOG_HELP("\nUsage:^3 sv_cmd <command>^7, where possible commands are listed above.\n"
1809 "For help about a specific command, type sv_cmd help <command>");
1813 else if (BanCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it
1817 else if (CommonCommand_macro_usage(argc, NULL)) // same here, but for common commands instead
1821 else if (GenericCommand_macro_usage(argc)) // same here, but for generic commands instead
1825 else if (GameCommand_macro_usage(argc)) // finally try for normal commands too
1830 else if (MUTATOR_CALLHOOK(SV_ParseServerCommand, strtolower(argv(0)), argc, command))
1832 return; // handled by a mutator
1834 else if (BanCommand(command))
1836 return; // handled by server/command/ipban.qc
1838 else if (CommonCommand_macro_command(argc, NULL, command))
1840 return; // handled by server/command/common.qc
1842 else if (GenericCommand(command))
1844 return; // handled by common/command/generic.qc
1846 else if (GameCommand_macro_command(argc, command)) // continue as usual and scan for normal commands
1848 return; // handled by one of the above GameCommand_* functions
1851 // nothing above caught the command, must be invalid
1852 LOG_INFO(((command != "") ? strcat("Unknown server command \"", command, "\"") : "No command provided"), ". For a list of supported commands, try sv_cmd help.");