4 #include <common/effects/all.qh>
9 #include "getreplies.qh"
10 #include "radarmap.qh"
12 #include "../anticheat.qh"
13 #include "../campaign.qh"
14 #include "../client.qh"
15 #include "../player.qh"
16 #include "../g_world.qh"
17 #include "../ipban.qh"
18 #include "../playerdemo.qh"
19 #include "../teamplay.qh"
21 #include "../bot/api.qh"
23 #include <server/mutators/_mod.qh>
24 #include <common/gamemodes/_mod.qh>
26 #include <common/constants.qh>
27 #include <common/net_linked.qh>
28 #include <common/mapinfo.qh>
29 #include <common/notifications/all.qh>
30 #include <common/teams.qh>
31 #include <common/util.qh>
33 #include <common/monsters/sv_monsters.qh>
35 // used by GameCommand_make_mapinfo()
36 void make_mapinfo_Think(entity this)
38 if (_MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
40 LOG_INFO("Done rebuiling mapinfos.");
41 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
46 setthink(this, make_mapinfo_Think);
47 this.nextthink = time;
51 // used by GameCommand_extendmatchtime() and GameCommand_reducematchtime()
52 void changematchtime(float delta, float mi, float ma)
58 if (delta == 0) return;
59 if (autocvar_timelimit < 0) return;
61 if (mi <= 10) mi = 10; // at least ten sec in the future
62 cur = time - game_starttime;
63 if (cur > 0) mi += cur; // from current time!
65 lim = autocvar_timelimit * 60;
69 if (lim == 0) return; // cannot increase any further
70 else if (lim < ma) update = min(ma, lim + delta);
71 else // already above maximum: FAIL
76 if (lim == 0) // infinite: try reducing to max, if we are allowed to
78 else if (lim > mi) // above minimum: decrease
79 update = max(mi, lim + delta);
80 else // already below minimum: FAIL
84 cvar_set("timelimit", ftos(update / 60));
88 // =======================
89 // Command Sub-Functions
90 // =======================
92 void GameCommand_adminmsg(float request, float argc)
96 case CMD_REQUEST_COMMAND:
101 string targets = strreplace(",", " ", argv(1));
102 string original_targets = strreplace(" ", ", ", targets);
103 string admin_message = argv(2);
104 float infobartime = stof(argv(3));
106 string successful, t;
107 successful = string_null;
109 if ((targets) && (admin_message))
114 targets = cdr(targets);
116 // Check to see if the player is a valid target
117 client = GetFilteredEntity(t);
118 accepted = VerifyClientEntity(client, true, false);
122 LOG_INFO("adminmsg: ", GetClientErrorString(accepted, t), (targets ? ", skipping to next player.\n" : "."));
126 // send the centerprint/console print or infomessage
129 stuffcmd(client, sprintf("\ninfobar %f \"%s\"\n", infobartime, MakeConsoleSafe(admin_message)));
133 centerprint(client, strcat("^3", GetCallerName(NULL), ":\n^7", admin_message));
134 sprint(client, strcat("\{1}\{13}^3", GetCallerName(NULL), "^7: ", admin_message, "\n"));
137 successful = strcat(successful, (successful ? ", " : ""), playername(client, false));
138 LOG_TRACE("Message sent to ", playername(client, false));
142 if (successful) bprint("Successfully sent message '", admin_message, "' to ", successful, ".\n");
143 else LOG_INFO("No players given (", original_targets, ") could receive the message.");
150 LOG_INFO("Incorrect parameters for ^2adminmsg^7");
151 case CMD_REQUEST_USAGE:
153 LOG_INFO("Usage:^3 sv_cmd adminmsg clients \"message\" [infobartime]");
154 LOG_INFO(" 'clients' is a list (separated by commas) of player entity ID's or nicknames");
155 LOG_INFO(" If infobartime is provided, the message will be sent to infobar.");
156 LOG_INFO(" Otherwise, it will just be sent as a centerprint message.");
157 LOG_INFO("Examples: adminmsg 2,4 \"this infomessage will last for ten seconds\" 10");
158 LOG_INFO(" adminmsg 2,5 \"this message will be a centerprint\"");
164 void GameCommand_allready(float request)
168 case CMD_REQUEST_COMMAND:
175 case CMD_REQUEST_USAGE:
177 LOG_INFO("Usage:^3 sv_cmd allready");
178 LOG_INFO(" No arguments required.");
184 void GameCommand_allspec(float request, float argc)
188 case CMD_REQUEST_COMMAND:
190 string reason = argv(1);
192 FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
193 if (it.caplayer) it.caplayer = 0;
194 PutObserverInServer(it);
197 if (n) bprint(strcat("Successfully forced all (", ftos(n), ") players to spectate", (reason ? strcat(" for reason: '", reason, "'") : ""), ".\n"));
198 else LOG_INFO("No players found to spectate.");
203 case CMD_REQUEST_USAGE:
205 LOG_INFO("Usage:^3 sv_cmd allspec [reason]");
206 LOG_INFO(" Where 'reason' is an optional argument for explanation of allspec command.");
207 LOG_INFO("See also: ^2moveplayer, shuffleteams^7");
213 void GameCommand_anticheat(float request, float argc)
217 case CMD_REQUEST_COMMAND:
219 entity client = GetIndexedEntity(argc, 1);
220 float accepted = VerifyClientEntity(client, false, false);
224 anticheat_report_to_eventlog(client);
229 LOG_INFO("anticheat: ", GetClientErrorString(accepted, argv(1)), ".");
234 LOG_INFO("Incorrect parameters for ^2anticheat^7");
235 case CMD_REQUEST_USAGE:
237 LOG_INFO("Usage:^3 sv_cmd anticheat client");
238 LOG_INFO(" 'client' is the entity number or name of the player.");
244 void GameCommand_bbox(float request)
248 case CMD_REQUEST_COMMAND:
250 vector size_min = '0 0 0';
251 vector size_max = '0 0 0';
252 tracebox('1 0 0' * world.absmin.x,
253 '0 1 0' * world.absmin.y + '0 0 1' * world.absmin.z,
254 '0 1 0' * world.absmax.y + '0 0 1' * world.absmax.z,
255 '1 0 0' * world.absmax.x,
258 size_min.x = (trace_startsolid) ? world.absmin.x : trace_endpos.x;
260 tracebox('0 1 0' * world.absmin.y,
261 '1 0 0' * world.absmin.x + '0 0 1' * world.absmin.z,
262 '1 0 0' * world.absmax.x + '0 0 1' * world.absmax.z,
263 '0 1 0' * world.absmax.y,
266 size_min.y = (trace_startsolid) ? world.absmin.y : trace_endpos.y;
268 tracebox('0 0 1' * world.absmin.z,
269 '1 0 0' * world.absmin.x + '0 1 0' * world.absmin.y,
270 '1 0 0' * world.absmax.x + '0 1 0' * world.absmax.y,
271 '0 0 1' * world.absmax.z,
274 size_min.z = (trace_startsolid) ? world.absmin.z : trace_endpos.z;
276 tracebox('1 0 0' * world.absmax.x,
277 '0 1 0' * world.absmin.y + '0 0 1' * world.absmin.z,
278 '0 1 0' * world.absmax.y + '0 0 1' * world.absmax.z,
279 '1 0 0' * world.absmin.x,
282 size_max.x = (trace_startsolid) ? world.absmax.x : trace_endpos.x;
284 tracebox('0 1 0' * world.absmax.y,
285 '1 0 0' * world.absmin.x + '0 0 1' * world.absmin.z,
286 '1 0 0' * world.absmax.x + '0 0 1' * world.absmax.z,
287 '0 1 0' * world.absmin.y,
290 size_max.y = (trace_startsolid) ? world.absmax.y : trace_endpos.y;
292 tracebox('0 0 1' * world.absmax.z,
293 '1 0 0' * world.absmin.x + '0 1 0' * world.absmin.y,
294 '1 0 0' * world.absmax.x + '0 1 0' * world.absmax.y,
295 '0 0 1' * world.absmin.z,
298 size_max.z = (trace_startsolid) ? world.absmax.z : trace_endpos.z;
300 LOG_INFOF("Original size: %v %v", world.absmin, world.absmax);
301 LOG_INFOF("Currently set size: %v %v", world.mins, world.maxs);
302 LOG_INFOF("Solid bounding box size: %v %v", size_min, size_max);
307 case CMD_REQUEST_USAGE:
309 LOG_INFO("Usage:^3 sv_cmd bbox");
310 LOG_INFO(" No arguments required.");
311 LOG_INFO("See also: ^2gettaginfo, trace^7");
317 void GameCommand_bot_cmd(float request, float argc, string command)
321 case CMD_REQUEST_COMMAND:
325 if (argv(1) == "reset")
330 else if (argv(1) == "setbots")
332 cvar_settemp("bot_vs_human", "0");
333 cvar_settemp("minplayers", "0");
334 cvar_settemp("bot_number", "0");
336 cvar_settemp("bot_number", argv(2));
337 if (!bot_fixcount()) LOG_INFO("Sorry, could not set requested bot count");
340 else if (argv(1) == "load" && argc == 3)
344 fh = fopen(argv(2), FILE_READ);
347 LOG_INFO("cannot open the file");
352 while ((s = fgets(fh)))
354 argc = tokenize_console(s);
356 if (argc >= 3 && argv(0) == "sv_cmd" && argv(1) == "bot_cmd")
358 if (argv(2) == "reset")
362 else if (argv(2) == "setbots")
364 cvar_settemp("bot_vs_human", "0");
365 cvar_settemp("minplayers", "0");
366 cvar_settemp("bot_number", "0");
368 cvar_settemp("bot_number", argv(3));
369 if (!bot_fixcount()) LOG_INFO("Sorry, could not set requested bot count");
373 if(argv(2) == "*" || argv(2) == "all")
374 FOREACH_CLIENT(IS_BOT_CLIENT(it), {
375 bot_queuecommand(it, substring(s, argv_start_index(3), -1));
379 bot = find_bot_by_number(stof(argv(2)));
380 if (bot == NULL) bot = find_bot_by_name(argv(2));
381 if (bot) bot_queuecommand(bot, substring(s, argv_start_index(3), -1));
387 localcmd(strcat(s, "\n"));
392 LOG_INFO(ftos(i), " commands read");
396 else if (argv(1) == "help")
398 if (argv(2)) bot_cmdhelp(argv(2));
399 else bot_list_commands();
402 else if (argc >= 3) // this comes last
404 if(argv(1) == "*" || argv(1) == "all")
407 FOREACH_CLIENT(IS_BOT_CLIENT(it), {
408 bot_queuecommand(it, substring(command, argv_start_index(2), -1));
412 LOG_INFO("Command '", substring(command, argv_start_index(2), -1), "' sent to all bots (", ftos(bot_num), ")");
417 bot = find_bot_by_number(stof(argv(1)));
418 if (bot == NULL) bot = find_bot_by_name(argv(1));
421 LOG_INFO("Command '", substring(command, argv_start_index(2), -1), "' sent to bot ", bot.netname);
422 bot_queuecommand(bot, substring(command, argv_start_index(2), -1));
427 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
434 LOG_INFO("Incorrect parameters for ^2bot_cmd^7");
435 case CMD_REQUEST_USAGE:
437 LOG_INFO("Usage:^3 sv_cmd bot_cmd client command [argument]");
438 LOG_INFO(" 'client' can be either the name of the bot or a progressive number (not the entity number!)");
439 LOG_INFO(" can also be '*' or 'all' to allow sending the command to all the bots");
440 LOG_INFO(" For full list of commands, see bot_cmd help [command].");
441 LOG_INFO("Examples: sv_cmd bot_cmd 1 cc \"say something\"");
442 LOG_INFO(" sv_cmd bot_cmd 1 presskey jump");
443 LOG_INFO(" sv_cmd bot_cmd * pause");
449 void GameCommand_cointoss(float request, float argc)
453 case CMD_REQUEST_COMMAND:
455 string result1 = (argv(2) ? strcat("^7", argv(1)) : "^1HEADS");
456 string result2 = (argv(2) ? strcat("^7", argv(2)) : "^4TAILS");
457 string choice = ((random() > 0.5) ? result1 : result2);
459 Send_Notification(NOTIF_ALL, NULL, MSG_MULTI, MULTI_COINTOSS, choice);
464 case CMD_REQUEST_USAGE:
466 LOG_INFO("Usage:^3 sv_cmd cointoss [result1 result2]");
467 LOG_INFO(" Where 'result1' and 'result2' are user created options.");
473 void GameCommand_database(float request, float argc)
477 case CMD_REQUEST_COMMAND:
481 if (argv(1) == "save")
483 db_save(ServerProgsDB, argv(2));
484 LOG_INFO("Copied serverprogs database to '", argv(2), "' in the data directory.");
487 else if (argv(1) == "dump")
489 db_dump(ServerProgsDB, argv(2));
490 LOG_INFO("DB dumped."); // wtf does this do?
493 else if (argv(1) == "load")
495 db_close(ServerProgsDB);
496 ServerProgsDB = db_load(argv(2));
497 LOG_INFO("Loaded '", argv(2), "' as new serverprogs database.");
504 LOG_INFO("Incorrect parameters for ^2database^7");
505 case CMD_REQUEST_USAGE:
507 LOG_INFO("Usage:^3 sv_cmd database action filename");
508 LOG_INFO(" Where 'action' is the command to complete,");
509 LOG_INFO(" and 'filename' is what it acts upon.");
510 LOG_INFO(" Full list of commands here: \"save, dump, load.\"");
516 void GameCommand_defer_clear(float request, float argc)
520 case CMD_REQUEST_COMMAND:
527 client = GetIndexedEntity(argc, 1);
528 accepted = VerifyClientEntity(client, true, false);
532 stuffcmd(client, "defer clear\n");
533 LOG_INFO("defer clear stuffed to ", playername(client, false));
535 else { LOG_INFO("defer_clear: ", GetClientErrorString(accepted, argv(1)), "."); }
542 LOG_INFO("Incorrect parameters for ^2defer_clear^7");
543 case CMD_REQUEST_USAGE:
545 LOG_INFO("Usage:^3 sv_cmd defer_clear client");
546 LOG_INFO(" 'client' is the entity number or name of the player.");
547 LOG_INFO("See also: ^2defer_clear_all^7");
553 void GameCommand_defer_clear_all(float request)
557 case CMD_REQUEST_COMMAND:
562 FOREACH_CLIENT(true, {
563 argc = tokenize_console(strcat("defer_clear ", ftos(etof(it))));
564 GameCommand_defer_clear(CMD_REQUEST_COMMAND, argc);
567 if (n) LOG_INFO("Successfully stuffed defer clear to all clients (", ftos(n), ")"); // should a message be added if no players were found?
572 case CMD_REQUEST_USAGE:
574 LOG_INFO("Usage:^3 sv_cmd defer_clear_all");
575 LOG_INFO(" No arguments required.");
576 LOG_INFO("See also: ^2defer_clear^7");
582 void GameCommand_delrec(float request, float argc) // perhaps merge later with records and printstats and such?
586 case CMD_REQUEST_COMMAND:
590 if (argv(2)) race_deleteTime(argv(2), stof(argv(1)));
591 else race_deleteTime(GetMapname(), stof(argv(1)));
597 LOG_INFO("Incorrect parameters for ^2delrec^7");
598 case CMD_REQUEST_USAGE:
600 LOG_INFO("Usage:^3 sv_cmd delrec ranking [map]");
601 LOG_INFO(" 'ranking' is which ranking level to clear up to, ");
602 LOG_INFO(" it will clear all records up to nth place.");
603 LOG_INFO(" if 'map' is not provided it will use current map.");
609 void GameCommand_effectindexdump(float request)
613 case CMD_REQUEST_COMMAND:
619 LOG_INFO("begin of effects list");
620 db_put(d, "TE_GUNSHOT", "1");
621 LOG_INFO("effect TE_GUNSHOT is ", ftos(_particleeffectnum("TE_GUNSHOT")));
622 db_put(d, "TE_GUNSHOTQUAD", "1");
623 LOG_INFO("effect TE_GUNSHOTQUAD is ", ftos(_particleeffectnum("TE_GUNSHOTQUAD")));
624 db_put(d, "TE_SPIKE", "1");
625 LOG_INFO("effect TE_SPIKE is ", ftos(_particleeffectnum("TE_SPIKE")));
626 db_put(d, "TE_SPIKEQUAD", "1");
627 LOG_INFO("effect TE_SPIKEQUAD is ", ftos(_particleeffectnum("TE_SPIKEQUAD")));
628 db_put(d, "TE_SUPERSPIKE", "1");
629 LOG_INFO("effect TE_SUPERSPIKE is ", ftos(_particleeffectnum("TE_SUPERSPIKE")));
630 db_put(d, "TE_SUPERSPIKEQUAD", "1");
631 LOG_INFO("effect TE_SUPERSPIKEQUAD is ", ftos(_particleeffectnum("TE_SUPERSPIKEQUAD")));
632 db_put(d, "TE_WIZSPIKE", "1");
633 LOG_INFO("effect TE_WIZSPIKE is ", ftos(_particleeffectnum("TE_WIZSPIKE")));
634 db_put(d, "TE_KNIGHTSPIKE", "1");
635 LOG_INFO("effect TE_KNIGHTSPIKE is ", ftos(_particleeffectnum("TE_KNIGHTSPIKE")));
636 db_put(d, "TE_EXPLOSION", "1");
637 LOG_INFO("effect TE_EXPLOSION is ", ftos(_particleeffectnum("TE_EXPLOSION")));
638 db_put(d, "TE_EXPLOSIONQUAD", "1");
639 LOG_INFO("effect TE_EXPLOSIONQUAD is ", ftos(_particleeffectnum("TE_EXPLOSIONQUAD")));
640 db_put(d, "TE_TAREXPLOSION", "1");
641 LOG_INFO("effect TE_TAREXPLOSION is ", ftos(_particleeffectnum("TE_TAREXPLOSION")));
642 db_put(d, "TE_TELEPORT", "1");
643 LOG_INFO("effect TE_TELEPORT is ", ftos(_particleeffectnum("TE_TELEPORT")));
644 db_put(d, "TE_LAVASPLASH", "1");
645 LOG_INFO("effect TE_LAVASPLASH is ", ftos(_particleeffectnum("TE_LAVASPLASH")));
646 db_put(d, "TE_SMALLFLASH", "1");
647 LOG_INFO("effect TE_SMALLFLASH is ", ftos(_particleeffectnum("TE_SMALLFLASH")));
648 db_put(d, "TE_FLAMEJET", "1");
649 LOG_INFO("effect TE_FLAMEJET is ", ftos(_particleeffectnum("TE_FLAMEJET")));
650 db_put(d, "EF_FLAME", "1");
651 LOG_INFO("effect EF_FLAME is ", ftos(_particleeffectnum("EF_FLAME")));
652 db_put(d, "TE_BLOOD", "1");
653 LOG_INFO("effect TE_BLOOD is ", ftos(_particleeffectnum("TE_BLOOD")));
654 db_put(d, "TE_SPARK", "1");
655 LOG_INFO("effect TE_SPARK is ", ftos(_particleeffectnum("TE_SPARK")));
656 db_put(d, "TE_PLASMABURN", "1");
657 LOG_INFO("effect TE_PLASMABURN is ", ftos(_particleeffectnum("TE_PLASMABURN")));
658 db_put(d, "TE_TEI_G3", "1");
659 LOG_INFO("effect TE_TEI_G3 is ", ftos(_particleeffectnum("TE_TEI_G3")));
660 db_put(d, "TE_TEI_SMOKE", "1");
661 LOG_INFO("effect TE_TEI_SMOKE is ", ftos(_particleeffectnum("TE_TEI_SMOKE")));
662 db_put(d, "TE_TEI_BIGEXPLOSION", "1");
663 LOG_INFO("effect TE_TEI_BIGEXPLOSION is ", ftos(_particleeffectnum("TE_TEI_BIGEXPLOSION")));
664 db_put(d, "TE_TEI_PLASMAHIT", "1");
665 LOG_INFO("effect TE_TEI_PLASMAHIT is ", ftos(_particleeffectnum("TE_TEI_PLASMAHIT")));
666 db_put(d, "EF_STARDUST", "1");
667 LOG_INFO("effect EF_STARDUST is ", ftos(_particleeffectnum("EF_STARDUST")));
668 db_put(d, "TR_ROCKET", "1");
669 LOG_INFO("effect TR_ROCKET is ", ftos(_particleeffectnum("TR_ROCKET")));
670 db_put(d, "TR_GRENADE", "1");
671 LOG_INFO("effect TR_GRENADE is ", ftos(_particleeffectnum("TR_GRENADE")));
672 db_put(d, "TR_BLOOD", "1");
673 LOG_INFO("effect TR_BLOOD is ", ftos(_particleeffectnum("TR_BLOOD")));
674 db_put(d, "TR_WIZSPIKE", "1");
675 LOG_INFO("effect TR_WIZSPIKE is ", ftos(_particleeffectnum("TR_WIZSPIKE")));
676 db_put(d, "TR_SLIGHTBLOOD", "1");
677 LOG_INFO("effect TR_SLIGHTBLOOD is ", ftos(_particleeffectnum("TR_SLIGHTBLOOD")));
678 db_put(d, "TR_KNIGHTSPIKE", "1");
679 LOG_INFO("effect TR_KNIGHTSPIKE is ", ftos(_particleeffectnum("TR_KNIGHTSPIKE")));
680 db_put(d, "TR_VORESPIKE", "1");
681 LOG_INFO("effect TR_VORESPIKE is ", ftos(_particleeffectnum("TR_VORESPIKE")));
682 db_put(d, "TR_NEHAHRASMOKE", "1");
683 LOG_INFO("effect TR_NEHAHRASMOKE is ", ftos(_particleeffectnum("TR_NEHAHRASMOKE")));
684 db_put(d, "TR_NEXUIZPLASMA", "1");
685 LOG_INFO("effect TR_NEXUIZPLASMA is ", ftos(_particleeffectnum("TR_NEXUIZPLASMA")));
686 db_put(d, "TR_GLOWTRAIL", "1");
687 LOG_INFO("effect TR_GLOWTRAIL is ", ftos(_particleeffectnum("TR_GLOWTRAIL")));
688 db_put(d, "TR_SEEKER", "1");
689 LOG_INFO("effect TR_SEEKER is ", ftos(_particleeffectnum("TR_SEEKER")));
690 db_put(d, "SVC_PARTICLE", "1");
691 LOG_INFO("effect SVC_PARTICLE is ", ftos(_particleeffectnum("SVC_PARTICLE")));
693 fh = fopen("effectinfo.txt", FILE_READ);
694 while ((s = fgets(fh)))
697 if (argv(0) == "effect")
699 if (db_get(d, argv(1)) != "1")
701 int i = _particleeffectnum(argv(1));
702 if (i >= 0) LOG_INFO("effect ", argv(1), " is ", ftos(i));
703 db_put(d, argv(1), "1");
707 LOG_INFO("end of effects list");
714 case CMD_REQUEST_USAGE:
716 LOG_INFO("Usage:^3 sv_cmd effectindexdump");
717 LOG_INFO(" No arguments required.");
723 void GameCommand_extendmatchtime(float request)
727 case CMD_REQUEST_COMMAND:
729 changematchtime(autocvar_timelimit_increment * 60, autocvar_timelimit_min * 60, autocvar_timelimit_max * 60);
734 case CMD_REQUEST_USAGE:
736 LOG_INFO("Usage:^3 sv_cmd extendmatchtime");
737 LOG_INFO(" No arguments required.");
738 LOG_INFO("See also: ^2reducematchtime^7");
744 void GameCommand_gametype(float request, float argc)
748 case CMD_REQUEST_COMMAND:
753 Gametype t = MapInfo_Type_FromString(s), tsave = MapInfo_CurrentGametype();
757 MapInfo_SwitchGameType(t);
758 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
759 if (MapInfo_count > 0)
761 // update lsmaps in case the gametype changed, this way people can easily list maps for it
762 if (lsmaps_reply != "") strunzone(lsmaps_reply);
763 lsmaps_reply = strzone(getlsmaps());
764 bprint("Game type successfully switched to ", s, "\n");
768 bprint("Cannot use this game type: no map for it found\n");
769 MapInfo_SwitchGameType(tsave);
770 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
775 bprint("Game type switch to ", s, " failed: this type does not exist!\n");
783 LOG_INFO("Incorrect parameters for ^2gametype^7");
784 case CMD_REQUEST_USAGE:
786 LOG_INFO("Usage:^3 sv_cmd gametype mode");
787 LOG_INFO(" Where 'mode' is the gametype mode to switch to.");
788 LOG_INFO("See also: ^2gotomap^7");
794 void GameCommand_gettaginfo(float request, float argc)
798 case CMD_REQUEST_COMMAND:
806 tmp_entity = spawn();
809 .entity weaponentity = weaponentities[0];
810 _setmodel(tmp_entity, (nextent(NULL)).(weaponentity).model);
814 precache_model(argv(1));
815 _setmodel(tmp_entity, argv(1));
817 tmp_entity.frame = stof(argv(2));
818 if (substring(argv(3), 0, 1) == "#") i = stof(substring(argv(3), 1, -1));
819 else i = gettagindex(tmp_entity, argv(3));
822 v = gettaginfo(tmp_entity, i);
824 "model %s frame %s tag %s index %s parent %s",
825 tmp_entity.model, ftos(tmp_entity.frame), gettaginfo_name, ftos(i), ftos(gettaginfo_parent)
827 LOG_INFOF(" vector = %s %s %s", ftos(v.x), ftos(v.y), ftos(v.z));
828 LOG_INFOF(" offset = %s %s %s", ftos(gettaginfo_offset.x), ftos(gettaginfo_offset.y), ftos(gettaginfo_offset.z));
829 LOG_INFOF(" forward = %s %s %s", ftos(gettaginfo_forward.x), ftos(gettaginfo_forward.y), ftos(gettaginfo_forward.z));
830 LOG_INFOF(" right = %s %s %s", ftos(gettaginfo_right.x), ftos(gettaginfo_right.y), ftos(gettaginfo_right.z));
831 LOG_INFOF(" up = %s %s %s", ftos(gettaginfo_up.x), ftos(gettaginfo_up.y), ftos(gettaginfo_up.z));
835 localcmd(strcat(argv(4), vtos(v), argv(5), "\n"));
840 LOG_INFO("bone not found");
849 LOG_INFO("Incorrect parameters for ^2gettaginfo^7");
850 case CMD_REQUEST_USAGE:
852 LOG_INFO("Usage:^3 sv_cmd gettaginfo model frame index [command one] [command two]");
853 LOG_INFO("See also: ^2bbox, trace^7");
859 void GameCommand_animbench(float request, float argc)
863 case CMD_REQUEST_COMMAND:
869 tmp_entity = spawn();
872 .entity weaponentity = weaponentities[0];
873 _setmodel(tmp_entity, (nextent(NULL)).(weaponentity).model);
877 precache_model(argv(1));
878 _setmodel(tmp_entity, argv(1));
880 float f1 = stof(argv(2));
881 float f2 = stof(argv(3));
889 tmp_entity.frame = f1;
890 t0 = gettime(GETTIME_HIRES);
891 getsurfacepoint(tmp_entity, 0, 0);
892 t1 += gettime(GETTIME_HIRES) - t0;
893 tmp_entity.frame = f2;
894 t0 = gettime(GETTIME_HIRES);
895 getsurfacepoint(tmp_entity, 0, 0);
896 t2 += gettime(GETTIME_HIRES) - t0;
899 LOG_INFO("model ", tmp_entity.model, " frame ", ftos(f1), " animtime ", ftos(n / t1), "/s");
900 LOG_INFO("model ", tmp_entity.model, " frame ", ftos(f2), " animtime ", ftos(n / t2), "/s");
908 LOG_INFO("Incorrect parameters for ^2gettaginfo^7");
909 case CMD_REQUEST_USAGE:
911 LOG_INFO("Usage:^3 sv_cmd gettaginfo model frame index [command one] [command two]");
912 LOG_INFO("See also: ^2bbox, trace^7");
918 void GameCommand_gotomap(float request, float argc)
922 case CMD_REQUEST_COMMAND:
926 LOG_INFO(GotoMap(argv(1)));
932 LOG_INFO("Incorrect parameters for ^2gotomap^7");
933 case CMD_REQUEST_USAGE:
935 LOG_INFO("Usage:^3 sv_cmd gotomap map");
936 LOG_INFO(" Where 'map' is the *.bsp file to change to.");
937 LOG_INFO("See also: ^2gametype^7");
943 void GameCommand_lockteams(float request)
947 case CMD_REQUEST_COMMAND:
952 bprint("^1The teams are now locked.\n");
956 bprint("lockteams command can only be used in a team-based gamemode.\n");
962 case CMD_REQUEST_USAGE:
964 LOG_INFO("Usage:^3 sv_cmd lockteams");
965 LOG_INFO(" No arguments required.");
966 LOG_INFO("See also: ^2unlockteams^7");
972 void GameCommand_make_mapinfo(float request)
976 case CMD_REQUEST_COMMAND:
980 tmp_entity = new(make_mapinfo);
981 setthink(tmp_entity, make_mapinfo_Think);
982 tmp_entity.nextthink = time;
988 case CMD_REQUEST_USAGE:
990 LOG_INFO("Usage:^3 sv_cmd make_mapinfo");
991 LOG_INFO(" No arguments required.");
992 LOG_INFO("See also: ^2radarmap^7");
998 void GameCommand_moveplayer(float request, float argc)
1002 case CMD_REQUEST_COMMAND:
1007 string targets = strreplace(",", " ", argv(1));
1008 string original_targets = strreplace(" ", ", ", targets);
1009 string destination = argv(2);
1011 string successful, t;
1012 successful = string_null;
1014 // lets see if the target(s) even actually exist.
1015 if ((targets) && (destination))
1020 targets = cdr(targets);
1022 // Check to see if the player is a valid target
1023 client = GetFilteredEntity(t);
1024 accepted = VerifyClientEntity(client, false, false);
1028 LOG_INFO("moveplayer: ", GetClientErrorString(accepted, t), (targets ? ", skipping to next player.\n" : "."));
1032 // Where are we putting this player?
1033 if (destination == "spec" || destination == "spectator")
1035 if (!IS_SPEC(client) && !IS_OBSERVER(client))
1037 if (client.caplayer) client.caplayer = 0;
1038 PutObserverInServer(client);
1040 successful = strcat(successful, (successful ? ", " : ""), playername(client, false));
1044 LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", playername(client, false), ") is already spectating.");
1050 if (!IS_SPEC(client) && !IS_OBSERVER(client))
1056 float save = client.team_forced;
1057 client.team_forced = 0;
1059 // find the team to move the player to
1060 team_id = Team_ColorToTeam(destination);
1062 if (team_id == client.team) // already on the destination team
1064 // keep the forcing undone
1065 LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", playername(client, false), ") is already on the ", Team_ColoredFullName(client.team), (targets ? "^7, skipping to next player.\n" : "^7."));
1068 else if (team_id == 0) // auto team
1070 balance = TeamBalance_CheckAllowedTeams(client);
1071 team_id = Team_IndexToTeam(TeamBalance_FindBestTeam(balance, client, false));
1075 balance = TeamBalance_CheckAllowedTeams(client);
1077 client.team_forced = save;
1079 // Check to see if the destination team is even available
1084 if (!TeamBalance_IsTeamAllowed(balance, 1))
1086 LOG_INFO("Sorry, can't move player to red team if it doesn't exist.");
1087 TeamBalance_Destroy(balance);
1090 TeamBalance_Destroy(balance);
1095 if (!TeamBalance_IsTeamAllowed(balance, 2))
1097 LOG_INFO("Sorry, can't move player to blue team if it doesn't exist.");
1098 TeamBalance_Destroy(balance);
1101 TeamBalance_Destroy(balance);
1106 if (!TeamBalance_IsTeamAllowed(balance, 3))
1108 LOG_INFO("Sorry, can't move player to yellow team if it doesn't exist.");
1109 TeamBalance_Destroy(balance);
1112 TeamBalance_Destroy(balance);
1117 if (!TeamBalance_IsTeamAllowed(balance, 4))
1119 LOG_INFO("Sorry, can't move player to pink team if it doesn't exist.");
1120 TeamBalance_Destroy(balance);
1123 TeamBalance_Destroy(balance);
1128 LOG_INFO("Sorry, can't move player here if team ", destination, " doesn't exist.");
1133 // If so, lets continue and finally move the player
1134 client.team_forced = 0;
1135 if (MoveToTeam(client, Team_TeamToIndex(team_id), 6))
1137 successful = strcat(successful, (successful ? ", " : ""), playername(client, false));
1138 LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", playername(client, false), ") has been moved to the ", Team_ColoredFullName(team_id), "^7.");
1142 LOG_INFO("Unable to move player ", ftos(GetFilteredNumber(t)), " (", playername(client, false), ")");
1148 LOG_INFO("Can't change teams when currently not playing a team game.");
1154 LOG_INFO("Can't change teams if the player isn't in the game."); // well technically we could, but should we allow that? :P
1160 if (successful) bprint("Successfully moved players ", successful, " to destination ", destination, ".\n");
1161 else LOG_INFO("No players given (", original_targets, ") are able to move.");
1163 return; // still correct parameters so return to avoid usage print
1168 LOG_INFO("Incorrect parameters for ^2moveplayer^7");
1169 case CMD_REQUEST_USAGE:
1171 LOG_INFO("Usage:^3 sv_cmd moveplayer clients destination");
1172 LOG_INFO(" 'clients' is a list (separated by commas) of player entity ID's or nicknames");
1173 LOG_INFO(" 'destination' is what to send the player to, be it team or spectating");
1174 LOG_INFO(" Full list of destinations here: \"spec, spectator, red, blue, yellow, pink, auto.\"");
1175 LOG_INFO("Examples: sv_cmd moveplayer 1,3,5 red 3");
1176 LOG_INFO(" sv_cmd moveplayer 2 spec ");
1177 LOG_INFO("See also: ^2allspec, shuffleteams^7");
1183 void GameCommand_nospectators(float request)
1187 case CMD_REQUEST_COMMAND:
1189 blockSpectators = 1;
1190 // give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
1191 FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_SPEC(it) || IS_OBSERVER(it)) && !it.caplayer, {
1194 CS(it).spectatortime = time;
1195 Send_Notification(NOTIF_ONE_ONLY, it, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
1198 bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n"));
1203 case CMD_REQUEST_USAGE:
1205 LOG_INFO("Usage:^3 sv_cmd nospectators");
1206 LOG_INFO(" No arguments required.");
1212 void GameCommand_playerdemo(float request, float argc)
1216 case CMD_REQUEST_COMMAND:
1218 if (argv(2) && argv(3))
1221 float i, n, accepted;
1227 client = GetIndexedEntity(argc, 2);
1228 accepted = VerifyClientEntity(client, false, true);
1232 LOG_INFO("playerdemo: read: ", GetClientErrorString(accepted, argv(2)), ".");
1236 playerdemo_open_read(client, argv(next_token));
1242 client = GetIndexedEntity(argc, 2);
1243 accepted = VerifyClientEntity(client, false, false);
1247 LOG_INFO("playerdemo: write: ", GetClientErrorString(accepted, argv(2)), ".");
1251 playerdemo_open_write(client, argv(next_token));
1255 case "auto_read_and_write":
1257 n = GetFilteredNumber(argv(3));
1258 cvar_set("bot_number", ftos(n));
1260 localcmd("wait; wait; wait\n");
1261 for (i = 0; i < n; ++i)
1262 localcmd("sv_cmd playerdemo read ", ftos(i + 2), " ", argv(2), ftos(i + 1), "\n");
1263 localcmd("sv_cmd playerdemo write 1 ", ftos(n + 1), "\n");
1269 n = GetFilteredNumber(argv(3));
1270 cvar_set("bot_number", ftos(n));
1272 localcmd("wait; wait; wait\n");
1273 for (i = 0; i < n; ++i)
1274 localcmd("sv_cmd playerdemo read ", ftos(i + 2), " ", argv(2), ftos(i + 1), "\n");
1282 LOG_INFO("Incorrect parameters for ^2playerdemo^7");
1283 case CMD_REQUEST_USAGE:
1285 LOG_INFO("Usage:^3 sv_cmd playerdemo command (entitynumber filename | entitynumber botnumber)");
1286 LOG_INFO(" Full list of commands here: \"read, write, auto_read_and_write, auto_read.\"");
1292 void GameCommand_printstats(float request)
1296 case CMD_REQUEST_COMMAND:
1299 LOG_INFO("stats dumped.");
1304 case CMD_REQUEST_USAGE:
1306 LOG_INFO("Usage:^3 sv_cmd printstats");
1307 LOG_INFO(" No arguments required.");
1313 void GameCommand_radarmap(float request, float argc)
1317 case CMD_REQUEST_COMMAND:
1319 if (RadarMap_Make(argc)) return;
1323 LOG_INFO("Incorrect parameters for ^2radarmap^7");
1324 case CMD_REQUEST_USAGE:
1326 LOG_INFO("Usage:^3 sv_cmd radarmap [--force] [--loop] [--quit] [--block | --trace | --sample | --lineblock] [--sharpen N] [--res W H] [--qual Q]");
1327 LOG_INFO(" The quality factor Q is roughly proportional to the time taken.");
1328 LOG_INFO(" trace supports no quality factor; its result should look like --block with infinite quality factor.");
1329 LOG_INFO("See also: ^2make_mapinfo^7");
1335 void GameCommand_reducematchtime(float request)
1339 case CMD_REQUEST_COMMAND:
1341 changematchtime(autocvar_timelimit_decrement * -60, autocvar_timelimit_min * 60, autocvar_timelimit_max * 60);
1346 case CMD_REQUEST_USAGE:
1348 LOG_INFO("Usage:^3 sv_cmd reducematchtime");
1349 LOG_INFO(" No arguments required.");
1350 LOG_INFO("See also: ^2extendmatchtime^7");
1356 void GameCommand_setbots(float request, float argc)
1360 case CMD_REQUEST_COMMAND:
1364 cvar_settemp("minplayers", "0");
1365 cvar_settemp("bot_number", argv(1));
1372 LOG_INFO("Incorrect parameters for ^2setbots^7");
1373 case CMD_REQUEST_USAGE:
1375 LOG_INFO("Usage:^3 sv_cmd setbots botnumber");
1376 LOG_INFO(" Where 'botnumber' is the amount of bots to set bot_number cvar to.");
1377 LOG_INFO("See also: ^2bot_cmd^7");
1383 void GameCommand_shuffleteams(float request)
1387 case CMD_REQUEST_COMMAND:
1391 LOG_INFO("Can't shuffle teams when currently not playing a team game.");
1395 FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, {
1396 if (it.team_forced) {
1397 // we could theoretically assign forced players to their teams
1398 // and shuffle the rest to fill the empty spots but in practise
1399 // either all players or none are gonna have forced teams
1400 LOG_INFO("Can't shuffle teams because at least one player has a forced team.");
1405 int number_of_teams = 0;
1406 entity balance = TeamBalance_CheckAllowedTeams(NULL);
1407 for (int i = 1; i <= NUM_TEAMS; ++i)
1409 if (TeamBalance_IsTeamAllowed(balance, i))
1411 number_of_teams = max(i, number_of_teams);
1414 TeamBalance_Destroy(balance);
1417 FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, {
1418 int target_team_index = team_index + 1;
1419 if (Entity_GetTeamIndex(it) != target_team_index)
1421 MoveToTeam(it, target_team_index, 6);
1423 team_index = (team_index + 1) % number_of_teams;
1426 bprint("Successfully shuffled the players around randomly.\n");
1431 case CMD_REQUEST_USAGE:
1433 LOG_INFO("Usage:^3 sv_cmd shuffleteams");
1434 LOG_INFO(" No arguments required.");
1435 LOG_INFO("See also: ^2moveplayer, allspec^7");
1441 void GameCommand_stuffto(float request, float argc)
1443 // This... is a fairly dangerous and powerful command... - It allows any arguments to be sent to a client via rcon.
1444 // Because of this, it is disabled by default and must be enabled by the server owner when doing compilation. That way,
1445 // we can be certain they understand the risks of it... So to enable, compile server with -DSTUFFTO_ENABLED argument.
1447 #ifdef STUFFTO_ENABLED
1450 case CMD_REQUEST_COMMAND:
1454 entity client = GetIndexedEntity(argc, 1);
1455 float accepted = VerifyClientEntity(client, true, false);
1459 stuffcmd(client, strcat("\n", argv(next_token), "\n"));
1460 LOG_INFO("Command: \"", argv(next_token), "\" sent to ", GetCallerName(client), " (", argv(1), ").");
1464 LOG_INFO("stuffto: ", GetClientErrorString(accepted, argv(1)), ".");
1472 LOG_INFO("Incorrect parameters for ^2stuffto^7");
1473 case CMD_REQUEST_USAGE:
1475 LOG_INFO("Usage:^3 sv_cmd stuffto client \"command\"");
1476 LOG_INFO(" 'client' is the entity number or name of the player,");
1477 LOG_INFO(" and 'command' is the command to be sent to that player.");
1484 LOG_INFO("stuffto command is not enabled on this server.");
1490 void GameCommand_trace(float request, float argc)
1494 case CMD_REQUEST_COMMAND:
1497 vector org, delta, start, end, p, q, q0, pos, vv, dv;
1498 float i, f, safe, unsafe, dq, dqf;
1505 LOG_INFO("TEST CASE. If this returns the runaway loop counter error, possibly everything is oaky.");
1506 float worst_endpos_bug = 0;
1510 delta = world.maxs - world.mins;
1512 start.x = org.x + random() * delta.x;
1513 start.y = org.y + random() * delta.y;
1514 start.z = org.z + random() * delta.z;
1516 end.x = org.x + random() * delta.x;
1517 end.y = org.y + random() * delta.y;
1518 end.z = org.z + random() * delta.z;
1520 start = stov(vtos(start));
1521 end = stov(vtos(end));
1523 tracebox(start, PL_MIN_CONST, PL_MAX_CONST, end, MOVE_NOMONSTERS, NULL);
1524 if (!trace_startsolid && trace_fraction < 1)
1527 tracebox(p, PL_MIN_CONST, PL_MAX_CONST, p, MOVE_NOMONSTERS, NULL);
1528 if (trace_startsolid)
1530 rint(42); // do an engine breakpoint on VM_rint so you can get the trace that errnoeously returns startsolid
1531 tracebox(start, PL_MIN_CONST, PL_MAX_CONST, end, MOVE_NOMONSTERS, NULL);
1533 // how much do we need to back off?
1538 pos = p * (1 - (safe + unsafe) * 0.5) + start * ((safe + unsafe) * 0.5);
1539 tracebox(pos, PL_MIN_CONST, PL_MAX_CONST, pos, MOVE_NOMONSTERS, NULL);
1540 if (trace_startsolid)
1542 if ((safe + unsafe) * 0.5 == unsafe) break;
1543 unsafe = (safe + unsafe) * 0.5;
1547 if ((safe + unsafe) * 0.5 == safe) break;
1548 safe = (safe + unsafe) * 0.5;
1552 LOG_INFO("safe distance to back off: ", ftos(safe * vlen(p - start)), "qu");
1553 LOG_INFO("unsafe distance to back off: ", ftos(unsafe * vlen(p - start)), "qu");
1555 tracebox(p, PL_MIN_CONST + '0.1 0.1 0.1', PL_MAX_CONST - '0.1 0.1 0.1', p, MOVE_NOMONSTERS, NULL);
1556 if (trace_startsolid) LOG_INFO("trace_endpos much in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p));
1557 else LOG_INFO("trace_endpos just in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p));
1558 if (++hitcount >= 10) break;
1567 q = p + normalize(end - p) * (dq + dqf);
1569 tracebox(p, PL_MIN_CONST, PL_MAX_CONST, q, MOVE_NOMONSTERS, NULL);
1570 if (trace_startsolid) error("THIS ONE cannot happen");
1571 if (trace_fraction > 0) dq += dqf * trace_fraction;
1575 if (dq > worst_endpos_bug)
1577 worst_endpos_bug = dq;
1578 LOG_INFO("trace_endpos still before solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p));
1579 LOG_INFO("could go ", ftos(dq), " units further to ", vtos(q));
1580 if (++hitcount >= 10) break;
1591 tracebox(e.origin + '0 0 32', e.mins, e.maxs, e.origin + '0 0 -1024', MOVE_NORMAL, e);
1593 if (trace_fraction == 1)
1595 LOG_INFO("not above ground, aborting");
1599 for (i = 0; i < 100000; ++i)
1602 if (dv.z > 0) dv = -1 * dv;
1603 tracebox(vv, e.mins, e.maxs, vv + dv, MOVE_NORMAL, e);
1604 if (trace_startsolid) LOG_INFO("bug 1");
1605 if (trace_fraction == 1)
1609 LOG_INFO("bug 2: ", ftos(dv.x), " ", ftos(dv.y), " ", ftos(dv.z));
1610 LOG_INFO(" (", ftos(asin(dv.z / vlen(dv)) * 180 / M_PI), " degrees)");
1615 LOG_INFO("highest possible dist: ", ftos(f));
1621 if (argc == 4 || argc == 5)
1624 int dphitcontentsmask_save = e.dphitcontentsmask;
1625 e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
1626 if (tracewalk(e, stov(argv(2)), e.mins, e.maxs, stov(argv(3)), stof(argv(4)), MOVE_NORMAL))
1627 LOG_INFO("can walk");
1629 LOG_INFO("cannot walk");
1630 e.dphitcontentsmask = dphitcontentsmask_save;
1641 traceline(vv, dv, MOVE_NORMAL, NULL);
1642 __trailparticles(NULL, particleeffectnum(EFFECT_TR_NEXUIZPLASMA), vv, trace_endpos);
1643 __trailparticles(NULL, particleeffectnum(EFFECT_TR_CRYLINKPLASMA), trace_endpos, dv);
1648 // no default case, just go straight to invalid
1653 LOG_INFO("Incorrect parameters for ^2trace^7");
1654 case CMD_REQUEST_USAGE:
1656 LOG_INFO("Usage:^3 sv_cmd trace command [startpos endpos] [endpos_height]");
1657 LOG_INFO(" Where startpos and endpos are parameters for 'walk' and 'showline' commands,");
1658 LOG_INFO(" 'endpos_height' is an optional parameter for 'walk' command,");
1659 LOG_INFO(" Full list of commands here: \"debug, debug2, walk, showline.\"");
1660 LOG_INFO("See also: ^2bbox, gettaginfo^7");
1666 void GameCommand_unlockteams(float request)
1670 case CMD_REQUEST_COMMAND:
1675 bprint("^1The teams are now unlocked.\n");
1679 bprint("unlockteams command can only be used in a team-based gamemode.\n");
1685 case CMD_REQUEST_USAGE:
1687 LOG_INFO("Usage:^3 sv_cmd unlockteams");
1688 LOG_INFO(" No arguments required.");
1689 LOG_INFO("See also: ^2lockteams^7");
1695 void GameCommand_warp(float request, float argc)
1699 case CMD_REQUEST_COMMAND:
1701 if (autocvar_g_campaign)
1705 CampaignLevelWarp(stof(argv(1)));
1706 LOG_INFO("Successfully warped to campaign level ", argv(1), ".");
1710 CampaignLevelWarp(-1);
1711 LOG_INFO("Successfully warped to next campaign level.");
1716 LOG_INFO("Not in campaign, can't level warp");
1722 case CMD_REQUEST_USAGE:
1724 LOG_INFO("Usage:^3 sv_cmd warp [level]");
1725 LOG_INFO(" 'level' is the level to change campaign mode to.");
1726 LOG_INFO(" if 'level' is not provided it will change to the next level.");
1732 /* use this when creating a new command, making sure to place it in alphabetical order... also,
1733 ** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION!
1734 void GameCommand_(float request)
1738 case CMD_REQUEST_COMMAND:
1745 case CMD_REQUEST_USAGE:
1747 print("\nUsage:^3 sv_cmd \n");
1748 print(" No arguments required.\n");
1756 // ==================================
1757 // Macro system for server commands
1758 // ==================================
1760 // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
1761 SERVER_COMMAND(adminmsg, "Send an admin message to a client directly") { GameCommand_adminmsg(request, arguments); }
1762 SERVER_COMMAND(allready, "Restart the server and reset the players") { GameCommand_allready(request); }
1763 SERVER_COMMAND(allspec, "Force all players to spectate") { GameCommand_allspec(request, arguments); }
1764 SERVER_COMMAND(anticheat, "Create an anticheat report for a client") { GameCommand_anticheat(request, arguments); }
1765 SERVER_COMMAND(animbench, "Benchmark model animation (LAGS)") { GameCommand_animbench(request, arguments); }
1766 SERVER_COMMAND(bbox, "Print detailed information about world size") { GameCommand_bbox(request); }
1767 SERVER_COMMAND(bot_cmd, "Control and send commands to bots") { GameCommand_bot_cmd(request, arguments, command); }
1768 SERVER_COMMAND(cointoss, "Flip a virtual coin and give random result") { GameCommand_cointoss(request, arguments); }
1769 SERVER_COMMAND(database, "Extra controls of the serverprogs database") { GameCommand_database(request, arguments); }
1770 SERVER_COMMAND(defer_clear, "Clear all queued defer commands for a specific client") { GameCommand_defer_clear(request, arguments); }
1771 SERVER_COMMAND(defer_clear_all, "Clear all queued defer commands for all clients") { GameCommand_defer_clear_all(request); }
1772 SERVER_COMMAND(delrec, "Delete race time record for a map") { GameCommand_delrec(request, arguments); }
1773 SERVER_COMMAND(effectindexdump, "Dump list of effects from code and effectinfo.txt") { GameCommand_effectindexdump(request); }
1774 SERVER_COMMAND(extendmatchtime, "Increase the timelimit value incrementally") { GameCommand_extendmatchtime(request); }
1775 SERVER_COMMAND(gametype, "Simple command to change the active gametype") { GameCommand_gametype(request, arguments); }
1776 SERVER_COMMAND(gettaginfo, "Get specific information about a weapon model") { GameCommand_gettaginfo(request, arguments); }
1777 SERVER_COMMAND(gotomap, "Simple command to switch to another map") { GameCommand_gotomap(request, arguments); }
1778 SERVER_COMMAND(lockteams, "Disable the ability for players to switch or enter teams") { GameCommand_lockteams(request); }
1779 SERVER_COMMAND(make_mapinfo, "Automatically rebuild mapinfo files") { GameCommand_make_mapinfo(request); }
1780 SERVER_COMMAND(moveplayer, "Change the team/status of a player") { GameCommand_moveplayer(request, arguments); }
1781 SERVER_COMMAND(nospectators, "Automatically remove spectators from a match") { GameCommand_nospectators(request); }
1782 SERVER_COMMAND(playerdemo, "Control the ability to save demos of players") { GameCommand_playerdemo(request, arguments); }
1783 SERVER_COMMAND(printstats, "Dump eventlog player stats and other score information") { GameCommand_printstats(request); }
1784 SERVER_COMMAND(radarmap, "Generate a radar image of the map") { GameCommand_radarmap(request, arguments); }
1785 SERVER_COMMAND(reducematchtime, "Decrease the timelimit value incrementally") { GameCommand_reducematchtime(request); }
1786 SERVER_COMMAND(setbots, "Adjust how many bots are in the match") { GameCommand_setbots(request, arguments); }
1787 SERVER_COMMAND(shuffleteams, "Randomly move players to different teams") { GameCommand_shuffleteams(request); }
1788 SERVER_COMMAND(stuffto, "Send a command to be executed on a client") { GameCommand_stuffto(request, arguments); }
1789 SERVER_COMMAND(trace, "Various debugging tools with tracing") { GameCommand_trace(request, arguments); }
1790 SERVER_COMMAND(unlockteams, "Enable the ability for players to switch or enter teams") { GameCommand_unlockteams(request); }
1791 SERVER_COMMAND(warp, "Choose different level in campaign") { GameCommand_warp(request, arguments); }
1793 void GameCommand_macro_help()
1795 FOREACH(SERVER_COMMANDS, true, { LOG_INFOF(" ^2%s^7: %s", it.m_name, it.m_description); });
1798 float GameCommand_macro_command(float argc, string command)
1800 string c = strtolower(argv(0));
1801 FOREACH(SERVER_COMMANDS, it.m_name == c, {
1802 it.m_invokecmd(it, CMD_REQUEST_COMMAND, NULL, argc, command);
1808 float GameCommand_macro_usage(float argc)
1810 string c = strtolower(argv(1));
1811 FOREACH(SERVER_COMMANDS, it.m_name == c, {
1812 it.m_invokecmd(it, CMD_REQUEST_USAGE, NULL, argc, "");
1818 void GameCommand_macro_write_aliases(float fh)
1820 FOREACH(SERVER_COMMANDS, true, { CMD_Write_Alias("qc_cmd_sv", it.m_name, it.m_description); });
1824 // =========================================
1825 // Main Function Called By Engine (sv_cmd)
1826 // =========================================
1827 // If this function exists, game code handles gamecommand instead of the engine code.
1829 void GameCommand(string command)
1831 float argc = tokenize_console(command);
1833 // Guide for working with argc arguments by example:
1834 // argc: 1 - 2 - 3 - 4
1835 // argv: 0 - 1 - 2 - 3
1836 // cmd vote - master - login - password
1838 if (strtolower(argv(0)) == "help")
1842 LOG_INFO("Server console commands:");
1843 GameCommand_macro_help();
1845 LOG_INFO("\nBanning commands:");
1846 BanCommand_macro_help();
1848 LOG_INFO("\nCommon networked commands:");
1849 CommonCommand_macro_help(NULL);
1851 LOG_INFO("\nGeneric commands shared by all programs:");
1852 GenericCommand_macro_help();
1855 "\nUsage:^3 sv_cmd COMMAND...^7, where possible commands are listed above.\n"
1856 "For help about a specific command, type sv_cmd help COMMAND"
1861 else if (BanCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it
1865 else if (CommonCommand_macro_usage(argc, NULL)) // same here, but for common commands instead
1869 else if (GenericCommand_macro_usage(argc)) // same here, but for generic commands instead
1873 else if (GameCommand_macro_usage(argc)) // finally try for normal commands too
1878 else if (MUTATOR_CALLHOOK(SV_ParseServerCommand, strtolower(argv(0)), argc, command))
1880 return; // handled by a mutator
1882 else if (BanCommand(command))
1884 return; // handled by server/command/ipban.qc
1886 else if (CommonCommand_macro_command(argc, NULL, command))
1888 return; // handled by server/command/common.qc
1890 else if (GenericCommand(command))
1892 return; // handled by common/command/generic.qc
1894 else if (GameCommand_macro_command(argc, command)) // continue as usual and scan for normal commands
1896 return; // handled by one of the above GameCommand_* functions
1899 // nothing above caught the command, must be invalid
1900 LOG_INFO(((command != "") ? strcat("Unknown server command \"", command, "\"") : "No command provided"), ". For a list of supported commands, try sv_cmd help.");