1 // =====================================================
2 // Server side game commands code, reworked by Samual
3 // Last updated: November 4th, 2011
4 // =====================================================
6 #define GC_REQUEST_HELP 1
7 #define GC_REQUEST_COMMAND 2
8 #define GC_REQUEST_USAGE 3
10 float RadarMap_Make(float argc);
12 string GotoMap(string m);
14 void race_deleteTime(string map, float pos);
17 // ============================
18 // Misc. Supporting Functions
19 // ============================
21 // used by GameCommand_make_mapinfo()
22 void make_mapinfo_Think()
24 if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
26 print("Done rebuiling mapinfos.\n");
27 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
32 self.think = make_mapinfo_Think;
33 self.nextthink = time;
37 // used by GameCommand_extendmatchtime() and GameCommand_reducematchtime()
38 void changematchtime(float delta, float mi, float ma)
46 if(autocvar_timelimit < 0)
50 mi = 10; // at least ten sec in the future
51 cur = time - game_starttime;
53 mi += cur; // from current time!
55 lim = autocvar_timelimit * 60;
60 return; // cannot increase any further
62 new = min(ma, lim + delta);
63 else // already above maximum: FAIL
68 if(lim == 0) // infinite: try reducing to max, if we are allowed to
70 else if(lim > mi) // above minimum: decrease
71 new = max(mi, lim + delta);
72 else // already below minimum: FAIL
76 cvar_set("timelimit", ftos(new / 60));
79 // used by GameCommand_modelbug() // TODO: is this even needed?
80 float g_clientmodel_genericsendentity (entity to, float sf);
81 void modelbug_make_svqc();
82 void modelbug_make_csqc()
84 Net_LinkEntity(self, TRUE, 0, g_clientmodel_genericsendentity);
85 self.think = modelbug_make_svqc;
86 self.nextthink = time + 1;
87 setorigin(self, self.origin - '0 0 8');
89 void modelbug_make_svqc()
91 self.SendEntity = func_null;
92 self.think = modelbug_make_csqc;
93 self.nextthink = time + 1;
94 setorigin(self, self.origin + '0 0 8');
100 setorigin(e, nextent(world).origin);
101 precache_model("models_portal.md3");
102 setmodel(e, "models/portal.md3");
103 e.think = modelbug_make_svqc;
104 e.nextthink = time + 1;
108 // =======================
109 // Command Sub-Functions
110 // =======================
112 void GameCommand_adminmsg(float request, float argc)
115 float entno = stof(argv(1));
121 case GC_REQUEST_HELP:
122 print(" ^2adminmsg^7: Send an admin message to a client directly\n");
125 case GC_REQUEST_COMMAND:
126 if(argc >= 3 && argc <= 4) {
127 if((entno < 0) | (entno > maxclients)) {
128 print("Player ", argv(1), " doesn't exist\n");
132 for(i = (entno ? entno : 1); i <= (entno ? entno : maxclients); ++i)
134 client = edict_num(i);
135 if(client.flags & FL_CLIENT)
139 // make the string console safe
141 s = strreplace("\n", "", s);
142 s = strreplace("\\", "\\\\", s);
143 s = strreplace("$", "$$", s);
144 s = strreplace("\"", "\\\"", s);
145 stuffcmd(client, sprintf("\ninfobar %f \"%s\"\n", stof(argv(3)), s));
149 centerprint(client, strcat("^3", admin_name(), ":\n\n^7", argv(2)));
150 sprint(client, strcat("\{1}\{13}^3", admin_name(), "^7: ", argv(2), "\n"));
152 dprint("Message sent to ", client.netname, "\n");
156 if(!n) { print(strcat("Client (", argv(1) ,") not found.\n")); }
161 print("Incorrect parameters for ^2adminmsg^7\n");
162 case GC_REQUEST_USAGE:
163 print("\nUsage:^3 sv_cmd adminmsg clientnumber \"message\" [infobartime]\n");
164 print(" If infobartime is provided, the message will be sent to infobar.\n");
165 print(" Otherwise, it will just be sent as a centerprint message.\n");
166 print("Examples: adminmsg 4 \"this infomessage will last for ten seconds\" 10\n");
167 print(" adminmsg 2 \"this message will be a centerprint\"\n");
172 void GameCommand_allready(float request)
176 case GC_REQUEST_HELP:
177 print(" ^2allready^7: Restart the server and reset the players\n");
180 case GC_REQUEST_COMMAND:
185 case GC_REQUEST_USAGE:
186 print("\nUsage:^3 sv_cmd allready\n");
187 print(" No arguments required.\n");
192 void GameCommand_allspec(float request, float argc)
199 case GC_REQUEST_HELP:
200 print(" ^2allspec^7: Force all players to spectate\n");
203 case GC_REQUEST_COMMAND:
204 FOR_EACH_PLAYER(client)
207 PutObserverInServer();
210 if(i) { bprint(strcat("Successfully forced all (", ftos(i), ") players to spectate", (argv(1) ? strcat(" for reason: '", argv(1), "'") : ""), ".\n")); }
211 else { print("No players found to spectate.\n"); }
215 case GC_REQUEST_USAGE:
216 print("\nUsage:^3 sv_cmd allspec [reason]\n");
217 print(" Where 'reason' is an optional argument for explanation of allspec command.\n");
218 print("See also: ^2moveplayer^7\n");
223 void GameCommand_anticheat(float request, float argc) // FIXME: player entity is never found
226 float entno = stof(argv(1));
230 case GC_REQUEST_HELP:
231 print(" ^2anticheat^7: Create an anticheat report for a client\n");
234 case GC_REQUEST_COMMAND:
235 if((entno < 1) | (entno > maxclients)) {
236 print("Player ", argv(1), " doesn't exist\n");
239 client = edict_num(entno);
240 if(clienttype(client) != CLIENTTYPE_REAL && clienttype(client) != CLIENTTYPE_BOT) {
241 print("Player ", client.netname, " is not active\n");
249 print("Incorrect parameters for ^2anticheat^7\n");
250 case GC_REQUEST_USAGE:
251 print("\nUsage:^3 sv_cmd anticheat clientnumber\n");
252 print(" where 'clientnumber' is player entity number.\n");
257 void GameCommand_bbox(float request)
261 case GC_REQUEST_HELP:
262 print(" ^2bbox^7: Print detailed information about world size\n");
265 case GC_REQUEST_COMMAND:
266 print("Original size: ", ftos(world.absmin_x), " ", ftos(world.absmin_y), " ", ftos(world.absmin_z));
267 print(" ", ftos(world.absmax_x), " ", ftos(world.absmax_y), " ", ftos(world.absmax_z), "\n");
268 print("Currently set size: ", ftos(world.mins_x), " ", ftos(world.mins_y), " ", ftos(world.mins_z));
269 print(" ", ftos(world.maxs_x), " ", ftos(world.maxs_y), " ", ftos(world.maxs_z), "\n");
270 print("Solid bounding box size:");
272 tracebox('1 0 0' * world.absmin_x,
273 '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
274 '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
275 '1 0 0' * world.absmax_x,
279 print(" ", ftos(world.absmin_x));
281 print(" ", ftos(trace_endpos_x));
283 tracebox('0 1 0' * world.absmin_y,
284 '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
285 '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
286 '0 1 0' * world.absmax_y,
290 print(" ", ftos(world.absmin_y));
292 print(" ", ftos(trace_endpos_y));
294 tracebox('0 0 1' * world.absmin_z,
295 '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
296 '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
297 '0 0 1' * world.absmax_z,
301 print(" ", ftos(world.absmin_z));
303 print(" ", ftos(trace_endpos_z));
305 tracebox('1 0 0' * world.absmax_x,
306 '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
307 '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
308 '1 0 0' * world.absmin_x,
312 print(" ", ftos(world.absmax_x));
314 print(" ", ftos(trace_endpos_x));
316 tracebox('0 1 0' * world.absmax_y,
317 '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
318 '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
319 '0 1 0' * world.absmin_y,
323 print(" ", ftos(world.absmax_y));
325 print(" ", ftos(trace_endpos_y));
327 tracebox('0 0 1' * world.absmax_z,
328 '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
329 '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
330 '0 0 1' * world.absmin_z,
334 print(" ", ftos(world.absmax_z));
336 print(" ", ftos(trace_endpos_z));
342 case GC_REQUEST_USAGE:
343 print("\nUsage:^3 sv_cmd bbox\n");
344 print(" No arguments required.\n");
345 print("See also: ^2gettaginfo^7\n");
350 void GameCommand_bot_cmd(float request, float argc) // what a mess... old old code.
356 case GC_REQUEST_HELP:
357 print(" ^2bot_cmd^7: Control and send commands to bots\n");
360 case GC_REQUEST_COMMAND:
361 if(argv(1) == "reset")
366 else if(argv(1) == "load" && argc == 3)
370 fh = fopen(argv(2), FILE_READ);
373 print("cannot open the file\n");
378 while((s = fgets(fh)))
380 argc = tokenize_console(s);
382 if(argc >= 3 && argv(0) == "sv_cmd" && argv(1) == "bot_cmd")
384 if(argv(2) == "reset")
388 else if(argv(2) == "setbots")
390 cvar_settemp("minplayers", "0");
391 cvar_settemp("bot_number", argv(3));
393 print("Sorry, could not set requested bot count\n");
397 // let's start at token 2 so we can skip sv_cmd bot_cmd
398 bot = find_bot_by_number(stof(argv(2)));
400 bot = find_bot_by_name(argv(2));
402 bot_queuecommand(bot, strcat(argv(3), " ", argv(4)));
406 localcmd(strcat(s, "\n"));
410 print(ftos(i), " commands read\n");
414 else if(argv(1) == "help")
417 bot_cmdhelp(argv(2));
422 else if(argc >= 3) // this comes last
424 bot = find_bot_by_number(stof(argv(1)));
426 bot = find_bot_by_name(argv(1));
429 print(strcat("Command '", strcat(argv(2), " ", argv(3)), "' sent to bot ", bot.netname, "\n"));
430 bot_queuecommand(bot, strcat(argv(2), " ", argv(3)));
434 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
438 print("Incorrect parameters for ^2bot_cmd^7\n");
439 case GC_REQUEST_USAGE:
440 print("\nUsage:^3 sv_cmd bot_cmd client command [argument]\n");
441 print(" 'client' can be either the name or entity id of the bot\n");
442 print(" For full list of commands, see bot_cmd help [command].\n");
443 print("Examples: bot_cmd <id> cc \"say something\"\n");
444 print(" bot_cmd <id> presskey jump\n");
449 void GameCommand_cointoss(float request, float argc)
452 string result1 = (argv(2) ? strcat("^7", argv(1), "^3!\n") : "^1HEADS^3!\n");
453 string result2 = (argv(2) ? strcat("^7", argv(2), "^3!\n") : "^4TAILS^3!\n");
454 string choice = ((random() > 0.5) ? result1 : result2);
458 case GC_REQUEST_HELP:
459 print(" ^2cointoss^7: Flip a virtual coin and give random result\n");
462 case GC_REQUEST_COMMAND:
463 FOR_EACH_CLIENT(client)
464 centerprint(client, strcat("^3Throwing coin... Result: ", choice));
465 bprint(strcat("^3Throwing coin... Result: ", choice));
469 case GC_REQUEST_USAGE:
470 print("\nUsage:^3 sv_cmd cointoss [result1 result2]\n");
471 print(" Where 'result1' and 'result2' are user created options.\n");
476 void GameCommand_cvar_changes(float request)
480 case GC_REQUEST_HELP:
481 print(" ^2cvar_changes^7: Prints a list of all changed server cvars\n");
484 case GC_REQUEST_COMMAND:
489 case GC_REQUEST_USAGE:
490 print("\nUsage:^3 sv_cmd cvar_changes\n");
491 print(" No arguments required.\n");
492 print("See also: ^2cvar_purechanges^7\n");
497 void GameCommand_cvar_purechanges(float request)
501 case GC_REQUEST_HELP:
502 print(" ^2cvar_purechanges^7: Prints a list of all changed gameplay cvars\n");
505 case GC_REQUEST_COMMAND:
506 print(cvar_purechanges);
510 case GC_REQUEST_USAGE:
511 print("\nUsage:^3 sv_cmd cvar_purechanges\n");
512 print(" No arguments required.\n");
513 print("See also: ^2cvar_changes^7\n");
518 void GameCommand_database(float request, float argc)
522 case GC_REQUEST_HELP:
523 print(" ^2database^7: Extra controls of the serverprogs database\n");
526 case GC_REQUEST_COMMAND:
529 if(argv(1) == "save")
531 db_save(ServerProgsDB, argv(2));
532 print(strcat("Copied serverprogs database to '", argv(2), "' in the data directory.\n"));
535 else if(argv(1) == "dump")
537 db_dump(ServerProgsDB, argv(2));
538 print("DB dumped.\n"); // wtf does this do?
541 else if(argv(1) == "load")
543 db_close(ServerProgsDB);
544 ServerProgsDB = db_load(argv(2));
545 print(strcat("Loaded '", argv(2), "' as new serverprogs database.\n"));
551 print("Incorrect parameters for ^2database^7\n");
552 case GC_REQUEST_USAGE:
553 print("\nUsage:^3 sv_cmd database action filename\n");
554 print(" Where 'action' is the command to complete,\n");
555 print(" and 'filename' is what it acts upon.\n");
556 print(" Full list of commands here: \"save, dump, load.\"\n");
561 void GameCommand_defer_clear(float request, float argc)
564 float entno = stof(argv(1));
568 case GC_REQUEST_HELP:
569 print(" ^2defer_clear^7: Clear all queued defer commands for client\n");
572 case GC_REQUEST_COMMAND:
575 // player_id is out of range
576 if((entno < 1) | (entno > maxclients)) {
577 print("Player ", argv(1), " doesn't exist\n");
580 client = edict_num(entno);
581 if not(client.flags & FL_CLIENT) {
582 print("Player ", argv(1), " doesn't exist\n");
585 if(clienttype(client) == CLIENTTYPE_BOT) {
586 print("Player ", argv(1), " (", client.netname, ") is a bot\n");
589 stuffcmd(client, "defer clear\n");
590 print("defer clear stuffed to ", argv(1), " (", client.netname, ")\n");
595 print("Incorrect parameters for ^2defer_clear^7\n");
596 case GC_REQUEST_USAGE:
597 print("\nUsage:^3 sv_cmd defer_clear clientnumber\n");
598 print(" where 'clientnumber' is player entity number.\n");
599 print("See also: ^2defer_clear_all^7\n");
604 void GameCommand_defer_clear_all(float request)
612 case GC_REQUEST_HELP:
613 print(" ^2defer_clear_all^7: Clear all queued defer commands for all clients\n");
616 case GC_REQUEST_COMMAND:
617 FOR_EACH_CLIENT(client)
619 argc = tokenize_console(strcat("defer_clear ", ftos(num_for_edict(client))));
620 GameCommand_defer_clear(GC_REQUEST_COMMAND, argc);
623 if(i) { bprint(strcat("Successfully stuffed defer clear to all clients (", ftos(i), ")\n")); } // should a message be added if no players were found?
627 case GC_REQUEST_USAGE:
628 print("\nUsage:^3 sv_cmd defer_clear_all\n");
629 print(" No arguments required.\n");
630 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_HELP:
640 print(" ^2delrec^7: Delete race time record for a map\n");
643 case GC_REQUEST_COMMAND:
647 race_deleteTime(argv(2), stof(argv(1)));
649 race_deleteTime(GetMapname(), stof(argv(1)));
654 print("Incorrect parameters for ^2delrec^7\n");
655 case GC_REQUEST_USAGE:
656 print("\nUsage:^3 sv_cmd delrec ranking [map]\n");
657 print(" 'ranking' is which ranking level to clear up to, \n");
658 print(" it will clear all records up to nth place.\n");
659 print(" if 'map' is not provided it will use current map.\n");
664 void GameCommand_effectindexdump(float request)
671 case GC_REQUEST_HELP:
672 print(" ^2effectindexdump^7: Dump list of effects from code and effectinfo.txt\n");
675 case GC_REQUEST_COMMAND:
677 print("begin of effects list\n");
678 db_put(d, "TE_GUNSHOT", "1"); print("effect TE_GUNSHOT is ", ftos(particleeffectnum("TE_GUNSHOT")), "\n");
679 db_put(d, "TE_GUNSHOTQUAD", "1"); print("effect TE_GUNSHOTQUAD is ", ftos(particleeffectnum("TE_GUNSHOTQUAD")), "\n");
680 db_put(d, "TE_SPIKE", "1"); print("effect TE_SPIKE is ", ftos(particleeffectnum("TE_SPIKE")), "\n");
681 db_put(d, "TE_SPIKEQUAD", "1"); print("effect TE_SPIKEQUAD is ", ftos(particleeffectnum("TE_SPIKEQUAD")), "\n");
682 db_put(d, "TE_SUPERSPIKE", "1"); print("effect TE_SUPERSPIKE is ", ftos(particleeffectnum("TE_SUPERSPIKE")), "\n");
683 db_put(d, "TE_SUPERSPIKEQUAD", "1"); print("effect TE_SUPERSPIKEQUAD is ", ftos(particleeffectnum("TE_SUPERSPIKEQUAD")), "\n");
684 db_put(d, "TE_WIZSPIKE", "1"); print("effect TE_WIZSPIKE is ", ftos(particleeffectnum("TE_WIZSPIKE")), "\n");
685 db_put(d, "TE_KNIGHTSPIKE", "1"); print("effect TE_KNIGHTSPIKE is ", ftos(particleeffectnum("TE_KNIGHTSPIKE")), "\n");
686 db_put(d, "TE_EXPLOSION", "1"); print("effect TE_EXPLOSION is ", ftos(particleeffectnum("TE_EXPLOSION")), "\n");
687 db_put(d, "TE_EXPLOSIONQUAD", "1"); print("effect TE_EXPLOSIONQUAD is ", ftos(particleeffectnum("TE_EXPLOSIONQUAD")), "\n");
688 db_put(d, "TE_TAREXPLOSION", "1"); print("effect TE_TAREXPLOSION is ", ftos(particleeffectnum("TE_TAREXPLOSION")), "\n");
689 db_put(d, "TE_TELEPORT", "1"); print("effect TE_TELEPORT is ", ftos(particleeffectnum("TE_TELEPORT")), "\n");
690 db_put(d, "TE_LAVASPLASH", "1"); print("effect TE_LAVASPLASH is ", ftos(particleeffectnum("TE_LAVASPLASH")), "\n");
691 db_put(d, "TE_SMALLFLASH", "1"); print("effect TE_SMALLFLASH is ", ftos(particleeffectnum("TE_SMALLFLASH")), "\n");
692 db_put(d, "TE_FLAMEJET", "1"); print("effect TE_FLAMEJET is ", ftos(particleeffectnum("TE_FLAMEJET")), "\n");
693 db_put(d, "EF_FLAME", "1"); print("effect EF_FLAME is ", ftos(particleeffectnum("EF_FLAME")), "\n");
694 db_put(d, "TE_BLOOD", "1"); print("effect TE_BLOOD is ", ftos(particleeffectnum("TE_BLOOD")), "\n");
695 db_put(d, "TE_SPARK", "1"); print("effect TE_SPARK is ", ftos(particleeffectnum("TE_SPARK")), "\n");
696 db_put(d, "TE_PLASMABURN", "1"); print("effect TE_PLASMABURN is ", ftos(particleeffectnum("TE_PLASMABURN")), "\n");
697 db_put(d, "TE_TEI_G3", "1"); print("effect TE_TEI_G3 is ", ftos(particleeffectnum("TE_TEI_G3")), "\n");
698 db_put(d, "TE_TEI_SMOKE", "1"); print("effect TE_TEI_SMOKE is ", ftos(particleeffectnum("TE_TEI_SMOKE")), "\n");
699 db_put(d, "TE_TEI_BIGEXPLOSION", "1"); print("effect TE_TEI_BIGEXPLOSION is ", ftos(particleeffectnum("TE_TEI_BIGEXPLOSION")), "\n");
700 db_put(d, "TE_TEI_PLASMAHIT", "1"); print("effect TE_TEI_PLASMAHIT is ", ftos(particleeffectnum("TE_TEI_PLASMAHIT")), "\n");
701 db_put(d, "EF_STARDUST", "1"); print("effect EF_STARDUST is ", ftos(particleeffectnum("EF_STARDUST")), "\n");
702 db_put(d, "TR_ROCKET", "1"); print("effect TR_ROCKET is ", ftos(particleeffectnum("TR_ROCKET")), "\n");
703 db_put(d, "TR_GRENADE", "1"); print("effect TR_GRENADE is ", ftos(particleeffectnum("TR_GRENADE")), "\n");
704 db_put(d, "TR_BLOOD", "1"); print("effect TR_BLOOD is ", ftos(particleeffectnum("TR_BLOOD")), "\n");
705 db_put(d, "TR_WIZSPIKE", "1"); print("effect TR_WIZSPIKE is ", ftos(particleeffectnum("TR_WIZSPIKE")), "\n");
706 db_put(d, "TR_SLIGHTBLOOD", "1"); print("effect TR_SLIGHTBLOOD is ", ftos(particleeffectnum("TR_SLIGHTBLOOD")), "\n");
707 db_put(d, "TR_KNIGHTSPIKE", "1"); print("effect TR_KNIGHTSPIKE is ", ftos(particleeffectnum("TR_KNIGHTSPIKE")), "\n");
708 db_put(d, "TR_VORESPIKE", "1"); print("effect TR_VORESPIKE is ", ftos(particleeffectnum("TR_VORESPIKE")), "\n");
709 db_put(d, "TR_NEHAHRASMOKE", "1"); print("effect TR_NEHAHRASMOKE is ", ftos(particleeffectnum("TR_NEHAHRASMOKE")), "\n");
710 db_put(d, "TR_NEXUIZPLASMA", "1"); print("effect TR_NEXUIZPLASMA is ", ftos(particleeffectnum("TR_NEXUIZPLASMA")), "\n");
711 db_put(d, "TR_GLOWTRAIL", "1"); print("effect TR_GLOWTRAIL is ", ftos(particleeffectnum("TR_GLOWTRAIL")), "\n");
712 db_put(d, "TR_SEEKER", "1"); print("effect TR_SEEKER is ", ftos(particleeffectnum("TR_SEEKER")), "\n");
713 db_put(d, "SVC_PARTICLE", "1"); print("effect SVC_PARTICLE is ", ftos(particleeffectnum("SVC_PARTICLE")), "\n");
715 fh = fopen("effectinfo.txt", FILE_READ);
716 while((s = fgets(fh)))
719 if(argv(0) == "effect")
721 if(db_get(d, argv(1)) != "1")
723 if(particleeffectnum(argv(1)) >= 0)
724 print("effect ", argv(1), " is ", ftos(particleeffectnum(argv(1))), "\n");
725 db_put(d, argv(1), "1");
729 print("end of effects list\n");
735 case GC_REQUEST_USAGE:
736 print("\nUsage:^3 sv_cmd effectindexdump\n");
737 print(" No arguments required.\n");
742 void GameCommand_extendmatchtime(float request)
746 case GC_REQUEST_HELP:
747 print(" ^2extendmatchtime^7: Increase the timelimit value incrementally\n");
750 case GC_REQUEST_COMMAND:
751 changematchtime(autocvar_timelimit_increment* 60, autocvar_timelimit_min*60, autocvar_timelimit_max*60);
755 case GC_REQUEST_USAGE:
756 print("\nUsage:^3 sv_cmd extendmatchtime\n");
757 print(" No arguments required.\n");
758 print("See also: ^2reducematchtime^7\n");
763 void GameCommand_find(float request, float argc)
769 case GC_REQUEST_HELP:
770 print(" ^2find^7: Search through entities for matching classname\n");
773 case GC_REQUEST_COMMAND:
774 for(client = world; (client = find(client, classname, argv(1))); )
775 print(etos(client), "\n");
779 print("Incorrect parameters for ^2find^7\n");
780 case GC_REQUEST_USAGE:
781 print("\nUsage:^3 sv_cmd find classname\n");
782 print(" Where 'classname' is the classname to search for.\n");
787 void GameCommand_gametype(float request, float argc)
790 float t = MapInfo_Type_FromString(s), tsave = MapInfo_CurrentGametype();
794 case GC_REQUEST_HELP:
795 print(" ^2gametype^7: Simple command to change the active gametype\n");
798 case GC_REQUEST_COMMAND:
801 MapInfo_SwitchGameType(t);
802 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
803 if(MapInfo_count > 0)
804 bprint("Game type successfully switched to ", s, "\n");
807 bprint("Cannot use this game type: no map for it found\n");
808 MapInfo_SwitchGameType(tsave);
809 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
813 bprint("Game type switch to ", s, " failed: this type does not exist!\n");
817 print("Incorrect parameters for ^2gametype^7\n");
818 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");
826 void GameCommand_gettaginfo(float request, float argc) // UNTESTED // todo: finish usage description for it (but, must first learn this shit)
834 case GC_REQUEST_HELP:
835 print(" ^2gettaginfo^7: Get specific information about a weapon model\n");
838 case GC_REQUEST_COMMAND:
841 tmp_entity = spawn();
843 setmodel(tmp_entity, (nextent(world)).weaponentity.model);
846 precache_model(argv(1));
847 setmodel(tmp_entity, argv(1));
849 tmp_entity.frame = stof(argv(2));
850 if(substring(argv(3), 0, 1) == "#")
851 i = stof(substring(argv(3), 1, -1));
853 i = gettagindex(tmp_entity, argv(3));
856 v = gettaginfo(tmp_entity, i);
857 print("model ", tmp_entity.model, " frame ", ftos(tmp_entity.frame), " tag ", gettaginfo_name);
858 print(" index ", ftos(i), " parent ", ftos(gettaginfo_parent), "\n");
859 print(" vector = ", ftos(v_x), " ", ftos(v_y), " ", ftos(v_z), "\n");
860 print(" offset = ", ftos(gettaginfo_offset_x), " ", ftos(gettaginfo_offset_y), " ", ftos(gettaginfo_offset_z), "\n");
861 print(" forward = ", ftos(gettaginfo_forward_x), " ", ftos(gettaginfo_forward_y), " ", ftos(gettaginfo_forward_z), "\n");
862 print(" right = ", ftos(gettaginfo_right_x), " ", ftos(gettaginfo_right_y), " ", ftos(gettaginfo_right_z), "\n");
863 print(" up = ", ftos(gettaginfo_up_x), " ", ftos(gettaginfo_up_y), " ", ftos(gettaginfo_up_z), "\n");
867 localcmd(strcat(argv(4), vtos(v), argv(5), "\n"));
871 print("bone not found\n");
878 print("Incorrect parameters for ^2gettaginfo^7\n");
879 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");
887 void GameCommand_gotomap(float request, float argc)
891 case GC_REQUEST_HELP:
892 print(" ^2gotomap^7: Simple command to switch to another map\n");
895 case GC_REQUEST_COMMAND:
898 print(GotoMap(argv(1)), "\n");
903 print("Incorrect parameters for ^2gotomap^7\n");
904 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");
912 void GameCommand_ladder(float request)
916 case GC_REQUEST_HELP:
917 print(" ^2ladder^7: Get information about top players if supported\n");
920 case GC_REQUEST_COMMAND:
925 case GC_REQUEST_USAGE:
926 print("\nUsage:^3 sv_cmd ladder\n");
927 print(" No arguments required.\n");
932 void GameCommand_lockteams(float request)
936 case GC_REQUEST_HELP:
937 print(" ^2lockteams^7: Disable the ability for players to switch or enter teams\n");
940 case GC_REQUEST_COMMAND:
944 bprint("^1The teams are now locked.\n");
947 bprint("That command can only be used in a team-based gamemode.\n");
951 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");
959 void GameCommand_make_mapinfo(float request) // UNTESTED
965 case GC_REQUEST_HELP:
966 print(" ^2make_mapinfo^7: Automatically rebuild mapinfo files\n");
969 case GC_REQUEST_COMMAND:
970 tmp_entity = spawn();
971 tmp_entity.classname = "make_mapinfo";
972 tmp_entity.think = make_mapinfo_Think;
973 tmp_entity.nextthink = time; // this sucks... todo: re-write this -- Use initializeentity later
978 case GC_REQUEST_USAGE:
979 print("\nUsage:^3 sv_cmd make_mapinfo\n");
980 print(" No arguments required.\n");
985 void GameCommand_modelbug(float request) // UNTESTED // is this even needed anymore?
989 case GC_REQUEST_HELP:
990 print(" ^2modelbug^7: foobar\n");
993 case GC_REQUEST_COMMAND:
998 case GC_REQUEST_USAGE:
999 print("\nUsage:^3 sv_cmd modelbug\n");
1000 print(" No arguments required.\n");
1005 void GameCommand_moveplayer(float request, float argc)
1009 string targets = strreplace(",", " ", argv(1));
1010 string original_targets = strreplace(" ", ", ", targets);
1011 string destination = argv(2);
1012 string notify = argv(3);
1014 string successful, t;
1018 case GC_REQUEST_HELP:
1019 print(" ^2moveplayer^7: Change the team/status of a player\n");
1022 case GC_REQUEST_COMMAND:
1023 // lets see if the target(s) even actually exist.
1024 if((targets) && (destination))
1028 t = car(targets); targets = cdr(targets);
1030 // Check to see if the player is a valid target
1031 if((GetFilteredNumber(t) < 1) || (GetFilteredNumber(t) > maxclients)) // player_id is out of range
1033 print("Player ", ftos(GetFilteredNumber(t)), " doesn't exist (out of range)", (targets ? ", skipping to next player.\n" : ".\n"));
1036 client = edict_num(GetFilteredNumber(t));
1037 if not(client.flags & FL_CLIENT) // player entity is not a client
1039 print("Player ", ftos(GetFilteredNumber(t)), " doesn't exist (not a client)", (targets ? ", skipping to next player.\n" : ".\n"));
1043 // Where are we putting this player?
1044 if(destination == "spec" || destination == "spectator")
1046 if(client.classname != "spectator" && client.classname != "observer")
1049 PutObserverInServer();
1051 successful = strcat(successful, (successful ? ", " : ""), client.netname);
1055 print("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") is already spectating.\n");
1061 if(client.classname != "spectator" && client.classname != "observer")
1067 float save = client.team_forced;
1068 client.team_forced = 0;
1070 // find the team to move the player to
1071 team_color = ColourToNumber(destination);
1072 if(team_color == client.team) // already on the destination team
1074 // keep the forcing undone
1075 print("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") is already on the ", ColoredTeamName(client.team), (targets ? ", skipping to next player.\n" : ".\n"));
1078 else if(team_color == 0) // auto team
1080 team_color = NumberToTeamNumber(FindSmallestTeam(client, FALSE));
1084 CheckAllowedTeams(client);
1086 client.team_forced = save;
1088 // Check to see if the destination team is even available
1091 case COLOR_TEAM1: if(c1 == -1) { print("Sorry, can't move player to red team if it doesn't exist.\n"); return; } break;
1092 case COLOR_TEAM2: if(c2 == -1) { print("Sorry, can't move player to blue team if it doesn't exist.\n"); return; } break;
1093 case COLOR_TEAM3: if(c3 == -1) { print("Sorry, can't move player to yellow team if it doesn't exist.\n"); return; } break;
1094 case COLOR_TEAM4: if(c4 == -1) { print("Sorry, can't move player to pink team if it doesn't exist.\n"); return; } break;
1096 default: print("Sorry, can't move player here if team ", destination, " doesn't exist.\n"); return;
1099 // If so, lets continue and finally move the player
1100 client.team_forced = 0;
1101 MoveToTeam(client, team_color, 6, stof(notify));
1102 successful = strcat(successful, (successful ? ", " : ""), client.netname);
1103 print("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") has been moved to the ", ColoredTeamName(team_color), ".\n");
1108 print("Can't change teams when currently not playing a team game.\n");
1114 print("Can't change teams if the player isn't in the game.\n"); // well technically we could, but should we allow that? :P
1121 print("Successfully moved players ", successful, " to destination ", destination, ".\n");
1123 print("No players given (", original_targets, ") are able to move.\n");
1125 return; // still correct parameters so return to avoid usage print
1129 print("Incorrect parameters for ^2moveplayer^7\n");
1130 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");
1145 void GameCommand_nospectators(float request)
1149 case GC_REQUEST_HELP:
1150 print(" ^2nospectators^7: Automatically remove spectators from a match\n");
1153 case GC_REQUEST_COMMAND:
1154 blockSpectators = 1;
1156 FOR_EACH_CLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
1158 if(plr.classname == "spectator" || plr.classname == "observer")
1160 plr.spectatortime = time;
1161 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"));
1164 bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n"));
1168 case GC_REQUEST_USAGE:
1169 print("\nUsage:^3 sv_cmd nospectators\n");
1170 print(" No arguments required.\n");
1175 void GameCommand_onslaught_updatelinks(float request) // UNTESTED // should this be here? Perhaps some mutatorhook call instead....
1179 case GC_REQUEST_HELP:
1180 print(" ^2onslaught_updatelinks^7: Refresh link status for onslaught\n");
1183 case GC_REQUEST_COMMAND:
1184 onslaught_updatelinks();
1185 print("ONS links updated\n");
1189 case GC_REQUEST_USAGE:
1190 print("\nUsage:^3 sv_cmd onslaught_updatelinks\n");
1191 print(" No arguments required.\n");
1196 void GameCommand_playerdemo(float request, float argc) // UNTESTED // TODO: change the if statements for sub arguments to switches
1204 case GC_REQUEST_HELP:
1205 print(" ^2playerdemo^7: Control the ability to save demos of players\n");
1208 case GC_REQUEST_COMMAND:
1209 if(argv(1) == "read")
1211 // TODO: Create a general command for looking this up, save a lot of space everywhere in this file
1212 entno = stof(argv(2));
1213 if((entno < 1) | (entno > maxclients)) {
1214 print("Player ", argv(2), " doesn't exist\n");
1217 client = edict_num(entno);
1218 if(clienttype(client) != CLIENTTYPE_BOT) {
1219 print("Player ", client.netname, " is not a bot\n");
1223 playerdemo_open_read(argv(3));
1226 else if(argv(1) == "write")
1228 entno = stof(argv(2));
1229 if((entno < 1) | (entno > maxclients)) {
1230 print("Player ", argv(2), " doesn't exist\n");
1233 client = edict_num(entno);
1235 playerdemo_open_write(argv(3));
1238 else if(argv(1) == "auto_read_and_write")
1242 cvar_set("bot_number", ftos(n));
1243 localcmd("wait; wait; wait\n");
1244 for(i = 0; i < n; ++i)
1245 localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", s, ftos(i+1), "\n");
1246 localcmd("sv_cmd playerdemo write 1 ", ftos(n+1), "\n");
1249 else if(argv(1) == "auto_read")
1253 cvar_set("bot_number", ftos(n));
1254 localcmd("wait; wait; wait\n");
1255 for(i = 0; i < n; ++i)
1256 localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", s, ftos(i+1), "\n");
1262 print("Incorrect parameters for ^2radarmap^7\n");
1263 case GC_REQUEST_USAGE:
1264 print("\nUsage:^3 sv_cmd \n");
1265 print(" FIXME: Arguments currently unknown\n");
1270 void GameCommand_printstats(float request)
1274 case GC_REQUEST_HELP:
1275 print(" ^2printstats^7: foobar\n");
1278 case GC_REQUEST_COMMAND:
1280 print("stats dumped.\n");
1284 case GC_REQUEST_USAGE:
1285 print("\nUsage:^3 sv_cmd printstats\n");
1286 print(" No arguments required.\n");
1291 void GameCommand_radarmap(float request, float argc)
1295 case GC_REQUEST_HELP:
1296 print(" ^2radarmap^7: Generate a radar image of the map\n");
1299 case GC_REQUEST_COMMAND:
1300 if(RadarMap_Make(argc))
1304 print("Incorrect parameters for ^2radarmap^7\n");
1305 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");
1313 void GameCommand_rankings(float request) // this is OLD.... jeez.
1317 case GC_REQUEST_HELP:
1318 print(" ^2rankings^7: Print information about rankings\n");
1321 case GC_REQUEST_COMMAND:
1322 strunzone(rankings_reply);
1323 rankings_reply = strzone(getrankings());
1324 print(rankings_reply);
1328 case GC_REQUEST_USAGE:
1329 print("\nUsage:^3 sv_cmd rankings\n");
1330 print(" No arguments required.\n");
1335 void GameCommand_records(float request)
1341 case GC_REQUEST_HELP:
1342 print(" ^2records^7: List top 10 records for the current map\n");
1345 case GC_REQUEST_COMMAND:
1346 for (i = 0; i < 10; ++i)
1347 print(records_reply[i]);
1351 case GC_REQUEST_USAGE:
1352 print("\nUsage:^3 sv_cmd records\n");
1353 print(" No arguments required.\n");
1358 void GameCommand_reducematchtime(float request)
1362 case GC_REQUEST_HELP:
1363 print(" ^2reducematchtime^7: Decrease the timelimit value incrementally\n");
1366 case GC_REQUEST_COMMAND:
1367 changematchtime(autocvar_timelimit_decrement*-60, autocvar_timelimit_min*60, autocvar_timelimit_max*60);
1371 case GC_REQUEST_USAGE:
1372 print("\nUsage:^3 sv_cmd reducematchtime\n");
1373 print(" No arguments required.\n");
1374 print("See also: ^2extendmatchtime^7\n");
1379 void GameCommand_setbots(float request, float argc)
1383 case GC_REQUEST_HELP:
1384 print(" ^2setbots^7: Change the values of bot_number and minplayers immediately to change the bot count\n");
1387 case GC_REQUEST_COMMAND:
1388 if(argc >= 3 && argv(1) == "setbots")
1390 cvar_settemp("minplayers", "0");
1391 cvar_settemp("bot_number", argv(2));
1397 case GC_REQUEST_USAGE:
1398 print("\nUsage:^3 sv_cmd setbots botnumber\n");
1399 print(" Where 'botnumber' is the amount of bots to set bot_number cvar to.\n");
1400 print("See also: ^2bot_cmd^7\n");
1405 void GameCommand_stuffto(float request, float argc)
1407 // This... is a fairly dangerous and powerful command... - It allows any arguments to be sent to a client via rcon.
1408 // Because of this, it is disabled by default and must be enabled by the server owner when doing compilation. That way,
1409 // we can be certain they understand the risks of it... So to enable, compile server with -DSTUFFTO_ENABLED argument.
1414 #ifdef STUFFTO_ENABLED
1417 case GC_REQUEST_HELP:
1418 print(" ^2stuffto^7: Send a command to be executed on a client\n");
1421 case GC_REQUEST_COMMAND:
1424 entno = stof(argv(1));
1426 if(entno <= maxclients)
1427 client = edict_num(entno);
1428 if(client.flags & FL_CLIENT)
1430 stuffcmd(client, strcat("\n", argv(2), "\n"));
1431 print(strcat("Command: \"", argv(2), "\" sent to ", client.netname, " (", argv(1) ,").\n"));
1434 print(strcat("Client (", argv(1) ,") not found.\n"));
1440 print("Incorrect parameters for ^2stuffto^7\n");
1441 case GC_REQUEST_USAGE:
1442 print("\nUsage:^3 sv_cmd stuffto clientnumber command\n");
1443 print(" FIXME: Arguments currently unknown\n");
1446 #else // give the response for missing command to fake them out ;3
1447 if(request == GC_REQUEST_COMMAND)
1449 print("Invalid command. For a list of supported commands, try sv_cmd help.\n");
1455 void GameCommand_teamstatus(float request)
1459 case GC_REQUEST_HELP:
1460 print(" ^2teamstatus^7: Show information about player and team scores\n");
1463 case GC_REQUEST_COMMAND:
1464 Score_NicePrint(world);
1468 case GC_REQUEST_USAGE:
1469 print("\nUsage:^3 sv_cmd teamstatus\n");
1470 print(" No arguments required.\n");
1475 void GameCommand_time(float request)
1479 case GC_REQUEST_HELP:
1480 print(" ^2time^7: Print different formats/readouts of time\n");
1483 case GC_REQUEST_COMMAND:
1484 print("time = ", ftos(time), "\n");
1485 print("frame start = ", ftos(gettime(GETTIME_FRAMESTART)), "\n");
1486 print("realtime = ", ftos(gettime(GETTIME_REALTIME)), "\n");
1487 print("hires = ", ftos(gettime(GETTIME_HIRES)), "\n");
1488 print("uptime = ", ftos(gettime(GETTIME_UPTIME)), "\n");
1489 print("localtime = ", strftime(TRUE, "%a %b %e %H:%M:%S %Z %Y"), "\n"); // FIXME: Why is strftime broken? is engine problem, I think.
1490 print("gmtime = ", strftime(FALSE, "%a %b %e %H:%M:%S %Z %Y"), "\n");
1494 case GC_REQUEST_USAGE:
1495 print("\nUsage:^3 sv_cmd time\n");
1496 print(" No arguments required.\n");
1501 void GameCommand_trace(float request, float argc)
1504 vector org, delta, start, end, p, q, q0, pos, vv, dv;
1505 float i, f, safe, unsafe, dq, dqf;
1507 // TODO: Clean up all of these variables and merge the code below to use only a few
1511 case GC_REQUEST_HELP:
1512 print(" ^2trace^7: Various debugging tools with tracing\n");
1515 case GC_REQUEST_COMMAND:
1519 print("TEST CASE. If this returns the runaway loop counter error, possibly everything is oaky.\n");
1523 delta = world.maxs - world.mins;
1525 start_x = org_x + random() * delta_x;
1526 start_y = org_y + random() * delta_y;
1527 start_z = org_z + random() * delta_z;
1529 end_x = org_x + random() * delta_x;
1530 end_y = org_y + random() * delta_y;
1531 end_z = org_z + random() * delta_z;
1533 start = stov(vtos(start));
1534 end = stov(vtos(end));
1536 tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world);
1537 if(!trace_startsolid)
1540 tracebox(p, PL_MIN, PL_MAX, p, MOVE_NOMONSTERS, world);
1541 if(trace_startsolid || trace_fraction == 1)
1543 rint(42); // do an engine breakpoint on VM_rint so you can get the trace that errnoeously returns startsolid
1544 tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world);
1545 tracebox(p, PL_MIN, PL_MAX, q, MOVE_NOMONSTERS, world);
1547 if(trace_startsolid)
1549 // how much do we need to back off?
1554 pos = p * (1 - (safe + unsafe) * 0.5) + start * ((safe + unsafe) * 0.5);
1555 tracebox(pos, PL_MIN, PL_MAX, pos, MOVE_NOMONSTERS, world);
1556 if(trace_startsolid)
1558 if((safe + unsafe) * 0.5 == unsafe)
1560 unsafe = (safe + unsafe) * 0.5;
1564 if((safe + unsafe) * 0.5 == safe)
1566 safe = (safe + unsafe) * 0.5;
1570 print("safe distance to back off: ", ftos(safe * vlen(p - start)), "qu\n");
1571 print("unsafe distance to back off: ", ftos(unsafe * vlen(p - start)), "qu\n");
1573 tracebox(p, PL_MIN + '0.1 0.1 0.1', PL_MAX - '0.1 0.1 0.1', p, MOVE_NOMONSTERS, world);
1574 if(trace_startsolid)
1575 print("trace_endpos much in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
1577 print("trace_endpos just in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
1586 q = p + normalize(end - p) * (dq + dqf);
1589 tracebox(p, PL_MIN, PL_MAX, q, MOVE_NOMONSTERS, world);
1590 if(trace_startsolid)
1591 error("THIS ONE cannot happen");
1592 if(trace_fraction > 0)
1593 dq += dqf * trace_fraction;
1599 print("trace_endpos still before solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
1600 print("could go ", ftos(dq), " units further to ", vtos(q), "\n");
1610 tracebox(e.origin + '0 0 32', e.mins, e.maxs, e.origin + '0 0 -1024', MOVE_NORMAL, e);
1612 if(trace_fraction == 1)
1614 print("not above ground, aborting\n");
1618 for(i = 0; i < 100000; ++i)
1623 tracebox(vv, e.mins, e.maxs, vv + dv, MOVE_NORMAL, e);
1624 if(trace_startsolid)
1626 if(trace_fraction == 1)
1629 print("bug 2: ", ftos(dv_x), " ", ftos(dv_y), " ", ftos(dv_z));
1630 print(" (", ftos(asin(dv_z / vlen(dv)) * 180 / M_PI), " degrees)\n");
1634 print("highest possible dist: ", ftos(f), "\n");
1641 if(tracewalk(e, stov(argv(1)), e.mins, e.maxs, stov(argv(2)), MOVE_NORMAL))
1642 print("can walk\n");
1644 print("cannot walk\n");
1653 traceline(vv, dv, MOVE_NORMAL, world);
1654 trailparticles(world, particleeffectnum("TR_NEXUIZPLASMA"), vv, trace_endpos);
1655 trailparticles(world, particleeffectnum("TR_CRYLINKPLASMA"), trace_endpos, dv);
1659 // no default case, just go straight to "invalid arguments"
1663 case GC_REQUEST_USAGE:
1664 print("\nUsage:^3 sv_cmd trace command [arguments]\n");
1665 print(" FIXME: Arguments currently unknown\n");
1670 void GameCommand_unlockteams(float request)
1674 case GC_REQUEST_HELP:
1675 print(" ^2unlockteams^7: Enable the ability for players to switch or enter teams\n");
1678 case GC_REQUEST_COMMAND:
1682 bprint("^1The teams are now unlocked.\n");
1685 bprint("That command can only be used in a team-based gamemode.\n");
1689 case GC_REQUEST_USAGE:
1690 print("\nUsage:^3 sv_cmd unlockteams\n");
1691 print(" No arguments required.\n");
1692 print("See also: ^2lockteams^7\n");
1697 void GameCommand_warp(float request, float argc)
1701 case GC_REQUEST_HELP:
1702 print(" ^2warp^7: Choose different level in campaign\n");
1705 case GC_REQUEST_COMMAND:
1706 if(autocvar_g_campaign)
1711 CampaignLevelWarp(stof(argv(1)));
1712 print("Successfully warped to campaign level ", stof(argv(1)), ".\n");
1716 CampaignLevelWarp(-1);
1717 print("Successfully warped to next campaign level.\n");
1721 print("Not in campaign, can't level warp\n");
1725 case GC_REQUEST_USAGE:
1726 print("\nUsage:^3 sv_cmd level\n");
1727 print(" 'level' is the level to change campaign mode to.\n");
1733 // =========================================
1734 // Main Function Called By Engine (sv_cmd)
1735 // =========================================
1736 // If this function exists, game code handles gamecommand instead of the engine code.
1738 void GameCommand(string command)
1740 // ===== TODO list =====
1741 // find all FIXME's and TODO'S and UNTESTED'S and finish them :P
1743 float search_request_type;
1744 float argc = tokenize_console(command);
1746 if(strtolower(argv(0)) == "help")
1750 print("\nUsage:^3 sv_cmd COMMAND...^7, where possible commands are:\n");
1751 GameCommand_adminmsg(GC_REQUEST_HELP, 0);
1752 GameCommand_allready(GC_REQUEST_HELP);
1753 GameCommand_allspec(GC_REQUEST_HELP, 0);
1754 GameCommand_anticheat(GC_REQUEST_HELP, 0);
1755 GameCommand_bbox(GC_REQUEST_HELP);
1756 GameCommand_bot_cmd(GC_REQUEST_HELP, 0);
1757 GameCommand_cointoss(GC_REQUEST_HELP, 0);
1758 GameCommand_cvar_changes(GC_REQUEST_HELP);
1759 GameCommand_cvar_purechanges(GC_REQUEST_HELP);
1760 GameCommand_database(GC_REQUEST_HELP, 0);
1761 GameCommand_defer_clear(GC_REQUEST_HELP, 0);
1762 GameCommand_defer_clear_all(GC_REQUEST_HELP);
1763 GameCommand_delrec(GC_REQUEST_HELP, 0);
1764 GameCommand_effectindexdump(GC_REQUEST_HELP);
1765 GameCommand_extendmatchtime(GC_REQUEST_HELP);
1766 GameCommand_find(GC_REQUEST_HELP, 0);
1767 GameCommand_gametype(GC_REQUEST_HELP, 0);
1768 GameCommand_gettaginfo(GC_REQUEST_HELP, 0);
1769 GameCommand_gotomap(GC_REQUEST_HELP, 0);
1770 GameCommand_ladder(GC_REQUEST_HELP);
1771 GameCommand_lockteams(GC_REQUEST_HELP);
1772 GameCommand_make_mapinfo(GC_REQUEST_HELP);
1773 GameCommand_modelbug(GC_REQUEST_HELP);
1774 GameCommand_moveplayer(GC_REQUEST_HELP, 0);
1775 GameCommand_nospectators(GC_REQUEST_HELP);
1776 GameCommand_onslaught_updatelinks(GC_REQUEST_HELP);
1777 GameCommand_playerdemo(GC_REQUEST_HELP, 0);
1778 GameCommand_printstats(GC_REQUEST_HELP);
1779 GameCommand_radarmap(GC_REQUEST_HELP, 0);
1780 GameCommand_rankings(GC_REQUEST_HELP);
1781 GameCommand_records(GC_REQUEST_HELP);
1782 GameCommand_reducematchtime(GC_REQUEST_HELP);
1783 GameCommand_setbots(GC_REQUEST_HELP, 0);
1784 GameCommand_stuffto(GC_REQUEST_HELP, 0);
1785 GameCommand_teamstatus(GC_REQUEST_HELP);
1786 GameCommand_time(GC_REQUEST_HELP);
1787 GameCommand_trace(GC_REQUEST_HELP, 0);
1788 GameCommand_unlockteams(GC_REQUEST_HELP);
1789 GameCommand_warp(GC_REQUEST_HELP, 0);
1790 GameCommand_Vote("help", world);
1791 GameCommand_Ban("help");
1792 GameCommand_Generic("help");
1793 print("For help about specific commands, type sv_cmd help COMMAND\n");
1797 search_request_type = GC_REQUEST_USAGE; // Instead of trying to call a command, we're going to see detailed information about it
1799 else if(GameCommand_Vote(command, world))
1801 return; // handled by server/vote.qc
1803 else if(GameCommand_Ban(command))
1805 return; // handled by server/ipban.qc
1807 else if(GameCommand_Generic(command))
1809 return; // handled by common/gamecommand.qc
1812 search_request_type = GC_REQUEST_COMMAND; // continue as usual and scan for normal commands
1814 switch(strtolower((search_request_type == GC_REQUEST_USAGE) ? argv(1) : argv(0))) // if first argument is help, then search for the second argument. Else, search for first.
1816 // Do not hard code aliases for these, instead create them in defaultXonotic.cfg
1817 // also: keep in alphabetical order, please ;)
1819 case "adminmsg": GameCommand_adminmsg(search_request_type, argc); break;
1820 case "allready": GameCommand_allready(search_request_type); break;
1821 case "allspec": GameCommand_allspec(search_request_type, argc); break;
1822 case "anticheat": GameCommand_anticheat(search_request_type, argc); break;
1823 case "bbox": GameCommand_bbox(search_request_type); break;
1824 case "bot_cmd": GameCommand_bot_cmd(search_request_type, argc); break;
1825 case "cointoss": GameCommand_cointoss(search_request_type, argc); break;
1826 case "cvar_changes": GameCommand_cvar_changes(search_request_type); break;
1827 case "cvar_purechanges": GameCommand_cvar_purechanges(search_request_type); break;
1828 case "database": GameCommand_database(search_request_type, argc); break;
1829 case "defer_clear": GameCommand_defer_clear(search_request_type, argc); break;
1830 case "defer_clear_all": GameCommand_defer_clear_all(search_request_type); break;
1831 case "delrec": GameCommand_delrec(search_request_type, argc); break;
1832 case "effectindexdump": GameCommand_effectindexdump(search_request_type); break;
1833 case "extendmatchtime": GameCommand_extendmatchtime(search_request_type); break;
1834 case "find": GameCommand_find(search_request_type, argc); break;
1835 case "gametype": GameCommand_gametype(search_request_type, argc); break;
1836 case "gettaginfo": GameCommand_gettaginfo(search_request_type, argc); break;
1837 case "gotomap": GameCommand_gotomap(search_request_type, argc); break;
1838 case "ladder": GameCommand_ladder(search_request_type); break;
1839 case "lockteams": GameCommand_lockteams(search_request_type); break;
1840 case "make_mapinfo": GameCommand_make_mapinfo(search_request_type); break;
1841 case "modelbug": GameCommand_modelbug(search_request_type); break;
1842 case "moveplayer": GameCommand_moveplayer(search_request_type, argc); break;
1843 case "nospectators": GameCommand_nospectators(search_request_type); break;
1844 case "onslaught_updatelinks": GameCommand_onslaught_updatelinks(search_request_type); break;
1845 case "playerdemo": GameCommand_playerdemo(search_request_type, argc); break;
1846 case "printstats": GameCommand_printstats(search_request_type); break;
1847 case "radarmap": GameCommand_radarmap(search_request_type, argc); break;
1848 case "rankings": GameCommand_rankings(search_request_type); break;
1849 case "records": GameCommand_records(search_request_type); break;
1850 case "reducematchtime": GameCommand_reducematchtime(search_request_type); break;
1851 case "setbots": GameCommand_setbots(search_request_type, argc); break;
1852 case "stuffto": GameCommand_stuffto(search_request_type, argc); break;
1853 case "teamstatus": GameCommand_teamstatus(search_request_type); break;
1854 case "time": GameCommand_time(search_request_type); break;
1855 case "trace": GameCommand_trace(search_request_type, argc); break;
1856 case "unlockteams": GameCommand_unlockteams(search_request_type); break;
1857 case "warp": GameCommand_warp(search_request_type, argc); break;
1860 print("Invalid command. For a list of supported commands, try sv_cmd help.\n");