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.");
234 void GameCommand_stop(int request, int argc)
238 case CMD_REQUEST_COMMAND:
240 if(argv(1) == "true")
243 game_stopped = false;
248 case CMD_REQUEST_USAGE:
250 LOG_HELP("Usage:^3 sv_cmd stop");
251 LOG_HELP(" No arguments required.");
257 void GameCommand_allspec(int request, int argc)
261 case CMD_REQUEST_COMMAND:
263 string reason = argv(1);
265 FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
266 if (it.caplayer) it.caplayer = 0;
267 PutObserverInServer(it);
270 if (n) bprint(strcat("Successfully forced all (", ftos(n), ") players to spectate", (reason ? strcat(" for reason: '", reason, "'") : ""), ".\n"));
271 else LOG_INFO("No players found to spectate.");
276 case CMD_REQUEST_USAGE:
278 LOG_HELP("Usage:^3 sv_cmd allspec [reason]");
279 LOG_HELP(" Where 'reason' is an optional argument for explanation of allspec command.");
280 LOG_HELP("See also: ^2moveplayer, shuffleteams^7");
286 void GameCommand_anticheat(int request, int argc)
290 case CMD_REQUEST_COMMAND:
292 entity client = GetIndexedEntity(argc, 1);
293 float accepted = VerifyClientEntity(client, false, false);
297 anticheat_report_to_eventlog(client);
302 LOG_INFO("anticheat: ", GetClientErrorString(accepted, argv(1)), ".");
307 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
308 case CMD_REQUEST_USAGE:
310 LOG_HELP("Usage:^3 sv_cmd anticheat client");
311 LOG_HELP(" 'client' is the entity number or name of the player.");
317 void GameCommand_bbox(int request)
321 case CMD_REQUEST_COMMAND:
323 vector size_min = '0 0 0';
324 vector size_max = '0 0 0';
325 tracebox('1 0 0' * world.absmin.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.absmax.x,
331 size_min.x = (trace_startsolid) ? world.absmin.x : trace_endpos.x;
333 tracebox('0 1 0' * world.absmin.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.absmax.y,
339 size_min.y = (trace_startsolid) ? world.absmin.y : trace_endpos.y;
341 tracebox('0 0 1' * world.absmin.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.absmax.z,
347 size_min.z = (trace_startsolid) ? world.absmin.z : trace_endpos.z;
349 tracebox('1 0 0' * world.absmax.x,
350 '0 1 0' * world.absmin.y + '0 0 1' * world.absmin.z,
351 '0 1 0' * world.absmax.y + '0 0 1' * world.absmax.z,
352 '1 0 0' * world.absmin.x,
355 size_max.x = (trace_startsolid) ? world.absmax.x : trace_endpos.x;
357 tracebox('0 1 0' * world.absmax.y,
358 '1 0 0' * world.absmin.x + '0 0 1' * world.absmin.z,
359 '1 0 0' * world.absmax.x + '0 0 1' * world.absmax.z,
360 '0 1 0' * world.absmin.y,
363 size_max.y = (trace_startsolid) ? world.absmax.y : trace_endpos.y;
365 tracebox('0 0 1' * world.absmax.z,
366 '1 0 0' * world.absmin.x + '0 1 0' * world.absmin.y,
367 '1 0 0' * world.absmax.x + '0 1 0' * world.absmax.y,
368 '0 0 1' * world.absmin.z,
371 size_max.z = (trace_startsolid) ? world.absmax.z : trace_endpos.z;
373 LOG_INFOF("Original size: %v %v", world.absmin, world.absmax);
374 LOG_INFOF("Currently set size: %v %v", world.mins, world.maxs);
375 LOG_INFOF("Solid bounding box size: %v %v", size_min, size_max);
380 case CMD_REQUEST_USAGE:
382 LOG_HELP("Usage:^3 sv_cmd bbox");
383 LOG_HELP(" No arguments required.");
384 LOG_HELP("See also: ^2gettaginfo, trace^7");
390 void GameCommand_bot_cmd(int request, int argc, string command)
394 case CMD_REQUEST_COMMAND:
398 if (argv(1) == "reset")
403 else if (argv(1) == "setbots")
405 cvar_settemp("bot_vs_human", "0");
406 cvar_settemp("minplayers", "0");
407 cvar_settemp("minplayers_per_team", "0");
408 cvar_settemp("bot_number", "0");
410 cvar_settemp("bot_number", argv(2));
411 if (!bot_fixcount()) LOG_INFO("Sorry, could not set requested bot count");
414 else if (argv(1) == "load" && argc == 3)
418 fh = fopen(argv(2), FILE_READ);
421 LOG_INFO("cannot open the file");
426 while ((s = fgets(fh)))
428 argc = tokenize_console(s);
430 if (argc >= 3 && argv(0) == "sv_cmd" && argv(1) == "bot_cmd")
432 if (argv(2) == "reset")
436 else if (argv(2) == "setbots")
438 cvar_settemp("bot_vs_human", "0");
439 cvar_settemp("minplayers", "0");
440 cvar_settemp("minplayers_per_team", "0");
441 cvar_settemp("bot_number", "0");
443 cvar_settemp("bot_number", argv(3));
444 if (!bot_fixcount()) LOG_INFO("Sorry, could not set requested bot count");
448 if(argv(2) == "*" || argv(2) == "all")
449 FOREACH_CLIENT(IS_BOT_CLIENT(it), {
450 bot_queuecommand(it, substring(s, argv_start_index(3), -1));
454 bot = find_bot_by_number(stof(argv(2)));
455 if (bot == NULL) bot = find_bot_by_name(argv(2));
456 if (bot) bot_queuecommand(bot, substring(s, argv_start_index(3), -1));
462 localcmd(strcat(s, "\n"));
467 LOG_INFO(ftos(i), " commands read");
471 else if (argv(1) == "help")
473 if (argv(2)) bot_cmdhelp(argv(2));
474 else bot_list_commands();
477 else if (argc >= 3) // this comes last
479 if(argv(1) == "*" || argv(1) == "all")
482 FOREACH_CLIENT(IS_BOT_CLIENT(it), {
483 bot_queuecommand(it, substring(command, argv_start_index(2), -1));
487 LOG_INFO("Command '", substring(command, argv_start_index(2), -1), "' sent to all bots (", ftos(bot_num), ")");
492 bot = find_bot_by_number(stof(argv(1)));
493 if (bot == NULL) bot = find_bot_by_name(argv(1));
496 LOG_INFO("Command '", substring(command, argv_start_index(2), -1), "' sent to bot ", bot.netname);
497 bot_queuecommand(bot, substring(command, argv_start_index(2), -1));
502 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
509 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
510 case CMD_REQUEST_USAGE:
512 LOG_HELP("Usage:^3 sv_cmd bot_cmd client command [argument]");
513 LOG_HELP(" 'client' can be either the name of the bot or a progressive number (not the entity number!)");
514 LOG_HELP(" can also be '*' or 'all' to allow sending the command to all the bots");
515 LOG_HELP(" For full list of commands, see bot_cmd help [command].");
516 LOG_HELP("Examples: sv_cmd bot_cmd 1 cc \"say something\"");
517 LOG_HELP(" sv_cmd bot_cmd 1 presskey jump");
518 LOG_HELP(" sv_cmd bot_cmd * pause");
524 void GameCommand_cointoss(int request, int argc)
528 case CMD_REQUEST_COMMAND:
530 string result1 = (argv(2) ? strcat("^7", argv(1)) : "^1HEADS");
531 string result2 = (argv(2) ? strcat("^7", argv(2)) : "^4TAILS");
532 string choice = ((random() > 0.5) ? result1 : result2);
534 Send_Notification(NOTIF_ALL, NULL, MSG_MULTI, MULTI_COINTOSS, choice);
539 case CMD_REQUEST_USAGE:
541 LOG_HELP("Usage:^3 sv_cmd cointoss [result1 result2]");
542 LOG_HELP(" Where 'result1' and 'result2' are user created options.");
548 void GameCommand_database(int request, int argc)
552 case CMD_REQUEST_COMMAND:
556 if (argv(1) == "save")
558 db_save(ServerProgsDB, argv(2));
559 LOG_INFO("Copied serverprogs database to '", argv(2), "' in the data directory.");
562 else if (argv(1) == "dump")
564 db_dump(ServerProgsDB, argv(2));
565 LOG_INFO("DB dumped."); // wtf does this do?
568 else if (argv(1) == "load")
570 db_close(ServerProgsDB);
571 ServerProgsDB = db_load(argv(2));
572 LOG_INFO("Loaded '", argv(2), "' as new serverprogs database.");
579 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
580 case CMD_REQUEST_USAGE:
582 LOG_HELP("Usage:^3 sv_cmd database action filename");
583 LOG_HELP(" Where 'action' is the command to complete,");
584 LOG_HELP(" and 'filename' is what it acts upon.");
585 LOG_HELP(" Full list of commands here: \"save, dump, load.\"");
591 void GameCommand_defer_clear(int request, int argc)
595 case CMD_REQUEST_COMMAND:
602 client = GetIndexedEntity(argc, 1);
603 accepted = VerifyClientEntity(client, true, false);
607 stuffcmd(client, "defer clear\n");
608 LOG_INFO("defer clear stuffed to ", playername(client.netname, client.team, false));
610 else { LOG_INFO("defer_clear: ", GetClientErrorString(accepted, argv(1)), "."); }
617 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
618 case CMD_REQUEST_USAGE:
620 LOG_HELP("Usage:^3 sv_cmd defer_clear client");
621 LOG_HELP(" 'client' is the entity number or name of the player.");
622 LOG_HELP("See also: ^2defer_clear_all^7");
628 void GameCommand_defer_clear_all(int request)
632 case CMD_REQUEST_COMMAND:
637 FOREACH_CLIENT(true, {
638 argc = tokenize_console(strcat("defer_clear ", ftos(etof(it))));
639 GameCommand_defer_clear(CMD_REQUEST_COMMAND, argc);
642 if (n) LOG_INFO("Successfully stuffed defer clear to all clients (", ftos(n), ")"); // should a message be added if no players were found?
647 case CMD_REQUEST_USAGE:
649 LOG_HELP("Usage:^3 sv_cmd defer_clear_all");
650 LOG_HELP(" No arguments required.");
651 LOG_HELP("See also: ^2defer_clear^7");
657 void GameCommand_delrec(int request, int argc) // perhaps merge later with records and printstats and such?
661 case CMD_REQUEST_COMMAND:
665 if (argv(2)) race_deleteTime(argv(2), stof(argv(1)));
666 else race_deleteTime(GetMapname(), stof(argv(1)));
672 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
673 case CMD_REQUEST_USAGE:
675 LOG_HELP("Usage:^3 sv_cmd delrec ranking [map]");
676 LOG_HELP(" 'ranking' is which ranking level to clear up to, ");
677 LOG_HELP(" it will clear all records up to nth place.");
678 LOG_HELP(" if 'map' is not provided it will use current map.");
684 void print_Effect_Index(int d, string effect_name)
686 // this is inside a function to avoid expanding it on compilation everytime
687 LOG_INFO("effect ", effect_name, " is ", ftos(_particleeffectnum(effect_name)), "\n");
688 db_put(d, effect_name, "1");
691 void GameCommand_effectindexdump(int request)
695 case CMD_REQUEST_COMMAND:
701 LOG_INFO("begin of effects list");
703 print_Effect_Index(d, "TE_GUNSHOT");
704 print_Effect_Index(d, "TE_GUNSHOTQUAD");
705 print_Effect_Index(d, "TE_SPIKE");
706 print_Effect_Index(d, "TE_SPIKEQUAD");
707 print_Effect_Index(d, "TE_SUPERSPIKE");
708 print_Effect_Index(d, "TE_SUPERSPIKEQUAD");
709 print_Effect_Index(d, "TE_WIZSPIKE");
710 print_Effect_Index(d, "TE_KNIGHTSPIKE");
711 print_Effect_Index(d, "TE_EXPLOSION");
712 print_Effect_Index(d, "TE_EXPLOSIONQUAD");
713 print_Effect_Index(d, "TE_TAREXPLOSION");
714 print_Effect_Index(d, "TE_TELEPORT");
715 print_Effect_Index(d, "TE_LAVASPLASH");
716 print_Effect_Index(d, "TE_SMALLFLASH");
717 print_Effect_Index(d, "TE_FLAMEJET");
718 print_Effect_Index(d, "EF_FLAME");
719 print_Effect_Index(d, "TE_BLOOD");
720 print_Effect_Index(d, "TE_SPARK");
721 print_Effect_Index(d, "TE_PLASMABURN");
722 print_Effect_Index(d, "TE_TEI_G3");
723 print_Effect_Index(d, "TE_TEI_SMOKE");
724 print_Effect_Index(d, "TE_TEI_BIGEXPLOSION");
725 print_Effect_Index(d, "TE_TEI_PLASMAHIT");
726 print_Effect_Index(d, "EF_STARDUST");
727 print_Effect_Index(d, "TR_ROCKET");
728 print_Effect_Index(d, "TR_GRENADE");
729 print_Effect_Index(d, "TR_BLOOD");
730 print_Effect_Index(d, "TR_WIZSPIKE");
731 print_Effect_Index(d, "TR_SLIGHTBLOOD");
732 print_Effect_Index(d, "TR_KNIGHTSPIKE");
733 print_Effect_Index(d, "TR_VORESPIKE");
734 print_Effect_Index(d, "TR_NEHAHRASMOKE");
735 print_Effect_Index(d, "TR_NEXUIZPLASMA");
736 print_Effect_Index(d, "TR_GLOWTRAIL");
737 print_Effect_Index(d, "TR_SEEKER");
738 print_Effect_Index(d, "SVC_PARTICLE");
740 fh = fopen("effectinfo.txt", FILE_READ);
741 while ((s = fgets(fh)))
744 if (argv(0) == "effect")
746 if (db_get(d, argv(1)) != "1")
748 int i = _particleeffectnum(argv(1));
749 if (i >= 0) LOG_INFO("effect ", argv(1), " is ", ftos(i));
750 db_put(d, argv(1), "1");
754 LOG_INFO("end of effects list");
761 case CMD_REQUEST_USAGE:
763 LOG_HELP("Usage:^3 sv_cmd effectindexdump");
764 LOG_HELP(" No arguments required.");
770 void GameCommand_extendmatchtime(int request)
774 case CMD_REQUEST_COMMAND:
776 changematchtime(autocvar_timelimit_increment * 60, autocvar_timelimit_min * 60, autocvar_timelimit_max * 60);
781 case CMD_REQUEST_USAGE:
783 LOG_HELP("Usage:^3 sv_cmd extendmatchtime");
784 LOG_HELP(" No arguments required.");
785 LOG_HELP("See also: ^2reducematchtime^7");
791 void GameCommand_gametype(int request, int argc)
795 case CMD_REQUEST_COMMAND:
800 Gametype t = MapInfo_Type_FromString(s, false), tsave = MapInfo_CurrentGametype();
804 MapInfo_SwitchGameType(t);
805 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
806 if (MapInfo_count > 0)
808 // update lsmaps in case the gametype changed, this way people can easily list maps for it
809 if (lsmaps_reply != "") strunzone(lsmaps_reply);
810 lsmaps_reply = strzone(getlsmaps());
811 bprint("Game type successfully switched to ", s, "\n");
815 bprint("Cannot use this game type: no map for it found\n");
816 MapInfo_SwitchGameType(tsave);
817 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
822 bprint("Game type switch to ", s, " failed: this type does not exist!\n");
830 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
831 case CMD_REQUEST_USAGE:
833 LOG_HELP("Usage:^3 sv_cmd gametype mode");
834 LOG_HELP(" Where 'mode' is the gametype mode to switch to.");
835 LOG_HELP("See also: ^2gotomap^7");
841 void GameCommand_gettaginfo(int request, int argc)
845 case CMD_REQUEST_COMMAND:
853 tmp_entity = spawn();
856 .entity weaponentity = weaponentities[0];
857 _setmodel(tmp_entity, (nextent(NULL)).(weaponentity).model);
861 precache_model(argv(1));
862 _setmodel(tmp_entity, argv(1));
864 tmp_entity.frame = stof(argv(2));
865 if (substring(argv(3), 0, 1) == "#") i = stof(substring(argv(3), 1, -1));
866 else i = gettagindex(tmp_entity, argv(3));
869 v = gettaginfo(tmp_entity, i);
871 "model %s frame %s tag %s index %s parent %s",
872 tmp_entity.model, ftos(tmp_entity.frame), gettaginfo_name, ftos(i), ftos(gettaginfo_parent)
874 LOG_INFOF(" vector = %s %s %s", ftos(v.x), ftos(v.y), ftos(v.z));
875 LOG_INFOF(" offset = %s %s %s", ftos(gettaginfo_offset.x), ftos(gettaginfo_offset.y), ftos(gettaginfo_offset.z));
876 LOG_INFOF(" forward = %s %s %s", ftos(gettaginfo_forward.x), ftos(gettaginfo_forward.y), ftos(gettaginfo_forward.z));
877 LOG_INFOF(" right = %s %s %s", ftos(gettaginfo_right.x), ftos(gettaginfo_right.y), ftos(gettaginfo_right.z));
878 LOG_INFOF(" up = %s %s %s", ftos(gettaginfo_up.x), ftos(gettaginfo_up.y), ftos(gettaginfo_up.z));
882 localcmd(strcat(argv(4), vtos(v), argv(5), "\n"));
887 LOG_INFO("bone not found");
896 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
897 case CMD_REQUEST_USAGE:
899 LOG_HELP("Usage:^3 sv_cmd gettaginfo model frame index [command one] [command two]");
900 LOG_HELP("See also: ^2bbox, trace^7");
906 void GameCommand_animbench(int request, int argc)
910 case CMD_REQUEST_COMMAND:
916 tmp_entity = spawn();
919 .entity weaponentity = weaponentities[0];
920 _setmodel(tmp_entity, (nextent(NULL)).(weaponentity).model);
924 precache_model(argv(1));
925 _setmodel(tmp_entity, argv(1));
927 float f1 = stof(argv(2));
928 float f2 = stof(argv(3));
936 tmp_entity.frame = f1;
937 t0 = gettime(GETTIME_HIRES);
938 getsurfacepoint(tmp_entity, 0, 0);
939 t1 += gettime(GETTIME_HIRES) - t0;
940 tmp_entity.frame = f2;
941 t0 = gettime(GETTIME_HIRES);
942 getsurfacepoint(tmp_entity, 0, 0);
943 t2 += gettime(GETTIME_HIRES) - t0;
946 LOG_INFO("model ", tmp_entity.model, " frame ", ftos(f1), " animtime ", ftos(n / t1), "/s");
947 LOG_INFO("model ", tmp_entity.model, " frame ", ftos(f2), " animtime ", ftos(n / t2), "/s");
955 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
956 case CMD_REQUEST_USAGE:
958 LOG_HELP("Usage:^3 sv_cmd gettaginfo model frame index [command one] [command two]");
959 LOG_HELP("See also: ^2bbox, trace^7");
965 void GameCommand_gotomap(int request, int argc)
969 case CMD_REQUEST_COMMAND:
973 LOG_INFO(GotoMap(argv(1)));
979 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
980 case CMD_REQUEST_USAGE:
982 LOG_HELP("Usage:^3 sv_cmd gotomap map");
983 LOG_HELP(" Where 'map' is the *.bsp file to change to.");
984 LOG_HELP("See also: ^2gametype^7");
990 void GameCommand_lockteams(int request)
994 case CMD_REQUEST_COMMAND:
999 bprint("\{1}^1The teams are now locked.\n");
1003 bprint("lockteams command can only be used in a team-based gamemode.\n");
1009 case CMD_REQUEST_USAGE:
1011 LOG_HELP("Usage:^3 sv_cmd lockteams");
1012 LOG_HELP(" No arguments required.");
1013 LOG_HELP("See also: ^2unlockteams^7");
1019 void GameCommand_make_mapinfo(int request)
1023 case CMD_REQUEST_COMMAND:
1027 tmp_entity = new(make_mapinfo);
1028 setthink(tmp_entity, make_mapinfo_Think);
1029 tmp_entity.nextthink = time;
1030 MapInfo_Enumerate();
1035 case CMD_REQUEST_USAGE:
1037 LOG_HELP("Usage:^3 sv_cmd make_mapinfo");
1038 LOG_HELP(" No arguments required.");
1039 LOG_HELP("See also: ^2radarmap^7");
1045 void GameCommand_setflag(int request, int argc)
1049 case CMD_REQUEST_COMMAND:
1055 client = GetFilteredEntity(argv(1));
1056 accepted = VerifyClientEntity(client, false, false);
1060 LOG_INFO("setflag error");
1064 client.countrycode = stof(argv(2));
1067 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
1068 case CMD_REQUEST_USAGE:
1070 LOG_HELP("Usage:^3 sv_cmd setflag client countrycode");
1076 void GameCommand_moveplayer(int request, int argc)
1080 case CMD_REQUEST_COMMAND:
1085 string targets = strreplace(",", " ", argv(1));
1086 string original_targets = strreplace(" ", ", ", targets);
1087 string destination = argv(2);
1089 string successful, t;
1090 successful = string_null;
1092 // lets see if the target(s) even actually exist.
1093 if ((targets) && (destination))
1098 targets = cdr(targets);
1100 // Check to see if the player is a valid target
1101 client = GetFilteredEntity(t);
1102 accepted = VerifyClientEntity(client, false, false);
1106 LOG_INFO("moveplayer: ", GetClientErrorString(accepted, t), (targets ? ", skipping to next player.\n" : "."));
1110 // Where are we putting this player?
1111 if (destination == "spec" || destination == "spectator")
1113 if (!IS_SPEC(client) && !IS_OBSERVER(client))
1115 if (client.caplayer) client.caplayer = 0;
1116 PutObserverInServer(client);
1118 successful = strcat(successful, (successful ? ", " : ""), playername(client.netname, client.team, false));
1122 LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", playername(client.netname, client.team, false), ") is already spectating.");
1128 if (!IS_SPEC(client) && !IS_OBSERVER(client))
1133 int save = Player_GetForcedTeamIndex(client);
1134 Player_SetForcedTeamIndex(client, TEAM_FORCE_DEFAULT);
1136 // find the team to move the player to
1137 int team_num = Team_ColorToTeam(destination);
1139 if (team_num == client.team) // already on the destination team
1141 // keep the forcing undone
1142 LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", playername(client.netname, client.team, false), ") is already on the ", Team_ColoredFullName(client.team), (targets ? "^7, skipping to next player.\n" : "^7."));
1145 else if (team_num == 0) // auto team
1147 balance = TeamBalance_CheckAllowedTeams(client);
1148 team_num = Team_IndexToTeam(TeamBalance_FindBestTeam(balance, client, false));
1152 balance = TeamBalance_CheckAllowedTeams(client);
1154 Player_SetForcedTeamIndex(client, save);
1156 // Check to see if the destination team is even available
1157 int team_id = Team_TeamToIndex(team_num);
1160 LOG_INFO("Sorry, can't move player here if team ", destination, " doesn't exist.");
1161 TeamBalance_Destroy(balance);
1164 if (!TeamBalance_IsTeamAllowed(balance, team_id))
1166 LOG_INFOF("Sorry, can't move player to %s team if it doesn't exist.", destination);
1167 TeamBalance_Destroy(balance);
1170 TeamBalance_Destroy(balance);
1172 // If so, lets continue and finally move the player
1173 Player_SetForcedTeamIndex(client, TEAM_FORCE_DEFAULT);
1174 if (MoveToTeam(client, team_id, 6))
1176 successful = strcat(successful, (successful ? ", " : ""), playername(client.netname, client.team, false));
1177 LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", playername(client.netname, client.team, false), ") has been moved to the ", Team_ColoredFullName(team_id), "^7.");
1181 LOG_INFO("Unable to move player ", ftos(GetFilteredNumber(t)), " (", playername(client.netname, client.team, false), ")");
1187 LOG_INFO("Can't change teams when currently not playing a team game.");
1193 LOG_INFO("Can't change teams if the player isn't in the game."); // well technically we could, but should we allow that? :P
1199 if (successful) bprint("Successfully moved players ", successful, " to destination ", destination, ".\n");
1200 else LOG_INFO("No players given (", original_targets, ") are able to move.");
1202 return; // still correct parameters so return to avoid usage print
1207 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
1208 case CMD_REQUEST_USAGE:
1210 LOG_HELP("Usage:^3 sv_cmd moveplayer clients destination");
1211 LOG_HELP(" 'clients' is a list (separated by commas) of player entity ID's or nicknames");
1212 LOG_HELP(" 'destination' is what to send the player to, be it team or spectating");
1213 LOG_HELP(" Full list of destinations here: \"spec, spectator, red, blue, yellow, pink, auto.\"");
1214 LOG_HELP("Examples: sv_cmd moveplayer 1,3,5 red");
1215 LOG_HELP(" sv_cmd moveplayer 2 spec");
1216 LOG_HELP("See also: ^2allspec, shuffleteams^7");
1222 void GameCommand_nospectators(int request)
1226 case CMD_REQUEST_COMMAND:
1228 blockSpectators = 1;
1229 // give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
1230 FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_SPEC(it) || IS_OBSERVER(it)) && !it.caplayer, {
1233 CS(it).spectatortime = time;
1234 Send_Notification(NOTIF_ONE_ONLY, it, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
1237 bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n"));
1242 case CMD_REQUEST_USAGE:
1244 LOG_HELP("Usage:^3 sv_cmd nospectators");
1245 LOG_HELP(" No arguments required.");
1251 void GameCommand_printstats(int request)
1255 case CMD_REQUEST_COMMAND:
1258 LOG_INFO("stats dumped.");
1263 case CMD_REQUEST_USAGE:
1265 LOG_HELP("Usage:^3 sv_cmd printstats");
1266 LOG_HELP(" No arguments required.");
1272 void GameCommand_radarmap(int request, int argc)
1276 case CMD_REQUEST_COMMAND:
1278 if (RadarMap_Make(argc)) return;
1282 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
1283 case CMD_REQUEST_USAGE:
1285 LOG_HELP("Usage:^3 sv_cmd radarmap [--force] [--loop] [--quit] [--block | --trace | --sample | --lineblock] [--sharpen N] [--res W H] [--qual Q]");
1286 LOG_HELP(" The quality factor Q is roughly proportional to the time taken.");
1287 LOG_HELP(" trace supports no quality factor; its result should look like --block with infinite quality factor.");
1288 LOG_HELP("See also: ^2make_mapinfo^7");
1294 void GameCommand_reducematchtime(int request)
1298 case CMD_REQUEST_COMMAND:
1300 changematchtime(autocvar_timelimit_decrement * -60, autocvar_timelimit_min * 60, autocvar_timelimit_max * 60);
1305 case CMD_REQUEST_USAGE:
1307 LOG_HELP("Usage:^3 sv_cmd reducematchtime");
1308 LOG_HELP(" No arguments required.");
1309 LOG_HELP("See also: ^2extendmatchtime^7");
1315 void GameCommand_setbots(int request, int argc)
1319 case CMD_REQUEST_COMMAND:
1323 cvar_settemp("minplayers", "0");
1324 cvar_settemp("minplayers_per_team", "0");
1325 cvar_settemp("bot_number", argv(1));
1332 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
1333 case CMD_REQUEST_USAGE:
1335 LOG_HELP("Usage:^3 sv_cmd setbots botnumber");
1336 LOG_HELP(" Where 'botnumber' is the amount of bots to set bot_number cvar to.");
1337 LOG_HELP("See also: ^2bot_cmd^7");
1347 LOG_INFO("Can't shuffle teams when currently not playing a team game.");
1351 FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, {
1352 if (Player_HasRealForcedTeam(it)) {
1353 // we could theoretically assign forced players to their teams
1354 // and shuffle the rest to fill the empty spots but in practise
1355 // either all players or none are gonna have forced teams
1356 LOG_INFO("Can't shuffle teams because at least one player has a forced team.");
1361 int number_of_teams = 0;
1362 entity balance = TeamBalance_CheckAllowedTeams(NULL);
1363 for (int i = 1; i <= NUM_TEAMS; ++i)
1365 if (TeamBalance_IsTeamAllowed(balance, i))
1367 number_of_teams = max(i, number_of_teams);
1370 TeamBalance_Destroy(balance);
1373 FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, {
1374 int target_team_index = team_index + 1;
1375 if (Entity_GetTeamIndex(it) != target_team_index)
1377 MoveToTeam(it, target_team_index, 6);
1379 team_index = (team_index + 1) % number_of_teams;
1382 bprint("Successfully shuffled the players around randomly.\n");
1385 void GameCommand_shuffleteams(int request)
1389 case CMD_REQUEST_COMMAND:
1391 if (shuffleteams_on_reset_map)
1393 bprint("Players will be shuffled when this round is over.\n");
1394 shuffleteams_on_reset_map = true;
1402 case CMD_REQUEST_USAGE:
1404 LOG_HELP("Usage:^3 sv_cmd shuffleteams");
1405 LOG_HELP(" No arguments required.");
1406 LOG_HELP("See also: ^2moveplayer, allspec^7");
1412 void GameCommand_stuffto(int request, int argc)
1414 // This... is a fairly dangerous and powerful command... - It allows any arguments to be sent to a client via rcon.
1415 // Because of this, it is disabled by default and must be enabled by the server owner when doing compilation. That way,
1416 // we can be certain they understand the risks of it... So to enable, compile server with -DSTUFFTO_ENABLED argument.
1418 #ifdef STUFFTO_ENABLED
1421 case CMD_REQUEST_COMMAND:
1425 entity client = GetIndexedEntity(argc, 1);
1426 float accepted = VerifyClientEntity(client, true, false);
1430 stuffcmd(client, strcat("\n", argv(next_token), "\n"));
1431 LOG_INFO("Command: \"", argv(next_token), "\" sent to ", GetCallerName(client), " (", argv(1), ").");
1435 LOG_INFO("stuffto: ", GetClientErrorString(accepted, argv(1)), ".");
1443 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
1444 case CMD_REQUEST_USAGE:
1446 LOG_HELP("Usage:^3 sv_cmd stuffto client \"command\"");
1447 LOG_HELP(" 'client' is the entity number or name of the player,");
1448 LOG_HELP(" and 'command' is the command to be sent to that player.");
1455 LOG_HELP("stuffto command is not enabled on this server.");
1461 void GameCommand_trace(int request, int argc)
1465 case CMD_REQUEST_COMMAND:
1468 vector org, delta, start, end, p, q, q0, pos, vv, dv;
1469 float i, f, safe, unsafe, dq, dqf;
1476 LOG_INFO("TEST CASE. If this returns the runaway loop counter error, possibly everything is oaky.");
1477 float worst_endpos_bug = 0;
1481 delta = world.maxs - world.mins;
1483 start.x = org.x + random() * delta.x;
1484 start.y = org.y + random() * delta.y;
1485 start.z = org.z + random() * delta.z;
1487 end.x = org.x + random() * delta.x;
1488 end.y = org.y + random() * delta.y;
1489 end.z = org.z + random() * delta.z;
1491 start = stov(vtos(start));
1492 end = stov(vtos(end));
1494 tracebox(start, PL_MIN_CONST, PL_MAX_CONST, end, MOVE_NOMONSTERS, NULL);
1495 if (!trace_startsolid && trace_fraction < 1)
1498 tracebox(p, PL_MIN_CONST, PL_MAX_CONST, p, MOVE_NOMONSTERS, NULL);
1499 if (trace_startsolid)
1501 rint(42); // do an engine breakpoint on VM_rint so you can get the trace that errnoeously returns startsolid
1502 tracebox(start, PL_MIN_CONST, PL_MAX_CONST, end, MOVE_NOMONSTERS, NULL);
1504 // how much do we need to back off?
1509 pos = p * (1 - (safe + unsafe) * 0.5) + start * ((safe + unsafe) * 0.5);
1510 tracebox(pos, PL_MIN_CONST, PL_MAX_CONST, pos, MOVE_NOMONSTERS, NULL);
1511 if (trace_startsolid)
1513 if ((safe + unsafe) * 0.5 == unsafe) break;
1514 unsafe = (safe + unsafe) * 0.5;
1518 if ((safe + unsafe) * 0.5 == safe) break;
1519 safe = (safe + unsafe) * 0.5;
1523 LOG_INFO("safe distance to back off: ", ftos(safe * vlen(p - start)), "qu");
1524 LOG_INFO("unsafe distance to back off: ", ftos(unsafe * vlen(p - start)), "qu");
1526 tracebox(p, PL_MIN_CONST + '0.1 0.1 0.1', PL_MAX_CONST - '0.1 0.1 0.1', p, MOVE_NOMONSTERS, NULL);
1527 if (trace_startsolid) LOG_INFO("trace_endpos much in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p));
1528 else LOG_INFO("trace_endpos just in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p));
1529 if (++hitcount >= 10) break;
1538 q = p + normalize(end - p) * (dq + dqf);
1540 tracebox(p, PL_MIN_CONST, PL_MAX_CONST, q, MOVE_NOMONSTERS, NULL);
1541 if (trace_startsolid) error("THIS ONE cannot happen");
1542 if (trace_fraction > 0) dq += dqf * trace_fraction;
1546 if (dq > worst_endpos_bug)
1548 worst_endpos_bug = dq;
1549 LOG_INFO("trace_endpos still before solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p));
1550 LOG_INFO("could go ", ftos(dq), " units further to ", vtos(q));
1551 if (++hitcount >= 10) break;
1562 tracebox(e.origin + '0 0 32', e.mins, e.maxs, e.origin + '0 0 -1024', MOVE_NORMAL, e);
1564 if (trace_fraction == 1)
1566 LOG_INFO("not above ground, aborting");
1570 for (i = 0; i < 100000; ++i)
1573 if (dv.z > 0) dv = -1 * dv;
1574 tracebox(vv, e.mins, e.maxs, vv + dv, MOVE_NORMAL, e);
1575 if (trace_startsolid) LOG_INFO("bug 1");
1576 if (trace_fraction == 1)
1580 LOG_INFO("bug 2: ", ftos(dv.x), " ", ftos(dv.y), " ", ftos(dv.z));
1581 LOG_INFO(" (", ftos(asin(dv.z / vlen(dv)) * 180 / M_PI), " degrees)");
1586 LOG_INFO("highest possible dist: ", ftos(f));
1592 if (argc == 4 || argc == 5)
1595 int dphitcontentsmask_save = e.dphitcontentsmask;
1596 e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
1597 if (tracewalk(e, stov(argv(2)), e.mins, e.maxs, stov(argv(3)), stof(argv(4)), MOVE_NORMAL))
1598 LOG_INFO("can walk");
1600 LOG_INFO("cannot walk");
1601 e.dphitcontentsmask = dphitcontentsmask_save;
1612 traceline(vv, dv, MOVE_NORMAL, NULL);
1613 __trailparticles(NULL, particleeffectnum(EFFECT_TR_NEXUIZPLASMA), vv, trace_endpos);
1614 __trailparticles(NULL, particleeffectnum(EFFECT_TR_CRYLINKPLASMA), trace_endpos, dv);
1619 // no default case, just go straight to invalid
1624 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
1625 case CMD_REQUEST_USAGE:
1627 LOG_HELP("Usage:^3 sv_cmd trace command [startpos endpos] [endpos_height]");
1628 LOG_HELP(" Where startpos and endpos are parameters for 'walk' and 'showline' commands,");
1629 LOG_HELP(" 'endpos_height' is an optional parameter for 'walk' command,");
1630 LOG_HELP(" Full list of commands here: \"debug, debug2, walk, showline.\"");
1631 LOG_HELP("See also: ^2bbox, gettaginfo^7");
1637 void GameCommand_unlockteams(int request)
1641 case CMD_REQUEST_COMMAND:
1646 bprint("\{1}^1The teams are now unlocked.\n");
1650 bprint("unlockteams command can only be used in a team-based gamemode.\n");
1656 case CMD_REQUEST_USAGE:
1658 LOG_HELP("Usage:^3 sv_cmd unlockteams");
1659 LOG_HELP(" No arguments required.");
1660 LOG_HELP("See also: ^2lockteams^7");
1666 void GameCommand_warp(int request, int argc)
1670 case CMD_REQUEST_COMMAND:
1672 if (autocvar_g_campaign)
1676 CampaignLevelWarp(stof(argv(1)));
1677 LOG_INFO("Successfully warped to campaign level ", argv(1), ".");
1681 CampaignLevelWarp(-1);
1682 LOG_INFO("Successfully warped to next campaign level.");
1687 LOG_INFO("Not in campaign, can't level warp");
1693 case CMD_REQUEST_USAGE:
1695 LOG_HELP("Usage:^3 sv_cmd warp [level]");
1696 LOG_HELP(" 'level' is the level to change campaign mode to.");
1697 LOG_HELP(" if 'level' is not provided it will change to the next level.");
1703 /* use this when creating a new command, making sure to place it in alphabetical order... also,
1704 ** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION!
1705 void GameCommand_(int request)
1709 case CMD_REQUEST_COMMAND:
1716 case CMD_REQUEST_USAGE:
1718 LOG_HELP("Usage:^3 sv_cmd ");
1719 LOG_HELP(" No arguments required.");
1727 // ==================================
1728 // Macro system for server commands
1729 // ==================================
1731 // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
1732 SERVER_COMMAND(setflag, "Set client flag") { GameCommand_setflag(request, arguments); }
1733 SERVER_COMMAND(teamname, "Set team name") { GameCommand_teamname(request, arguments); }
1734 SERVER_COMMAND(stop, "Stop") { GameCommand_stop(request, arguments); }
1736 SERVER_COMMAND(adminmsg, "Send an admin message to a client directly") { GameCommand_adminmsg(request, arguments); }
1737 SERVER_COMMAND(allready, "Restart the server and reset the players") { GameCommand_allready(request); }
1738 SERVER_COMMAND(allspec, "Force all players to spectate") { GameCommand_allspec(request, arguments); }
1739 SERVER_COMMAND(anticheat, "Create an anticheat report for a client") { GameCommand_anticheat(request, arguments); }
1740 SERVER_COMMAND(animbench, "Benchmark model animation (LAGS)") { GameCommand_animbench(request, arguments); }
1741 SERVER_COMMAND(bbox, "Print detailed information about world size") { GameCommand_bbox(request); }
1742 SERVER_COMMAND(bot_cmd, "Control and send commands to bots") { GameCommand_bot_cmd(request, arguments, command); }
1743 SERVER_COMMAND(cointoss, "Flip a virtual coin and give random result") { GameCommand_cointoss(request, arguments); }
1744 SERVER_COMMAND(database, "Extra controls of the serverprogs database") { GameCommand_database(request, arguments); }
1745 SERVER_COMMAND(defer_clear, "Clear all queued defer commands for a specific client") { GameCommand_defer_clear(request, arguments); }
1746 SERVER_COMMAND(defer_clear_all, "Clear all queued defer commands for all clients") { GameCommand_defer_clear_all(request); }
1747 SERVER_COMMAND(delrec, "Delete race time record for a map") { GameCommand_delrec(request, arguments); }
1748 SERVER_COMMAND(effectindexdump, "Dump list of effects from code and effectinfo.txt") { GameCommand_effectindexdump(request); }
1749 SERVER_COMMAND(extendmatchtime, "Increase the timelimit value incrementally") { GameCommand_extendmatchtime(request); }
1750 SERVER_COMMAND(gametype, "Simple command to change the active gametype") { GameCommand_gametype(request, arguments); }
1751 SERVER_COMMAND(gettaginfo, "Get specific information about a weapon model") { GameCommand_gettaginfo(request, arguments); }
1752 SERVER_COMMAND(gotomap, "Simple command to switch to another map") { GameCommand_gotomap(request, arguments); }
1753 SERVER_COMMAND(lockteams, "Disable the ability for players to switch or enter teams") { GameCommand_lockteams(request); }
1754 SERVER_COMMAND(make_mapinfo, "Automatically rebuild mapinfo files") { GameCommand_make_mapinfo(request); }
1755 SERVER_COMMAND(moveplayer, "Change the team/status of a player") { GameCommand_moveplayer(request, arguments); }
1756 SERVER_COMMAND(nospectators, "Automatically remove spectators from a match") { GameCommand_nospectators(request); }
1757 SERVER_COMMAND(printstats, "Dump eventlog player stats and other score information") { GameCommand_printstats(request); }
1758 SERVER_COMMAND(radarmap, "Generate a radar image of the map") { GameCommand_radarmap(request, arguments); }
1759 SERVER_COMMAND(reducematchtime, "Decrease the timelimit value incrementally") { GameCommand_reducematchtime(request); }
1760 SERVER_COMMAND(setbots, "Adjust how many bots are in the match") { GameCommand_setbots(request, arguments); }
1761 SERVER_COMMAND(shuffleteams, "Randomly move players to different teams") { GameCommand_shuffleteams(request); }
1762 SERVER_COMMAND(stuffto, "Send a command to be executed on a client") { GameCommand_stuffto(request, arguments); }
1763 SERVER_COMMAND(trace, "Various debugging tools with tracing") { GameCommand_trace(request, arguments); }
1764 SERVER_COMMAND(unlockteams, "Enable the ability for players to switch or enter teams") { GameCommand_unlockteams(request); }
1765 SERVER_COMMAND(warp, "Choose different level in campaign") { GameCommand_warp(request, arguments); }
1767 void GameCommand_macro_help()
1769 FOREACH(SERVER_COMMANDS, true, { LOG_HELPF(" ^2%s^7: %s", it.m_name, it.m_description); });
1772 float GameCommand_macro_command(int argc, string command)
1774 string c = strtolower(argv(0));
1775 FOREACH(SERVER_COMMANDS, it.m_name == c, {
1776 it.m_invokecmd(it, CMD_REQUEST_COMMAND, NULL, argc, command);
1782 float GameCommand_macro_usage(int argc)
1784 string c = strtolower(argv(1));
1785 FOREACH(SERVER_COMMANDS, it.m_name == c, {
1786 it.m_invokecmd(it, CMD_REQUEST_USAGE, NULL, argc, "");
1792 void GameCommand_macro_write_aliases(float fh)
1794 FOREACH(SERVER_COMMANDS, true, { CMD_Write_Alias("qc_cmd_sv", it.m_name, it.m_description); });
1798 // =========================================
1799 // Main Function Called By Engine (sv_cmd)
1800 // =========================================
1801 // If this function exists, game code handles gamecommand instead of the engine code.
1803 void GameCommand(string command)
1805 int argc = tokenize_console(command);
1807 // Guide for working with argc arguments by example:
1808 // argc: 1 - 2 - 3 - 4
1809 // argv: 0 - 1 - 2 - 3
1810 // cmd vote - master - login - password
1812 if (strtolower(argv(0)) == "help")
1816 LOG_HELP("Server console commands:");
1817 GameCommand_macro_help();
1819 LOG_HELP("\nBanning commands:");
1820 BanCommand_macro_help();
1822 LOG_HELP("\nCommon networked commands:");
1823 CommonCommand_macro_help(NULL);
1825 LOG_HELP("\nGeneric commands shared by all programs:");
1826 GenericCommand_macro_help();
1828 LOG_HELP("\nUsage:^3 sv_cmd COMMAND...^7, where possible commands are listed above.\n"
1829 "For help about a specific command, type sv_cmd help COMMAND");
1833 else if (BanCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it
1837 else if (CommonCommand_macro_usage(argc, NULL)) // same here, but for common commands instead
1841 else if (GenericCommand_macro_usage(argc)) // same here, but for generic commands instead
1845 else if (GameCommand_macro_usage(argc)) // finally try for normal commands too
1850 else if (MUTATOR_CALLHOOK(SV_ParseServerCommand, strtolower(argv(0)), argc, command))
1852 return; // handled by a mutator
1854 else if (BanCommand(command))
1856 return; // handled by server/command/ipban.qc
1858 else if (CommonCommand_macro_command(argc, NULL, command))
1860 return; // handled by server/command/common.qc
1862 else if (GenericCommand(command))
1864 return; // handled by common/command/generic.qc
1866 else if (GameCommand_macro_command(argc, command)) // continue as usual and scan for normal commands
1868 return; // handled by one of the above GameCommand_* functions
1871 // nothing above caught the command, must be invalid
1872 LOG_INFO(((command != "") ? strcat("Unknown server command \"", command, "\"") : "No command provided"), ". For a list of supported commands, try sv_cmd help.");