1 // =====================================================
2 // Server side game commands code, reworked by Samual
3 // Last updated: November 6th, 2011
4 // =====================================================
6 #define GC_REQUEST_COMMAND 1
7 #define GC_REQUEST_USAGE 2
9 float RadarMap_Make(float argc);
11 string GotoMap(string m);
13 void race_deleteTime(string map, float pos);
16 // ============================
17 // Misc. Supporting Functions
18 // ============================
20 // used by GameCommand_make_mapinfo()
21 void make_mapinfo_Think()
23 if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
25 print("Done rebuiling mapinfos.\n");
26 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
31 self.think = make_mapinfo_Think;
32 self.nextthink = time;
36 // used by GameCommand_extendmatchtime() and GameCommand_reducematchtime()
37 void changematchtime(float delta, float mi, float ma)
45 if(autocvar_timelimit < 0)
49 mi = 10; // at least ten sec in the future
50 cur = time - game_starttime;
52 mi += cur; // from current time!
54 lim = autocvar_timelimit * 60;
59 return; // cannot increase any further
61 new = min(ma, lim + delta);
62 else // already above maximum: FAIL
67 if(lim == 0) // infinite: try reducing to max, if we are allowed to
69 else if(lim > mi) // above minimum: decrease
70 new = max(mi, lim + delta);
71 else // already below minimum: FAIL
75 cvar_set("timelimit", ftos(new / 60));
78 // used by GameCommand_modelbug() // TODO: is this even needed?
79 float g_clientmodel_genericsendentity (entity to, float sf);
80 void modelbug_make_svqc();
81 void modelbug_make_csqc()
83 Net_LinkEntity(self, TRUE, 0, g_clientmodel_genericsendentity);
84 self.think = modelbug_make_svqc;
85 self.nextthink = time + 1;
86 setorigin(self, self.origin - '0 0 8');
88 void modelbug_make_svqc()
90 self.SendEntity = func_null;
91 self.think = modelbug_make_csqc;
92 self.nextthink = time + 1;
93 setorigin(self, self.origin + '0 0 8');
99 setorigin(e, nextent(world).origin);
100 precache_model("models_portal.md3");
101 setmodel(e, "models/portal.md3");
102 e.think = modelbug_make_svqc;
103 e.nextthink = time + 1;
107 // =======================
108 // Command Sub-Functions
109 // =======================
111 void GameCommand_adminmsg(float request, float argc)
115 case GC_REQUEST_COMMAND:
118 float entno = stof(argv(1));
122 if(argc >= 3 && argc <= 4) {
123 if((entno < 0) | (entno > maxclients)) {
124 print("Player ", argv(1), " doesn't exist\n");
128 for(i = (entno ? entno : 1); i <= (entno ? entno : maxclients); ++i)
130 client = edict_num(i);
131 if(client.flags & FL_CLIENT)
135 // make the string console safe
137 s = strreplace("\n", "", s);
138 s = strreplace("\\", "\\\\", s);
139 s = strreplace("$", "$$", s);
140 s = strreplace("\"", "\\\"", s);
141 stuffcmd(client, sprintf("\ninfobar %f \"%s\"\n", stof(argv(3)), s));
145 centerprint(client, strcat("^3", admin_name(), ":\n\n^7", argv(2)));
146 sprint(client, strcat("\{1}\{13}^3", admin_name(), "^7: ", argv(2), "\n"));
148 dprint("Message sent to ", client.netname, "\n");
152 if(!n) { print(strcat("Client (", argv(1) ,") not found.\n")); }
158 print("Incorrect parameters for ^2adminmsg^7\n");
159 case GC_REQUEST_USAGE:
161 print("\nUsage:^3 sv_cmd adminmsg clientnumber \"message\" [infobartime]\n");
162 print(" If infobartime is provided, the message will be sent to infobar.\n");
163 print(" Otherwise, it will just be sent as a centerprint message.\n");
164 print("Examples: adminmsg 4 \"this infomessage will last for ten seconds\" 10\n");
165 print(" adminmsg 2 \"this message will be a centerprint\"\n");
171 void GameCommand_allready(float request)
175 case GC_REQUEST_COMMAND:
182 case GC_REQUEST_USAGE:
184 print("\nUsage:^3 sv_cmd allready\n");
185 print(" No arguments required.\n");
191 void GameCommand_allspec(float request, float argc)
195 case GC_REQUEST_COMMAND:
198 string reason = argv(1);
201 FOR_EACH_PLAYER(client)
204 PutObserverInServer();
207 if(i) { bprint(strcat("Successfully forced all (", ftos(i), ") players to spectate", (reason ? strcat(" for reason: '", reason, "'") : ""), ".\n")); }
208 else { print("No players found to spectate.\n"); }
213 case GC_REQUEST_USAGE:
215 print("\nUsage:^3 sv_cmd allspec [reason]\n");
216 print(" Where 'reason' is an optional argument for explanation of allspec command.\n");
217 print("See also: ^2moveplayer^7\n");
223 void GameCommand_anticheat(float request, float argc)
227 case GC_REQUEST_COMMAND:
230 float entno = stof(argv(1));
232 if((entno < 1) | (entno > maxclients)) {
233 print("Player ", argv(1), " doesn't exist\n");
236 client = edict_num(entno);
237 if(clienttype(client) != CLIENTTYPE_REAL || clienttype(client) != CLIENTTYPE_BOT) {
238 print("Player ", client.netname, " is not active\n");
247 print("Incorrect parameters for ^2anticheat^7\n");
248 case GC_REQUEST_USAGE:
250 print("\nUsage:^3 sv_cmd anticheat clientnumber\n");
251 print(" where 'clientnumber' is player entity number.\n");
257 void GameCommand_bbox(float request)
261 case GC_REQUEST_COMMAND:
263 print("Original size: ", ftos(world.absmin_x), " ", ftos(world.absmin_y), " ", ftos(world.absmin_z));
264 print(" ", ftos(world.absmax_x), " ", ftos(world.absmax_y), " ", ftos(world.absmax_z), "\n");
265 print("Currently set size: ", ftos(world.mins_x), " ", ftos(world.mins_y), " ", ftos(world.mins_z));
266 print(" ", ftos(world.maxs_x), " ", ftos(world.maxs_y), " ", ftos(world.maxs_z), "\n");
267 print("Solid bounding box size:");
269 tracebox('1 0 0' * world.absmin_x,
270 '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
271 '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
272 '1 0 0' * world.absmax_x,
276 print(" ", ftos(world.absmin_x));
278 print(" ", ftos(trace_endpos_x));
280 tracebox('0 1 0' * world.absmin_y,
281 '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
282 '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
283 '0 1 0' * world.absmax_y,
287 print(" ", ftos(world.absmin_y));
289 print(" ", ftos(trace_endpos_y));
291 tracebox('0 0 1' * world.absmin_z,
292 '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
293 '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
294 '0 0 1' * world.absmax_z,
298 print(" ", ftos(world.absmin_z));
300 print(" ", ftos(trace_endpos_z));
302 tracebox('1 0 0' * world.absmax_x,
303 '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
304 '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
305 '1 0 0' * world.absmin_x,
309 print(" ", ftos(world.absmax_x));
311 print(" ", ftos(trace_endpos_x));
313 tracebox('0 1 0' * world.absmax_y,
314 '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
315 '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
316 '0 1 0' * world.absmin_y,
320 print(" ", ftos(world.absmax_y));
322 print(" ", ftos(trace_endpos_y));
324 tracebox('0 0 1' * world.absmax_z,
325 '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
326 '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
327 '0 0 1' * world.absmin_z,
331 print(" ", ftos(world.absmax_z));
333 print(" ", ftos(trace_endpos_z));
340 case GC_REQUEST_USAGE:
342 print("\nUsage:^3 sv_cmd bbox\n");
343 print(" No arguments required.\n");
344 print("See also: ^2gettaginfo^7\n");
350 void GameCommand_bot_cmd(float request, float argc) // what a mess... old old code.
354 case GC_REQUEST_COMMAND:
358 if(argv(1) == "reset")
363 else if(argv(1) == "load" && argc == 3)
367 fh = fopen(argv(2), FILE_READ);
370 print("cannot open the file\n");
375 while((s = fgets(fh)))
377 argc = tokenize_console(s);
379 if(argc >= 3 && argv(0) == "sv_cmd" && argv(1) == "bot_cmd")
381 if(argv(2) == "reset")
385 else if(argv(2) == "setbots")
387 cvar_settemp("minplayers", "0");
388 cvar_settemp("bot_number", argv(3));
390 print("Sorry, could not set requested bot count\n");
394 // let's start at token 2 so we can skip sv_cmd bot_cmd
395 bot = find_bot_by_number(stof(argv(2)));
397 bot = find_bot_by_name(argv(2));
399 bot_queuecommand(bot, strcat(argv(3), " ", argv(4)));
403 localcmd(strcat(s, "\n"));
407 print(ftos(i), " commands read\n");
411 else if(argv(1) == "help")
414 bot_cmdhelp(argv(2));
419 else if(argc >= 3) // this comes last
421 bot = find_bot_by_number(stof(argv(1)));
423 bot = find_bot_by_name(argv(1));
426 print(strcat("Command '", strcat(argv(2), " ", argv(3)), "' sent to bot ", bot.netname, "\n"));
427 bot_queuecommand(bot, strcat(argv(2), " ", argv(3)));
431 print(strcat("Error: Can't find bot with the name or id '", argv(1),"' - Did you mistype the command?\n")); // don't return so that usage is shown
436 print("Incorrect parameters for ^2bot_cmd^7\n");
437 case GC_REQUEST_USAGE:
439 print("\nUsage:^3 sv_cmd bot_cmd client command [argument]\n");
440 print(" 'client' can be either the name or entity id of the bot\n");
441 print(" For full list of commands, see bot_cmd help [command].\n");
442 print("Examples: bot_cmd <id> cc \"say something\"\n");
443 print(" bot_cmd <id> presskey jump\n");
449 void GameCommand_cointoss(float request, float argc)
453 case GC_REQUEST_COMMAND:
456 string result1 = (argv(2) ? strcat("^7", argv(1), "^3!\n") : "^1HEADS^3!\n");
457 string result2 = (argv(2) ? strcat("^7", argv(2), "^3!\n") : "^4TAILS^3!\n");
458 string choice = ((random() > 0.5) ? result1 : result2);
460 FOR_EACH_CLIENT(client)
461 centerprint(client, strcat("^3Throwing coin... Result: ", choice));
462 bprint(strcat("^3Throwing coin... Result: ", choice));
467 case GC_REQUEST_USAGE:
469 print("\nUsage:^3 sv_cmd cointoss [result1 result2]\n");
470 print(" Where 'result1' and 'result2' are user created options.\n");
476 void GameCommand_cvar_changes(float request)
480 case GC_REQUEST_COMMAND:
487 case GC_REQUEST_USAGE:
489 print("\nUsage:^3 sv_cmd cvar_changes\n");
490 print(" No arguments required.\n");
491 print("See also: ^2cvar_purechanges^7\n");
497 void GameCommand_cvar_purechanges(float request)
501 case GC_REQUEST_COMMAND:
503 print(cvar_purechanges);
508 case GC_REQUEST_USAGE:
510 print("\nUsage:^3 sv_cmd cvar_purechanges\n");
511 print(" No arguments required.\n");
512 print("See also: ^2cvar_changes^7\n");
518 void GameCommand_database(float request, float argc)
522 case GC_REQUEST_COMMAND:
526 if(argv(1) == "save")
528 db_save(ServerProgsDB, argv(2));
529 print(strcat("Copied serverprogs database to '", argv(2), "' in the data directory.\n"));
532 else if(argv(1) == "dump")
534 db_dump(ServerProgsDB, argv(2));
535 print("DB dumped.\n"); // wtf does this do?
538 else if(argv(1) == "load")
540 db_close(ServerProgsDB);
541 ServerProgsDB = db_load(argv(2));
542 print(strcat("Loaded '", argv(2), "' as new serverprogs database.\n"));
549 print("Incorrect parameters for ^2database^7\n");
550 case GC_REQUEST_USAGE:
552 print("\nUsage:^3 sv_cmd database action filename\n");
553 print(" Where 'action' is the command to complete,\n");
554 print(" and 'filename' is what it acts upon.\n");
555 print(" Full list of commands here: \"save, dump, load.\"\n");
561 void GameCommand_defer_clear(float request, float argc)
565 case GC_REQUEST_COMMAND:
568 float entno = stof(argv(1));
572 // player_id is out of range
573 if((entno < 1) | (entno > maxclients)) {
574 print("Player ", argv(1), " doesn't exist\n");
577 client = edict_num(entno);
578 if not(client.flags & FL_CLIENT) {
579 print("Player ", argv(1), " doesn't exist\n");
582 if(clienttype(client) == CLIENTTYPE_BOT) {
583 print("Player ", argv(1), " (", client.netname, ") is a bot\n");
586 stuffcmd(client, "defer clear\n");
587 print("defer clear stuffed to ", argv(1), " (", client.netname, ")\n");
593 print("Incorrect parameters for ^2defer_clear^7\n");
594 case GC_REQUEST_USAGE:
596 print("\nUsage:^3 sv_cmd defer_clear clientnumber\n");
597 print(" where 'clientnumber' is player entity number.\n");
598 print("See also: ^2defer_clear_all^7\n");
604 void GameCommand_defer_clear_all(float request)
608 case GC_REQUEST_COMMAND:
614 FOR_EACH_CLIENT(client)
616 argc = tokenize_console(strcat("defer_clear ", ftos(num_for_edict(client))));
617 GameCommand_defer_clear(GC_REQUEST_COMMAND, argc);
620 if(i) { bprint(strcat("Successfully stuffed defer clear to all clients (", ftos(i), ")\n")); } // should a message be added if no players were found?
625 case GC_REQUEST_USAGE:
627 print("\nUsage:^3 sv_cmd defer_clear_all\n");
628 print(" No arguments required.\n");
629 print("See also: ^2defer_clear^7\n");
635 void GameCommand_delrec(float request, float argc) // UNTESTED // perhaps merge later with records and printstats and such?
639 case GC_REQUEST_COMMAND:
644 race_deleteTime(argv(2), stof(argv(1)));
646 race_deleteTime(GetMapname(), stof(argv(1)));
652 print("Incorrect parameters for ^2delrec^7\n");
653 case GC_REQUEST_USAGE:
655 print("\nUsage:^3 sv_cmd delrec ranking [map]\n");
656 print(" 'ranking' is which ranking level to clear up to, \n");
657 print(" it will clear all records up to nth place.\n");
658 print(" if 'map' is not provided it will use current map.\n");
664 void GameCommand_effectindexdump(float request)
668 case GC_REQUEST_COMMAND:
674 print("begin of effects list\n");
675 db_put(d, "TE_GUNSHOT", "1"); print("effect TE_GUNSHOT is ", ftos(particleeffectnum("TE_GUNSHOT")), "\n");
676 db_put(d, "TE_GUNSHOTQUAD", "1"); print("effect TE_GUNSHOTQUAD is ", ftos(particleeffectnum("TE_GUNSHOTQUAD")), "\n");
677 db_put(d, "TE_SPIKE", "1"); print("effect TE_SPIKE is ", ftos(particleeffectnum("TE_SPIKE")), "\n");
678 db_put(d, "TE_SPIKEQUAD", "1"); print("effect TE_SPIKEQUAD is ", ftos(particleeffectnum("TE_SPIKEQUAD")), "\n");
679 db_put(d, "TE_SUPERSPIKE", "1"); print("effect TE_SUPERSPIKE is ", ftos(particleeffectnum("TE_SUPERSPIKE")), "\n");
680 db_put(d, "TE_SUPERSPIKEQUAD", "1"); print("effect TE_SUPERSPIKEQUAD is ", ftos(particleeffectnum("TE_SUPERSPIKEQUAD")), "\n");
681 db_put(d, "TE_WIZSPIKE", "1"); print("effect TE_WIZSPIKE is ", ftos(particleeffectnum("TE_WIZSPIKE")), "\n");
682 db_put(d, "TE_KNIGHTSPIKE", "1"); print("effect TE_KNIGHTSPIKE is ", ftos(particleeffectnum("TE_KNIGHTSPIKE")), "\n");
683 db_put(d, "TE_EXPLOSION", "1"); print("effect TE_EXPLOSION is ", ftos(particleeffectnum("TE_EXPLOSION")), "\n");
684 db_put(d, "TE_EXPLOSIONQUAD", "1"); print("effect TE_EXPLOSIONQUAD is ", ftos(particleeffectnum("TE_EXPLOSIONQUAD")), "\n");
685 db_put(d, "TE_TAREXPLOSION", "1"); print("effect TE_TAREXPLOSION is ", ftos(particleeffectnum("TE_TAREXPLOSION")), "\n");
686 db_put(d, "TE_TELEPORT", "1"); print("effect TE_TELEPORT is ", ftos(particleeffectnum("TE_TELEPORT")), "\n");
687 db_put(d, "TE_LAVASPLASH", "1"); print("effect TE_LAVASPLASH is ", ftos(particleeffectnum("TE_LAVASPLASH")), "\n");
688 db_put(d, "TE_SMALLFLASH", "1"); print("effect TE_SMALLFLASH is ", ftos(particleeffectnum("TE_SMALLFLASH")), "\n");
689 db_put(d, "TE_FLAMEJET", "1"); print("effect TE_FLAMEJET is ", ftos(particleeffectnum("TE_FLAMEJET")), "\n");
690 db_put(d, "EF_FLAME", "1"); print("effect EF_FLAME is ", ftos(particleeffectnum("EF_FLAME")), "\n");
691 db_put(d, "TE_BLOOD", "1"); print("effect TE_BLOOD is ", ftos(particleeffectnum("TE_BLOOD")), "\n");
692 db_put(d, "TE_SPARK", "1"); print("effect TE_SPARK is ", ftos(particleeffectnum("TE_SPARK")), "\n");
693 db_put(d, "TE_PLASMABURN", "1"); print("effect TE_PLASMABURN is ", ftos(particleeffectnum("TE_PLASMABURN")), "\n");
694 db_put(d, "TE_TEI_G3", "1"); print("effect TE_TEI_G3 is ", ftos(particleeffectnum("TE_TEI_G3")), "\n");
695 db_put(d, "TE_TEI_SMOKE", "1"); print("effect TE_TEI_SMOKE is ", ftos(particleeffectnum("TE_TEI_SMOKE")), "\n");
696 db_put(d, "TE_TEI_BIGEXPLOSION", "1"); print("effect TE_TEI_BIGEXPLOSION is ", ftos(particleeffectnum("TE_TEI_BIGEXPLOSION")), "\n");
697 db_put(d, "TE_TEI_PLASMAHIT", "1"); print("effect TE_TEI_PLASMAHIT is ", ftos(particleeffectnum("TE_TEI_PLASMAHIT")), "\n");
698 db_put(d, "EF_STARDUST", "1"); print("effect EF_STARDUST is ", ftos(particleeffectnum("EF_STARDUST")), "\n");
699 db_put(d, "TR_ROCKET", "1"); print("effect TR_ROCKET is ", ftos(particleeffectnum("TR_ROCKET")), "\n");
700 db_put(d, "TR_GRENADE", "1"); print("effect TR_GRENADE is ", ftos(particleeffectnum("TR_GRENADE")), "\n");
701 db_put(d, "TR_BLOOD", "1"); print("effect TR_BLOOD is ", ftos(particleeffectnum("TR_BLOOD")), "\n");
702 db_put(d, "TR_WIZSPIKE", "1"); print("effect TR_WIZSPIKE is ", ftos(particleeffectnum("TR_WIZSPIKE")), "\n");
703 db_put(d, "TR_SLIGHTBLOOD", "1"); print("effect TR_SLIGHTBLOOD is ", ftos(particleeffectnum("TR_SLIGHTBLOOD")), "\n");
704 db_put(d, "TR_KNIGHTSPIKE", "1"); print("effect TR_KNIGHTSPIKE is ", ftos(particleeffectnum("TR_KNIGHTSPIKE")), "\n");
705 db_put(d, "TR_VORESPIKE", "1"); print("effect TR_VORESPIKE is ", ftos(particleeffectnum("TR_VORESPIKE")), "\n");
706 db_put(d, "TR_NEHAHRASMOKE", "1"); print("effect TR_NEHAHRASMOKE is ", ftos(particleeffectnum("TR_NEHAHRASMOKE")), "\n");
707 db_put(d, "TR_NEXUIZPLASMA", "1"); print("effect TR_NEXUIZPLASMA is ", ftos(particleeffectnum("TR_NEXUIZPLASMA")), "\n");
708 db_put(d, "TR_GLOWTRAIL", "1"); print("effect TR_GLOWTRAIL is ", ftos(particleeffectnum("TR_GLOWTRAIL")), "\n");
709 db_put(d, "TR_SEEKER", "1"); print("effect TR_SEEKER is ", ftos(particleeffectnum("TR_SEEKER")), "\n");
710 db_put(d, "SVC_PARTICLE", "1"); print("effect SVC_PARTICLE is ", ftos(particleeffectnum("SVC_PARTICLE")), "\n");
712 fh = fopen("effectinfo.txt", FILE_READ);
713 while((s = fgets(fh)))
716 if(argv(0) == "effect")
718 if(db_get(d, argv(1)) != "1")
720 if(particleeffectnum(argv(1)) >= 0)
721 print("effect ", argv(1), " is ", ftos(particleeffectnum(argv(1))), "\n");
722 db_put(d, argv(1), "1");
726 print("end of effects list\n");
733 case GC_REQUEST_USAGE:
735 print("\nUsage:^3 sv_cmd effectindexdump\n");
736 print(" No arguments required.\n");
742 void GameCommand_extendmatchtime(float request)
746 case GC_REQUEST_COMMAND:
748 changematchtime(autocvar_timelimit_increment* 60, autocvar_timelimit_min*60, autocvar_timelimit_max*60);
753 case GC_REQUEST_USAGE:
755 print("\nUsage:^3 sv_cmd extendmatchtime\n");
756 print(" No arguments required.\n");
757 print("See also: ^2reducematchtime^7\n");
763 void GameCommand_find(float request, float argc)
767 case GC_REQUEST_COMMAND:
771 for(client = world; (client = find(client, classname, argv(1))); )
772 print(etos(client), "\n");
778 print("Incorrect parameters for ^2find^7\n");
779 case GC_REQUEST_USAGE:
781 print("\nUsage:^3 sv_cmd find classname\n");
782 print(" Where 'classname' is the classname to search for.\n");
788 void GameCommand_gametype(float request, float argc)
792 case GC_REQUEST_COMMAND:
795 float t = MapInfo_Type_FromString(s), tsave = MapInfo_CurrentGametype();
799 MapInfo_SwitchGameType(t);
800 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
801 if(MapInfo_count > 0)
802 bprint("Game type successfully switched to ", s, "\n");
805 bprint("Cannot use this game type: no map for it found\n");
806 MapInfo_SwitchGameType(tsave);
807 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
811 bprint("Game type switch to ", s, " failed: this type does not exist!\n");
816 print("Incorrect parameters for ^2gametype^7\n");
817 case GC_REQUEST_USAGE:
819 print("\nUsage:^3 sv_cmd gametype mode\n");
820 print(" Where 'mode' is the gametype mode to switch to.\n");
821 print("See also: ^2gotomap^7\n");
827 void GameCommand_gettaginfo(float request, float argc) // UNTESTED // todo: finish usage description for it (but, must first learn this shit)
831 case GC_REQUEST_COMMAND:
839 tmp_entity = spawn();
841 setmodel(tmp_entity, (nextent(world)).weaponentity.model);
844 precache_model(argv(1));
845 setmodel(tmp_entity, argv(1));
847 tmp_entity.frame = stof(argv(2));
848 if(substring(argv(3), 0, 1) == "#")
849 i = stof(substring(argv(3), 1, -1));
851 i = gettagindex(tmp_entity, argv(3));
854 v = gettaginfo(tmp_entity, i);
855 print("model ", tmp_entity.model, " frame ", ftos(tmp_entity.frame), " tag ", gettaginfo_name);
856 print(" index ", ftos(i), " parent ", ftos(gettaginfo_parent), "\n");
857 print(" vector = ", ftos(v_x), " ", ftos(v_y), " ", ftos(v_z), "\n");
858 print(" offset = ", ftos(gettaginfo_offset_x), " ", ftos(gettaginfo_offset_y), " ", ftos(gettaginfo_offset_z), "\n");
859 print(" forward = ", ftos(gettaginfo_forward_x), " ", ftos(gettaginfo_forward_y), " ", ftos(gettaginfo_forward_z), "\n");
860 print(" right = ", ftos(gettaginfo_right_x), " ", ftos(gettaginfo_right_y), " ", ftos(gettaginfo_right_z), "\n");
861 print(" up = ", ftos(gettaginfo_up_x), " ", ftos(gettaginfo_up_y), " ", ftos(gettaginfo_up_z), "\n");
865 localcmd(strcat(argv(4), vtos(v), argv(5), "\n"));
869 print("bone not found\n");
877 print("Incorrect parameters for ^2gettaginfo^7\n");
878 case GC_REQUEST_USAGE:
880 print("\nUsage:^3 sv_cmd gettaginfo\n");
881 print(" FIXME: Arguments currently unknown\n");
882 print("See also: ^2bbox^7\n");
888 void GameCommand_gotomap(float request, float argc)
892 case GC_REQUEST_COMMAND:
896 print(GotoMap(argv(1)), "\n");
902 print("Incorrect parameters for ^2gotomap^7\n");
903 case GC_REQUEST_USAGE:
905 print("\nUsage:^3 sv_cmd gotomap map\n");
906 print(" Where 'map' is the *.bsp file to change to.\n");
907 print("See also: ^2gametype^7\n");
913 void GameCommand_ladder(float request)
917 case GC_REQUEST_COMMAND:
924 case GC_REQUEST_USAGE:
926 print("\nUsage:^3 sv_cmd ladder\n");
927 print(" No arguments required.\n");
933 void GameCommand_lockteams(float request)
937 case GC_REQUEST_COMMAND:
942 bprint("^1The teams are now locked.\n");
945 bprint("That command can only be used in a team-based gamemode.\n");
950 case GC_REQUEST_USAGE:
952 print("\nUsage:^3 sv_cmd lockteams\n");
953 print(" No arguments required.\n");
954 print("See also: ^2unlockteams^7\n");
960 void GameCommand_make_mapinfo(float request) // UNTESTED
964 case GC_REQUEST_COMMAND:
968 tmp_entity = spawn();
969 tmp_entity.classname = "make_mapinfo";
970 tmp_entity.think = make_mapinfo_Think;
971 tmp_entity.nextthink = time; // this sucks... todo: re-write this -- Use initializeentity later
977 case GC_REQUEST_USAGE:
979 print("\nUsage:^3 sv_cmd make_mapinfo\n");
980 print(" No arguments required.\n");
986 void GameCommand_modelbug(float request) // UNTESTED // is this even needed anymore?
990 case GC_REQUEST_COMMAND:
997 case GC_REQUEST_USAGE:
999 print("\nUsage:^3 sv_cmd modelbug\n");
1000 print(" No arguments required.\n");
1006 void GameCommand_moveplayer(float request, float argc)
1010 case GC_REQUEST_COMMAND:
1014 string targets = strreplace(",", " ", argv(1));
1015 string original_targets = strreplace(" ", ", ", targets);
1016 string destination = argv(2);
1017 string notify = argv(3);
1019 string successful, t;
1021 // lets see if the target(s) even actually exist.
1022 if((targets) && (destination))
1026 t = car(targets); targets = cdr(targets);
1028 // Check to see if the player is a valid target
1029 if((GetFilteredNumber(t) < 1) || (GetFilteredNumber(t) > maxclients)) // player_id is out of range
1031 print("Player ", ftos(GetFilteredNumber(t)), " doesn't exist (out of range)", (targets ? ", skipping to next player.\n" : ".\n"));
1034 client = edict_num(GetFilteredNumber(t));
1035 if not(client.flags & FL_CLIENT) // player entity is not a client
1037 print("Player ", ftos(GetFilteredNumber(t)), " doesn't exist (not a client)", (targets ? ", skipping to next player.\n" : ".\n"));
1041 // Where are we putting this player?
1042 if(destination == "spec" || destination == "spectator")
1044 if(client.classname != "spectator" && client.classname != "observer")
1047 PutObserverInServer();
1049 successful = strcat(successful, (successful ? ", " : ""), client.netname);
1053 print("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") is already spectating.\n");
1059 if(client.classname != "spectator" && client.classname != "observer")
1065 float save = client.team_forced;
1066 client.team_forced = 0;
1068 // find the team to move the player to
1069 team_color = ColourToNumber(destination);
1070 if(team_color == client.team) // already on the destination team
1072 // keep the forcing undone
1073 print("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") is already on the ", ColoredTeamName(client.team), (targets ? ", skipping to next player.\n" : ".\n"));
1076 else if(team_color == 0) // auto team
1078 team_color = NumberToTeamNumber(FindSmallestTeam(client, FALSE));
1082 CheckAllowedTeams(client);
1084 client.team_forced = save;
1086 // Check to see if the destination team is even available
1089 case COLOR_TEAM1: if(c1 == -1) { print("Sorry, can't move player to red team if it doesn't exist.\n"); return; } break;
1090 case COLOR_TEAM2: if(c2 == -1) { print("Sorry, can't move player to blue team if it doesn't exist.\n"); return; } break;
1091 case COLOR_TEAM3: if(c3 == -1) { print("Sorry, can't move player to yellow team if it doesn't exist.\n"); return; } break;
1092 case COLOR_TEAM4: if(c4 == -1) { print("Sorry, can't move player to pink team if it doesn't exist.\n"); return; } break;
1094 default: print("Sorry, can't move player here if team ", destination, " doesn't exist.\n"); return;
1097 // If so, lets continue and finally move the player
1098 client.team_forced = 0;
1099 MoveToTeam(client, team_color, 6, stof(notify));
1100 successful = strcat(successful, (successful ? ", " : ""), client.netname);
1101 print("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") has been moved to the ", ColoredTeamName(team_color), ".\n");
1106 print("Can't change teams when currently not playing a team game.\n");
1112 print("Can't change teams if the player isn't in the game.\n"); // well technically we could, but should we allow that? :P
1119 print("Successfully moved players ", successful, " to destination ", destination, ".\n");
1121 print("No players given (", original_targets, ") are able to move.\n");
1123 return; // still correct parameters so return to avoid usage print
1128 print("Incorrect parameters for ^2moveplayer^7\n");
1129 case GC_REQUEST_USAGE:
1131 print("\nUsage:^3 sv_cmd moveplayer clientnumbers destination [notify]\n");
1132 print(" 'clientnumbers' is a list (separated by commas) of player entity ID's\n");
1133 print(" 'destination' is what to send the player to, be it team or spectating\n");
1134 print(" Full list of destinations here: \"spec, spectator, red, blue, yellow, pink, auto.\"\n");
1135 print(" 'notify' is whether or not to send messages notifying of the move. Detail below.\n");
1136 print(" 0 (00) automove centerprint, admin message; 1 (01) automove centerprint, no admin message\n");
1137 print(" 2 (10) no centerprint, admin message; 3 (11) no centerprint, no admin message\n");
1138 print("Examples: moveplayer 1,3,5 red 3\n");
1139 print(" moveplayer 2 spec \n");
1140 print("See also: ^2allspec^7\n");
1146 void GameCommand_nospectators(float request)
1150 case GC_REQUEST_COMMAND:
1152 blockSpectators = 1;
1154 FOR_EACH_CLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
1156 if(plr.classname == "spectator" || plr.classname == "observer")
1158 plr.spectatortime = time;
1159 sprint(plr, strcat("^7You have to become a player within the next ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
1162 bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n"));
1167 case GC_REQUEST_USAGE:
1169 print("\nUsage:^3 sv_cmd nospectators\n");
1170 print(" No arguments required.\n");
1176 void GameCommand_onslaught_updatelinks(float request) // UNTESTED // should this be here? Perhaps some mutatorhook call instead....
1180 case GC_REQUEST_COMMAND:
1182 onslaught_updatelinks();
1183 print("ONS links updated\n");
1188 case GC_REQUEST_USAGE:
1190 print("\nUsage:^3 sv_cmd onslaught_updatelinks\n");
1191 print(" No arguments required.\n");
1197 void GameCommand_playerdemo(float request, float argc) // UNTESTED // TODO: change the if statements for sub arguments to switches
1201 case GC_REQUEST_COMMAND:
1207 if(argv(1) == "read")
1209 // TODO: Create a general command for looking this up, save a lot of space everywhere in this file
1210 entno = stof(argv(2));
1211 if((entno < 1) | (entno > maxclients)) {
1212 print("Player ", argv(2), " doesn't exist\n");
1215 client = edict_num(entno);
1216 if(clienttype(client) != CLIENTTYPE_BOT) {
1217 print("Player ", client.netname, " is not a bot\n");
1221 playerdemo_open_read(argv(3));
1224 else if(argv(1) == "write")
1226 entno = stof(argv(2));
1227 if((entno < 1) | (entno > maxclients)) {
1228 print("Player ", argv(2), " doesn't exist\n");
1231 client = edict_num(entno);
1233 playerdemo_open_write(argv(3));
1236 else if(argv(1) == "auto_read_and_write")
1240 cvar_set("bot_number", ftos(n));
1241 localcmd("wait; wait; wait\n");
1242 for(i = 0; i < n; ++i)
1243 localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", s, ftos(i+1), "\n");
1244 localcmd("sv_cmd playerdemo write 1 ", ftos(n+1), "\n");
1247 else if(argv(1) == "auto_read")
1251 cvar_set("bot_number", ftos(n));
1252 localcmd("wait; wait; wait\n");
1253 for(i = 0; i < n; ++i)
1254 localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", s, ftos(i+1), "\n");
1261 print("Incorrect parameters for ^2radarmap^7\n");
1262 case GC_REQUEST_USAGE:
1264 print("\nUsage:^3 sv_cmd \n");
1265 print(" FIXME: Arguments currently unknown\n");
1271 void GameCommand_printstats(float request)
1275 case GC_REQUEST_COMMAND:
1278 print("stats dumped.\n");
1283 case GC_REQUEST_USAGE:
1285 print("\nUsage:^3 sv_cmd printstats\n");
1286 print(" No arguments required.\n");
1292 void GameCommand_radarmap(float request, float argc)
1296 case GC_REQUEST_COMMAND:
1298 if(RadarMap_Make(argc))
1303 print("Incorrect parameters for ^2radarmap^7\n");
1304 case GC_REQUEST_USAGE:
1306 print("\nUsage:^3 sv_cmd radarmap [--force] [--loop] [--quit] [--block | --trace | --sample | --lineblock] [--sharpen N] [--res W H] [--qual Q]\n");
1307 print(" The quality factor Q is roughly proportional to the time taken.\n");
1308 print(" trace supports no quality factor; its result should look like --block with infinite quality factor.\n");
1314 void GameCommand_rankings(float request) // this is OLD.... jeez.
1318 case GC_REQUEST_COMMAND:
1320 strunzone(rankings_reply);
1321 rankings_reply = strzone(getrankings());
1322 print(rankings_reply);
1327 case GC_REQUEST_USAGE:
1329 print("\nUsage:^3 sv_cmd rankings\n");
1330 print(" No arguments required.\n");
1336 void GameCommand_records(float request)
1340 case GC_REQUEST_COMMAND:
1344 for (i = 0; i < 10; ++i)
1345 print(records_reply[i]);
1351 case GC_REQUEST_USAGE:
1353 print("\nUsage:^3 sv_cmd records\n");
1354 print(" No arguments required.\n");
1360 void GameCommand_reducematchtime(float request)
1364 case GC_REQUEST_COMMAND:
1366 changematchtime(autocvar_timelimit_decrement*-60, autocvar_timelimit_min*60, autocvar_timelimit_max*60);
1371 case GC_REQUEST_USAGE:
1373 print("\nUsage:^3 sv_cmd reducematchtime\n");
1374 print(" No arguments required.\n");
1375 print("See also: ^2extendmatchtime^7\n");
1381 void GameCommand_setbots(float request, float argc)
1385 case GC_REQUEST_COMMAND:
1387 if(argc >= 3 && argv(1) == "setbots")
1389 cvar_settemp("minplayers", "0");
1390 cvar_settemp("bot_number", argv(2));
1397 case GC_REQUEST_USAGE:
1399 print("\nUsage:^3 sv_cmd setbots botnumber\n");
1400 print(" Where 'botnumber' is the amount of bots to set bot_number cvar to.\n");
1401 print("See also: ^2bot_cmd^7\n");
1407 void GameCommand_stuffto(float request, float argc)
1409 // This... is a fairly dangerous and powerful command... - It allows any arguments to be sent to a client via rcon.
1410 // Because of this, it is disabled by default and must be enabled by the server owner when doing compilation. That way,
1411 // we can be certain they understand the risks of it... So to enable, compile server with -DSTUFFTO_ENABLED argument.
1413 #ifdef STUFFTO_ENABLED
1416 case GC_REQUEST_COMMAND:
1423 entno = stof(argv(1));
1425 if(entno <= maxclients)
1426 client = edict_num(entno);
1427 if(client.flags & FL_CLIENT)
1429 stuffcmd(client, strcat("\n", argv(2), "\n"));
1430 print(strcat("Command: \"", argv(2), "\" sent to ", client.netname, " (", argv(1) ,").\n"));
1433 print(strcat("Client (", argv(1) ,") not found.\n"));
1440 print("Incorrect parameters for ^2stuffto^7\n");
1441 case GC_REQUEST_USAGE:
1443 print("\nUsage:^3 sv_cmd stuffto clientnumber command\n");
1444 print(" FIXME: Arguments currently unknown\n");
1451 print("stuffto command is not enabled on this server.\n");
1457 void GameCommand_teamstatus(float request)
1461 case GC_REQUEST_COMMAND:
1463 Score_NicePrint(world);
1468 case GC_REQUEST_USAGE:
1470 print("\nUsage:^3 sv_cmd teamstatus\n");
1471 print(" No arguments required.\n");
1477 void GameCommand_time(float request)
1481 case GC_REQUEST_COMMAND:
1483 print("time = ", ftos(time), "\n");
1484 print("frame start = ", ftos(gettime(GETTIME_FRAMESTART)), "\n");
1485 print("realtime = ", ftos(gettime(GETTIME_REALTIME)), "\n");
1486 print("hires = ", ftos(gettime(GETTIME_HIRES)), "\n");
1487 print("uptime = ", ftos(gettime(GETTIME_UPTIME)), "\n");
1488 print("localtime = ", strftime(TRUE, "%a %b %e %H:%M:%S %Z %Y"), "\n"); // FIXME: Why is strftime broken? is engine problem, I think.
1489 print("gmtime = ", strftime(FALSE, "%a %b %e %H:%M:%S %Z %Y"), "\n");
1494 case GC_REQUEST_USAGE:
1496 print("\nUsage:^3 sv_cmd time\n");
1497 print(" No arguments required.\n");
1503 void GameCommand_trace(float request, float argc)
1507 case GC_REQUEST_COMMAND:
1509 // TODO: Clean up all of these variables and merge the code below to use only a few
1511 vector org, delta, start, end, p, q, q0, pos, vv, dv;
1512 float i, f, safe, unsafe, dq, dqf;
1517 print("TEST CASE. If this returns the runaway loop counter error, possibly everything is oaky.\n");
1521 delta = world.maxs - world.mins;
1523 start_x = org_x + random() * delta_x;
1524 start_y = org_y + random() * delta_y;
1525 start_z = org_z + random() * delta_z;
1527 end_x = org_x + random() * delta_x;
1528 end_y = org_y + random() * delta_y;
1529 end_z = org_z + random() * delta_z;
1531 start = stov(vtos(start));
1532 end = stov(vtos(end));
1534 tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world);
1535 if(!trace_startsolid)
1538 tracebox(p, PL_MIN, PL_MAX, p, MOVE_NOMONSTERS, world);
1539 if(trace_startsolid || trace_fraction == 1)
1541 rint(42); // do an engine breakpoint on VM_rint so you can get the trace that errnoeously returns startsolid
1542 tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world);
1543 tracebox(p, PL_MIN, PL_MAX, q, MOVE_NOMONSTERS, world);
1545 if(trace_startsolid)
1547 // how much do we need to back off?
1552 pos = p * (1 - (safe + unsafe) * 0.5) + start * ((safe + unsafe) * 0.5);
1553 tracebox(pos, PL_MIN, PL_MAX, pos, MOVE_NOMONSTERS, world);
1554 if(trace_startsolid)
1556 if((safe + unsafe) * 0.5 == unsafe)
1558 unsafe = (safe + unsafe) * 0.5;
1562 if((safe + unsafe) * 0.5 == safe)
1564 safe = (safe + unsafe) * 0.5;
1568 print("safe distance to back off: ", ftos(safe * vlen(p - start)), "qu\n");
1569 print("unsafe distance to back off: ", ftos(unsafe * vlen(p - start)), "qu\n");
1571 tracebox(p, PL_MIN + '0.1 0.1 0.1', PL_MAX - '0.1 0.1 0.1', p, MOVE_NOMONSTERS, world);
1572 if(trace_startsolid)
1573 print("trace_endpos much in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
1575 print("trace_endpos just in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
1584 q = p + normalize(end - p) * (dq + dqf);
1587 tracebox(p, PL_MIN, PL_MAX, q, MOVE_NOMONSTERS, world);
1588 if(trace_startsolid)
1589 error("THIS ONE cannot happen");
1590 if(trace_fraction > 0)
1591 dq += dqf * trace_fraction;
1597 print("trace_endpos still before solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
1598 print("could go ", ftos(dq), " units further to ", vtos(q), "\n");
1608 tracebox(e.origin + '0 0 32', e.mins, e.maxs, e.origin + '0 0 -1024', MOVE_NORMAL, e);
1610 if(trace_fraction == 1)
1612 print("not above ground, aborting\n");
1616 for(i = 0; i < 100000; ++i)
1621 tracebox(vv, e.mins, e.maxs, vv + dv, MOVE_NORMAL, e);
1622 if(trace_startsolid)
1624 if(trace_fraction == 1)
1627 print("bug 2: ", ftos(dv_x), " ", ftos(dv_y), " ", ftos(dv_z));
1628 print(" (", ftos(asin(dv_z / vlen(dv)) * 180 / M_PI), " degrees)\n");
1632 print("highest possible dist: ", ftos(f), "\n");
1639 if(tracewalk(e, stov(argv(1)), e.mins, e.maxs, stov(argv(2)), MOVE_NORMAL))
1640 print("can walk\n");
1642 print("cannot walk\n");
1651 traceline(vv, dv, MOVE_NORMAL, world);
1652 trailparticles(world, particleeffectnum("TR_NEXUIZPLASMA"), vv, trace_endpos);
1653 trailparticles(world, particleeffectnum("TR_CRYLINKPLASMA"), trace_endpos, dv);
1656 // no default case, just go straight to "invalid arguments"
1661 case GC_REQUEST_USAGE:
1663 print("\nUsage:^3 sv_cmd trace command [arguments]\n");
1664 print(" FIXME: Arguments currently unknown\n");
1670 void GameCommand_unlockteams(float request)
1674 case GC_REQUEST_COMMAND:
1679 bprint("^1The teams are now unlocked.\n");
1682 bprint("That command can only be used in a team-based gamemode.\n");
1687 case GC_REQUEST_USAGE:
1689 print("\nUsage:^3 sv_cmd unlockteams\n");
1690 print(" No arguments required.\n");
1691 print("See also: ^2lockteams^7\n");
1697 void GameCommand_warp(float request, float argc)
1701 case GC_REQUEST_COMMAND:
1703 if(autocvar_g_campaign)
1708 CampaignLevelWarp(stof(argv(1)));
1709 print("Successfully warped to campaign level ", stof(argv(1)), ".\n");
1713 CampaignLevelWarp(-1);
1714 print("Successfully warped to next campaign level.\n");
1718 print("Not in campaign, can't level warp\n");
1723 case GC_REQUEST_USAGE:
1725 print("\nUsage:^3 sv_cmd level\n");
1726 print(" 'level' is the level to change campaign mode to.\n");
1733 void GameCommand_(float request)
1737 case GC_REQUEST_COMMAND:
1744 case GC_REQUEST_USAGE:
1746 sprint(self, "\nUsage:^3 cmd \n");
1747 sprint(self, " No arguments required.\n");
1755 // ===========================
1756 // Macro system for commands
1757 // ===========================
1759 // For now, the list has to be split up due to the suckage called fteqcc which limits macros to only 1024 characters
1760 // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
1761 #define SERVER_COMMANDS_1(request,arguments) \
1762 SERVER_COMMAND("adminmsg", GameCommand_adminmsg(request, arguments), "Send an admin message to a client directly") \
1763 SERVER_COMMAND("allready", GameCommand_allready(request), "Restart the server and reset the players") \
1764 SERVER_COMMAND("allspec", GameCommand_allspec(request, arguments), "Force all players to spectate") \
1765 SERVER_COMMAND("anticheat", GameCommand_anticheat(request, arguments), "Create an anticheat report for a client") \
1766 SERVER_COMMAND("bbox", GameCommand_bbox(request), "Print detailed information about world size") \
1767 SERVER_COMMAND("bot_cmd", GameCommand_bot_cmd(request, arguments), "Control and send commands to bots") \
1768 SERVER_COMMAND("cointoss", GameCommand_cointoss(request, arguments), "Flip a virtual coin and give random result") \
1769 SERVER_COMMAND("cvar_changes", GameCommand_cvar_changes(request), "Prints a list of all changed server cvars") \
1772 #define SERVER_COMMANDS_2(request,arguments) \
1773 SERVER_COMMAND("cvar_purechanges", GameCommand_cvar_purechanges(request), "Prints a list of all changed gameplay cvars") \
1774 SERVER_COMMAND("database", GameCommand_database(request, arguments), "Extra controls of the serverprogs database") \
1775 SERVER_COMMAND("defer_clear", GameCommand_defer_clear(request, arguments), "Clear all queued defer commands for a specific client") \
1776 SERVER_COMMAND("defer_clear_all", GameCommand_defer_clear_all(request), "Clear all queued defer commands for all clients") \
1777 SERVER_COMMAND("delrec", GameCommand_delrec(request, arguments), "Delete race time record for a map") \
1778 SERVER_COMMAND("effectindexdump", GameCommand_effectindexdump(request), "Dump list of effects from code and effectinfo.txt") \
1779 SERVER_COMMAND("extendmatchtime", GameCommand_extendmatchtime(request), "Increase the timelimit value incrementally") \
1782 #define SERVER_COMMANDS_3(request,arguments) \
1783 SERVER_COMMAND("find", GameCommand_find(request, arguments), "Search through entities for matching classname") \
1784 SERVER_COMMAND("gametype", GameCommand_gametype(request, arguments), "Simple command to change the active gametype") \
1785 SERVER_COMMAND("gettaginfo", GameCommand_gettaginfo(request, arguments), "Get specific information about a weapon model") \
1786 SERVER_COMMAND("gotomap", GameCommand_gotomap(request, arguments), "Simple command to switch to another map") \
1787 SERVER_COMMAND("ladder", GameCommand_ladder(request), "Get information about top players if supported") \
1788 SERVER_COMMAND("lockteams", GameCommand_lockteams(request), "Disable the ability for players to switch or enter teams") \
1789 SERVER_COMMAND("make_mapinfo", GameCommand_make_mapinfo(request), "Automatically rebuild mapinfo files") \
1790 SERVER_COMMAND("modelbug", GameCommand_modelbug(request), "TODO foobar") \
1793 #define SERVER_COMMANDS_4(request,arguments) \
1794 SERVER_COMMAND("moveplayer", GameCommand_moveplayer(request, arguments), "Change the team/status of a player") \
1795 SERVER_COMMAND("nospectators", GameCommand_nospectators(request), "Automatically remove spectators from a match") \
1796 SERVER_COMMAND("onslaught_updatelinks", GameCommand_onslaught_updatelinks(request), "Refresh link status for onslaught") \
1797 SERVER_COMMAND("playerdemo", GameCommand_playerdemo(request, arguments), "Control the ability to save demos of players") \
1798 SERVER_COMMAND("printstats", GameCommand_printstats(request), "TODO foobar") \
1799 SERVER_COMMAND("radarmap", GameCommand_radarmap(request, arguments), "Generate a radar image of the map") \
1800 SERVER_COMMAND("rankings", GameCommand_rankings(request), "Print information about rankings") \
1801 SERVER_COMMAND("records", GameCommand_records(request), "List top 10 records for the current map") \
1804 #define SERVER_COMMANDS_5(request,arguments) \
1805 SERVER_COMMAND("reducematchtime", GameCommand_reducematchtime(request), "Decrease the timelimit value incrementally") \
1806 SERVER_COMMAND("setbots", GameCommand_setbots(request, arguments), "Adjust how many bots are in the match") \
1807 SERVER_COMMAND("stuffto", GameCommand_stuffto(request, arguments), "Send a command to be executed on a client") \
1808 SERVER_COMMAND("teamstatus", GameCommand_teamstatus(request), "Show information about player and team scores") \
1809 SERVER_COMMAND("time", GameCommand_time(request), "Print different formats/readouts of time") \
1810 SERVER_COMMAND("trace", GameCommand_trace(request, arguments), "Various debugging tools with tracing") \
1811 SERVER_COMMAND("unlockteams", GameCommand_unlockteams(request), "Enable the ability for players to switch or enter teams") \
1812 SERVER_COMMAND("warp", GameCommand_warp(request, arguments), "Choose different level in campaign") \
1815 void GameCommand_macro_help()
1817 #define SERVER_COMMAND(name,function,description) \
1818 { print(" ^2", name, "^7: ", description, "\n"); }
1820 SERVER_COMMANDS_1(0, 0)
1821 SERVER_COMMANDS_2(0, 0)
1822 SERVER_COMMANDS_3(0, 0)
1823 SERVER_COMMANDS_4(0, 0)
1824 SERVER_COMMANDS_5(0, 0)
1825 #undef SERVER_COMMAND
1830 float GameCommand_macro_command(float argc)
1832 #define SERVER_COMMAND(name,function,description) \
1833 { if(name == strtolower(argv(0))) { function; return TRUE; } }
1835 SERVER_COMMANDS_1(GC_REQUEST_COMMAND, argc)
1836 SERVER_COMMANDS_2(GC_REQUEST_COMMAND, argc)
1837 SERVER_COMMANDS_3(GC_REQUEST_COMMAND, argc)
1838 SERVER_COMMANDS_4(GC_REQUEST_COMMAND, argc)
1839 SERVER_COMMANDS_5(GC_REQUEST_COMMAND, argc)
1840 #undef SERVER_COMMAND
1845 float GameCommand_macro_usage(float argc)
1847 #define SERVER_COMMAND(name,function,description) \
1848 { if(name == strtolower(argv(1))) { function; return TRUE; } }
1850 SERVER_COMMANDS_1(GC_REQUEST_USAGE, argc)
1851 SERVER_COMMANDS_2(GC_REQUEST_USAGE, argc)
1852 SERVER_COMMANDS_3(GC_REQUEST_USAGE, argc)
1853 SERVER_COMMANDS_4(GC_REQUEST_USAGE, argc)
1854 SERVER_COMMANDS_5(GC_REQUEST_USAGE, argc)
1855 #undef SERVER_COMMAND
1861 // =========================================
1862 // Main Function Called By Engine (sv_cmd)
1863 // =========================================
1864 // If this function exists, game code handles gamecommand instead of the engine code.
1866 void GameCommand(string command)
1868 float argc = tokenize_console(command);
1870 if(strtolower(argv(0)) == "help")
1874 print("\nUsage:^3 sv_cmd COMMAND...^7, where possible commands are:\n");
1875 GameCommand_macro_help();
1876 GameCommand_Vote("help", world);
1877 GameCommand_Ban("help");
1878 GameCommand_Generic("help");
1879 print("For help about specific commands, type sv_cmd help COMMAND\n");
1882 else if(GameCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it
1887 else if(GameCommand_Vote(command, world))
1889 return; // handled by server/vote.qc
1891 else if(GameCommand_Ban(command))
1893 return; // handled by server/ipban.qc
1895 else if(GameCommand_Generic(command))
1897 return; // handled by common/gamecommand.qc
1899 else if(GameCommand_macro_command(argc)) // continue as usual and scan for normal commands
1901 return; // handled by one of the above GameCommand_* functions
1904 // nothing above caught the command, must be invalid
1905 print("Invalid command. For a list of supported commands, try sv_cmd help.\n");