1 string GotoMap(string m);
2 void race_deleteTime(string map, float pos);
4 float FullTraceFraction(vector a, vector mi, vector ma, vector b)
17 while(vlen(c - b) > 1)
21 tracebox(c, mi, ma, b, MOVE_WORLDONLY, world);
26 black += vlen(trace_endpos - c);
30 n += tracebox_inverted(c, mi, ma, b, MOVE_WORLDONLY, world);
32 white += vlen(trace_endpos - c);
37 dprint("HOLY SHIT! FullTraceFraction: ", ftos(n), " total traces, ", ftos(m), " iterations\n");
39 return white / (black + white);
42 float RadarMapAtPoint_Trace(float x, float y, float w, float h, float zmin, float zsize, float q)
47 ma = '1 0 0' * w + '0 1 0' * h;
48 a = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
49 b = '1 0 0' * x + '0 1 0' * y + '0 0 1' * (zsize + zmin);
51 return FullTraceFraction(a, mi, ma, b);
53 float RadarMapAtPoint_LineBlock(float x, float y, float w, float h, float zmin, float zsize, float q)
60 // 256q-1 is the ideal sample count to map equal amount of sample values to one pixel value
63 dz = (zsize / q) * '0 0 1';
64 ma = '1 0 0' * w + '0 1 0' * h + dz;
65 o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
67 if(x < world.absmin_x - w)
69 if(y < world.absmin_y - h)
71 if(x > world.absmax_x)
73 if(y > world.absmax_y)
77 for(i = 0; i < q; ++i)
80 v1 = v2 = o + dz * i + mi;
81 v1_x += random() * (ma_x - mi_x);
82 v1_y += random() * (ma_y - mi_y);
83 v1_z += random() * (ma_z - mi_z);
84 v2_x += random() * (ma_x - mi_x);
85 v2_y += random() * (ma_y - mi_y);
86 v2_z += random() * (ma_z - mi_z);
87 traceline(v1, v2, MOVE_WORLDONLY, world);
88 if(trace_startsolid || trace_fraction < 1)
93 float RadarMapAtPoint_Block(float x, float y, float w, float h, float zmin, float zsize, float q)
100 // 256q-1 is the ideal sample count to map equal amount of sample values to one pixel value
103 dz = (zsize / q) * '0 0 1';
104 ma = '1 0 0' * w + '0 1 0' * h + dz;
105 o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
107 if(x < world.absmin_x - w)
109 if(y < world.absmin_y - h)
111 if(x > world.absmax_x)
113 if(y > world.absmax_y)
117 for(i = 0; i < q; ++i)
119 tracebox(o + dz * i, mi, ma, o + dz * i, MOVE_WORLDONLY, world);
125 float RadarMapAtPoint_Sample(float x, float y, float w, float h, float zmin, float zsize, float q)
129 q *= 4; // choose q so it matches the regular algorithm in speed
132 // 256q-1 is the ideal sample count to map equal amount of sample values to one pixel value
135 ma = '1 0 0' * w + '0 1 0' * h;
136 a = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
137 b = '1 0 0' * w + '0 1 0' * h + '0 0 1' * zsize;
142 for(i = 0; i < q; ++i)
145 v_x = a_x + random() * b_x;
146 v_y = a_y + random() * b_y;
147 v_z = a_z + random() * b_z;
148 traceline(v, v, MOVE_WORLDONLY, world);
156 // FF is contained twice, to map 256 to FF too
157 // removes the need to bound()
158 string doublehex = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFFFF";
160 float RADAR_WIDTH_MAX = 512;
161 float RADAR_HEIGHT_MAX = 512;
162 float sharpen_buffer[RADAR_WIDTH_MAX * 3];
164 void sharpen_set(float x, float v)
166 sharpen_buffer[x + 2 * RADAR_WIDTH_MAX] = v;
169 float sharpen_getpixel(float x, float y)
173 if(x >= RADAR_WIDTH_MAX)
179 return sharpen_buffer[x + y * RADAR_WIDTH_MAX];
182 float sharpen_get(float x, float a)
185 sum = sharpen_getpixel(x, 1);
189 sum -= sharpen_getpixel(x - 1, 0);
190 sum -= sharpen_getpixel(x - 1, 1);
191 sum -= sharpen_getpixel(x - 1, 2);
192 sum -= sharpen_getpixel(x + 1, 0);
193 sum -= sharpen_getpixel(x + 1, 1);
194 sum -= sharpen_getpixel(x + 1, 2);
195 sum -= sharpen_getpixel(x, 0);
196 sum -= sharpen_getpixel(x, 2);
197 return bound(0, sum * a, 1);
200 void sharpen_shift(float w)
203 for(i = 0; i < w; ++i)
205 sharpen_buffer[i] = sharpen_buffer[i + RADAR_WIDTH_MAX];
206 sharpen_buffer[i + RADAR_WIDTH_MAX] = sharpen_buffer[i + 2 * RADAR_WIDTH_MAX];
207 sharpen_buffer[i + 2 * RADAR_WIDTH_MAX] = 0;
211 void sharpen_init(float w)
214 for(i = 0; i < w; ++i)
216 sharpen_buffer[i] = 0;
217 sharpen_buffer[i + RADAR_WIDTH_MAX] = 0;
218 sharpen_buffer[i + 2 * RADAR_WIDTH_MAX] = 0;
225 if(radarmapper.count & 4)
229 else if(radarmapper.count & 2)
231 localcmd(strcat("defer 1 \"sv_cmd radarmap --flags ", ftos(radarmapper.count), strcat(" --res ", ftos(radarmapper.size_x), " ", ftos(radarmapper.size_y), " --sharpen ", ftos(radarmapper.ltime), " --qual ", ftos(radarmapper.size_z)), "\"\n"));
240 // size: pixel width/height
241 // maxs: cell width/height
243 void RadarMap_Think()
251 get_mi_min_max_texcoords(1);
252 self.mins = mi_picmin;
253 self.maxs_x = (mi_picmax_x - mi_picmin_x) / self.size_x;
254 self.maxs_y = (mi_picmax_y - mi_picmin_y) / self.size_y;
255 self.maxs_z = mi_max_z - mi_min_z;
256 print("Picture mins/maxs: ", ftos(self.maxs_x), " and ", ftos(self.maxs_y), " should match\n");
257 self.netname = strzone(strcat("gfx/", mi_shortname, "_radar.xpm"));
258 if(!(self.count & 1))
260 self.cnt = fopen(self.netname, FILE_READ);
262 self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.tga"), FILE_READ);
264 self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.png"), FILE_READ);
266 self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.jpg"), FILE_READ);
268 self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.tga"), FILE_READ);
270 self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.png"), FILE_READ);
272 self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.jpg"), FILE_READ);
277 print(self.netname, " already exists, aborting (you may want to specify --force)\n");
282 self.cnt = fopen(self.netname, FILE_WRITE);
285 print("Error writing ", self.netname, "\n");
290 print("Writing to ", self.netname, "...\n");
291 fputs(self.cnt, "/* XPM */\n");
292 fputs(self.cnt, "static char *RadarMap[] = {\n");
293 fputs(self.cnt, "/* columns rows colors chars-per-pixel */\n");
294 fputs(self.cnt, strcat("\"", ftos(self.size_x), " ", ftos(self.size_y), " 256 2\",\n"));
295 for(i = 0; i < 256; ++i)
297 si = substring(doublehex, i*2, 2);
298 fputs(self.cnt, strcat("\"", si, " c #", si, si, si, "\",\n"));
301 self.nextthink = time;
302 sharpen_init(self.size_x);
304 else if(self.frame <= self.size_y)
306 // fill the sharpen buffer with this line
307 sharpen_shift(self.size_x);
314 for(x = 0; x < self.size_x; ++x)
316 l = RadarMapAtPoint_Block(self.mins_x + x * self.maxs_x, self.mins_y + (self.size_y - self.frame) * self.maxs_y, self.maxs_x, self.maxs_y, self.mins_z, self.maxs_z, self.size_z);
321 for(x = 0; x < self.size_x; ++x)
323 l = RadarMapAtPoint_Trace(self.mins_x + x * self.maxs_x, self.mins_y + (self.size_y - self.frame) * self.maxs_y, self.maxs_x, self.maxs_y, self.mins_z, self.maxs_z, self.size_z);
328 for(x = 0; x < self.size_x; ++x)
330 l = RadarMapAtPoint_Sample(self.mins_x + x * self.maxs_x, self.mins_y + (self.size_y - self.frame) * self.maxs_y, self.maxs_x, self.maxs_y, self.mins_z, self.maxs_z, self.size_z);
335 for(x = 0; x < self.size_x; ++x)
337 l = RadarMapAtPoint_LineBlock(self.mins_x + x * self.maxs_x, self.mins_y + (self.size_y - self.frame) * self.maxs_y, self.maxs_x, self.maxs_y, self.mins_z, self.maxs_z, self.size_z);
343 // do we have enough lines?
346 // write a pixel line
347 fputs(self.cnt, "\"");
348 for(x = 0; x < self.size_x; ++x)
350 l = sharpen_get(x, self.ltime);
351 fputs(self.cnt, substring(doublehex, 2 * floor(l * 256.0), 2));
353 if(self.frame == self.size_y)
354 fputs(self.cnt, "\"\n");
357 fputs(self.cnt, "\",\n");
358 print(ftos(self.size_y - self.frame), " lines left\n");
362 // is this the last line? then write back the missing line
363 if(self.frame == self.size_y)
365 sharpen_shift(self.size_x);
366 // write a pixel line
367 fputs(self.cnt, "\"");
368 for(x = 0; x < self.size_x; ++x)
370 l = sharpen_get(x, self.ltime);
371 fputs(self.cnt, substring(doublehex, 2 * floor(l * 256.0), 2));
373 if(self.frame == self.size_y)
374 fputs(self.cnt, "\"\n");
377 fputs(self.cnt, "\",\n");
378 print(ftos(self.size_y - self.frame), " lines left\n");
383 self.nextthink = time;
388 fputs(self.cnt, "};\n");
390 print("Finished. Please edit data/", self.netname, " with an image editing application and place it in the TGA format in the gfx folder.\n");
395 void RadarMap(float argc)
400 radarmapper = spawn();
401 radarmapper.classname = "radarmapper";
402 radarmapper.think = RadarMap_Think;
403 radarmapper.nextthink = time;
404 radarmapper.count = 8; // default to the --trace method, as it is faster now
405 radarmapper.ltime = 1;
406 radarmapper.size_x = 512;
407 radarmapper.size_y = 512;
408 radarmapper.size_z = 1;
410 for(i = 1; i < argc; ++i)
412 if(argv(i) == "--force")
413 radarmapper.count |= 1;
414 else if(argv(i) == "--loop")
415 radarmapper.count |= 2;
416 else if(argv(i) == "--quit")
417 radarmapper.count |= 4;
418 else if(argv(i) == "--block")
420 radarmapper.count &~= 24;
422 else if(argv(i) == "--trace")
424 radarmapper.count &~= 24;
425 radarmapper.count |= 8;
427 else if(argv(i) == "--sample")
429 radarmapper.count &~= 24;
430 radarmapper.count |= 16;
432 else if(argv(i) == "--lineblock")
434 radarmapper.count |= 24;
436 else if(argv(i) == "--flags") // for the recursive call
439 radarmapper.count = stof(argv(i));
441 else if(argv(i) == "--sharpen") // for the recursive call
444 radarmapper.ltime = stof(argv(i));
446 else if(argv(i) == "--res") // resolution
449 radarmapper.size_x = stof(argv(i));
451 radarmapper.size_y = stof(argv(i));
453 else if(argv(i) == "--qual") // quality multiplier
456 radarmapper.size_z = stof(argv(i));
462 print("Usage: sv_cmd radarmap [--force] [--loop] [--quit] [--block | --trace | --sample | --lineblock] [--sharpen N] [--res W H] [--qual Q]\n");
463 print("The quality factor Q is roughly proportional to the time taken.\n");
464 print("--trace supports no quality factor; its result should look like --block with infinite quality factor.\n");
470 print("Radarmap entity spawned.\n");
473 // ======================
474 // Supporting Functions
475 // ======================
477 void make_mapinfo_Think()
479 if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
481 print("Done rebuiling mapinfos.\n");
482 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
487 self.think = make_mapinfo_Think;
488 self.nextthink = time;
492 void changematchtime(float delta, float mi, float ma)
500 if(autocvar_timelimit < 0)
504 mi = 10; // at least ten sec in the future
505 cur = time - game_starttime;
507 mi += cur; // from current time!
509 lim = autocvar_timelimit * 60;
514 return; // cannot increase any further
516 new = min(ma, lim + delta);
517 else // already above maximum: FAIL
522 if(lim == 0) // infinite: try reducing to max, if we are allowed to
524 else if(lim > mi) // above minimum: decrease
525 new = max(mi, lim + delta);
526 else // already below minimum: FAIL
530 cvar_set("timelimit", ftos(new / 60));
533 float g_clientmodel_genericsendentity (entity to, float sf);
534 void modelbug_make_svqc();
535 void modelbug_make_csqc()
537 Net_LinkEntity(self, TRUE, 0, g_clientmodel_genericsendentity);
538 self.think = modelbug_make_svqc;
539 self.nextthink = time + 1;
540 setorigin(self, self.origin - '0 0 8');
542 void modelbug_make_svqc()
544 self.SendEntity = func_null;
545 self.think = modelbug_make_csqc;
546 self.nextthink = time + 1;
547 setorigin(self, self.origin + '0 0 8');
554 setorigin(e, nextent(world).origin);
555 precache_model("models_portal.md3");
556 setmodel(e, "models/portal.md3");
557 e.think = modelbug_make_svqc;
558 e.nextthink = time + 1;
561 // ===================
563 // ===================
564 #define GC_REQUEST_HELP 1
565 #define GC_REQUEST_COMMAND 2
566 #define GC_REQUEST_USAGE 3
568 void GameCommand_adminmsg(float request, float argc)
571 float entno = stof(argv(1));
577 case GC_REQUEST_HELP:
578 print(" ^2adminmsg^7: Send an admin message to a client directly\n");
581 case GC_REQUEST_COMMAND:
582 if(argc >= 3 && argc <= 4) {
583 if((entno < 0) | (entno > maxclients)) {
584 print("Player ", argv(1), " doesn't exist\n");
588 for(i = (entno ? entno : 1); i <= (entno ? entno : maxclients); ++i)
590 client = edict_num(i);
591 if(client.flags & FL_CLIENT)
596 s = strreplace("\n", "", s);
597 s = strreplace("\\", "\\\\", s);
598 s = strreplace("$", "$$", s);
599 s = strreplace("\"", "\\\"", s);
600 stuffcmd(client, sprintf("\ninfobar %f \"%s\"\n", stof(argv(3)), s));
604 centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3", admin_name(), ":\n\n^7", argv(2)));
605 sprint(client, strcat("\{1}\{13}^3", admin_name(), "^7: ", argv(2), "\n"));
607 dprint("Message sent to ", client.netname, "\n");
611 if(!n) { print("Client not found\n"); }
616 print("Incorrect parameters for \"adminmsg\"\n");
617 case GC_REQUEST_USAGE:
618 print("\nUsage:^3 sv_cmd adminmsg clientnumber \"message\" [infobartime]\n");
619 print(" If infobartime is provided, the message will be sent to infobar.\n");
620 print(" Otherwise, it will just be sent as a centerprint message.\n");
621 print("Examples: adminmsg 4 \"this message will last for ten seconds\" 10\n");
622 print(" adminmsg 2 \"this message will be a centerprint\"\n");
627 void GameCommand_allready(float request)
631 case GC_REQUEST_HELP:
632 print(" ^2allready^7: Restart the server and reset the players\n");
635 case GC_REQUEST_COMMAND:
640 case GC_REQUEST_USAGE:
641 print("\nUsage:^3 sv_cmd allready\n");
642 print(" No arguments required.\n");
647 void GameCommand_allspec(float request) // todo: Add ability to provide a reason string?
654 case GC_REQUEST_HELP:
655 print(" ^2allspec^7: Force all players to spectate\n");
658 case GC_REQUEST_COMMAND:
659 FOR_EACH_PLAYER(client)
662 PutObserverInServer();
665 if(i) { bprint(strcat("Successfully forced all players to spectate (", ftos(i), ")\n")); } // should a message be added if no players were found?
669 case GC_REQUEST_USAGE:
670 print("\nUsage:^3 sv_cmd allspec\n");
671 print(" No arguments required.\n");
672 print("See also: ^2moveplayer^7\n");
677 void GameCommand_anticheat(float request, float argc) // FIXME: player entity is never found
680 float entno = stof(argv(1));
684 case GC_REQUEST_HELP:
685 print(" ^2anticheat^7: Create an anticheat report for a client\n");
688 case GC_REQUEST_COMMAND:
689 if((entno < 1) | (entno > maxclients)) {
690 print("Player ", argv(1), " doesn't exist\n");
693 client = edict_num(entno);
694 if(clienttype(client) != CLIENTTYPE_REAL && clienttype(client) != CLIENTTYPE_BOT) {
695 print("Player ", client.netname, " is not active\n");
703 print("Incorrect parameters for \"anticheat\"\n");
704 case GC_REQUEST_USAGE:
705 print("\nUsage:^3 sv_cmd anticheat clientnumber\n");
706 print(" where clientnumber is player entity number.\n");
711 void GameCommand_bbox(float request)
715 case GC_REQUEST_HELP:
716 print(" ^2bbox^7: Print detailed information about world size\n");
719 case GC_REQUEST_COMMAND:
720 print("Original size: ", ftos(world.absmin_x), " ", ftos(world.absmin_y), " ", ftos(world.absmin_z));
721 print(" ", ftos(world.absmax_x), " ", ftos(world.absmax_y), " ", ftos(world.absmax_z), "\n");
722 print("Currently set size: ", ftos(world.mins_x), " ", ftos(world.mins_y), " ", ftos(world.mins_z));
723 print(" ", ftos(world.maxs_x), " ", ftos(world.maxs_y), " ", ftos(world.maxs_z), "\n");
724 print("Solid bounding box size:");
726 tracebox('1 0 0' * world.absmin_x,
727 '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
728 '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
729 '1 0 0' * world.absmax_x,
733 print(" ", ftos(world.absmin_x));
735 print(" ", ftos(trace_endpos_x));
737 tracebox('0 1 0' * world.absmin_y,
738 '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
739 '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
740 '0 1 0' * world.absmax_y,
744 print(" ", ftos(world.absmin_y));
746 print(" ", ftos(trace_endpos_y));
748 tracebox('0 0 1' * world.absmin_z,
749 '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
750 '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
751 '0 0 1' * world.absmax_z,
755 print(" ", ftos(world.absmin_z));
757 print(" ", ftos(trace_endpos_z));
759 tracebox('1 0 0' * world.absmax_x,
760 '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
761 '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
762 '1 0 0' * world.absmin_x,
766 print(" ", ftos(world.absmax_x));
768 print(" ", ftos(trace_endpos_x));
770 tracebox('0 1 0' * world.absmax_y,
771 '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
772 '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
773 '0 1 0' * world.absmin_y,
777 print(" ", ftos(world.absmax_y));
779 print(" ", ftos(trace_endpos_y));
781 tracebox('0 0 1' * world.absmax_z,
782 '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
783 '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
784 '0 0 1' * world.absmin_z,
788 print(" ", ftos(world.absmax_z));
790 print(" ", ftos(trace_endpos_z));
796 case GC_REQUEST_USAGE:
797 print("\nUsage:^3 sv_cmd bbox\n");
798 print(" No arguments required.\n");
799 print("See also: ^2gettaginfo^7\n");
804 void GameCommand_bot_cmd(float request, float argc) // what a mess... old old code.
810 case GC_REQUEST_HELP:
811 print(" ^2bot_cmd^7: Control and send commands to bots\n");
814 case GC_REQUEST_COMMAND:
815 if(argv(1) == "reset")
820 else if(argv(1) == "load" && argc == 3)
824 fh = fopen(argv(2), FILE_READ);
827 print("cannot open the file\n");
832 while((s = fgets(fh)))
834 argc = tokenize_console(s);
836 if(argc >= 3 && argv(0) == "sv_cmd" && argv(1) == "bot_cmd")
838 // let's start at token 2 so we can skip sv_cmd bot_cmd
839 bot = find_bot_by_number(stof(argv(2)));
841 bot = find_bot_by_name(argv(2));
843 bot_queuecommand(bot, strcat(argv(3), " ", argv(4)));
846 localcmd(strcat(s, "\n"));
850 print(ftos(i), " commands read\n");
854 else if(argv(1) == "help")
857 bot_cmdhelp(argv(2));
862 else if(argc >= 3) // this comes last
864 bot = find_bot_by_number(stof(argv(1)));
866 bot = find_bot_by_name(argv(1));
869 print(strcat("Command '", (argv(2), " ", argv(3)), "' sent to bot ", bot.netname, "\n"));
870 bot_queuecommand(bot, strcat(argv(2), " ", argv(3)));
874 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
878 print("Incorrect parameters for \"bot_cmd\"\n");
879 case GC_REQUEST_USAGE:
880 print("\nUsage:^3 sv_cmd bot_cmd client command [argument]\n");
881 print(" 'client' can be either the name or entity id of the bot\n");
882 print(" For full list of commands, see bot_cmd help [command].\n");
883 print("Examples: bot_cmd <id> cc \"say something\"\n");
884 print(" bot_cmd <id> presskey jump\n");
889 void GameCommand_cointoss(float request) // todo: Perhaps add the ability to give your own arguments to pick between? (Like player names)
892 float choice = (random() > 0.5);
896 case GC_REQUEST_HELP:
897 print(" ^2cointoss^7: Flip a virtual coin and give random result\n");
900 case GC_REQUEST_COMMAND:
901 FOR_EACH_CLIENT(client)
902 centerprint(client, strcat("^3Throwing coin... Result: ", (choice ? "^1HEADS^3!\n" : "^4TAILS^3!\n")));
903 bprint(strcat("^3Throwing coin... Result: ", (choice ? "^1HEADS^3!\n" : "^4TAILS^3!\n")));
907 case GC_REQUEST_USAGE:
908 print("\nUsage:^3 sv_cmd cointoss\n");
909 print(" No arguments required.\n");
914 void GameCommand_cvar_changes(float request)
918 case GC_REQUEST_HELP:
919 print(" ^2cvar_changes^7: Prints a list of all changed server cvars\n");
922 case GC_REQUEST_COMMAND:
927 case GC_REQUEST_USAGE:
928 print("\nUsage:^3 sv_cmd \n");
929 print(" No arguments required.\n");
930 print("See also: ^2cvar_purechanges^7\n");
935 void GameCommand_cvar_purechanges(float request)
939 case GC_REQUEST_HELP:
940 print(" ^2cvar_purechanges^7: Prints a list of all changed gameplay cvars\n");
943 case GC_REQUEST_COMMAND:
944 print(cvar_purechanges);
948 case GC_REQUEST_USAGE:
949 print("\nUsage:^3 sv_cmd cvar_purechanges\n");
950 print(" No arguments required.\n");
951 print("See also: ^2cvar_changes^7\n");
956 void GameCommand_database(float request, float argc)
960 case GC_REQUEST_HELP:
961 print(" ^2database^7: Extra controls of the serverprogs database\n");
964 case GC_REQUEST_COMMAND:
967 if(argv(1) == "save")
969 db_save(ServerProgsDB, argv(2));
970 print(strcat("Copied serverprogs database to '", argv(2), "' in the data directory.\n"));
973 else if(argv(1) == "dump")
975 db_dump(ServerProgsDB, argv(2));
976 print("DB dumped.\n"); // wtf does this do?
979 else if(argv(1) == "load")
981 db_close(ServerProgsDB);
982 ServerProgsDB = db_load(argv(2));
983 print(strcat("Loaded '", argv(2), "' as new serverprogs database.\n"));
989 print("Incorrect parameters for \"database\"\n");
990 case GC_REQUEST_USAGE:
991 print("\nUsage:^3 sv_cmd database action filename\n");
992 print(" Where 'action' is the command to complete,\n");
993 print(" and 'filename' is what it acts upon.\n");
994 print(" Full list of commands here: \"save, dump, load.\"\n");
999 void GameCommand_defer_clear(float request, float argc)
1002 float entno = stof(argv(1));
1006 case GC_REQUEST_HELP:
1007 print(" ^2defer_clear^7: Clear all queued defer commands for client\n");
1010 case GC_REQUEST_COMMAND:
1013 // player_id is out of range
1014 if((entno < 1) | (entno > maxclients)) {
1015 print("Player ", argv(1), " doesn't exist\n");
1018 client = edict_num(entno);
1019 if not(client.flags & FL_CLIENT) {
1020 print("Player ", argv(1), " doesn't exist\n");
1023 if(clienttype(client) == CLIENTTYPE_BOT) {
1024 print("Player ", argv(1), " (", client.netname, ") is a bot\n");
1027 stuffcmd(client, "defer clear\n");
1028 print("defer clear stuffed to ", argv(1), " (", client.netname, ")\n");
1033 print("Incorrect parameters for \"defer_clear\"\n");
1034 case GC_REQUEST_USAGE:
1035 print("\nUsage:^3 sv_cmd defer_clear clientnumber\n");
1036 print(" where 'clientnumber' is player entity number.\n");
1037 print("See also: ^2defer_clear_all^7\n");
1042 void GameCommand_defer_clear_all(float request)
1050 case GC_REQUEST_HELP:
1051 print(" ^2defer_clear_all^7: Clear all queued defer commands for all clients\n");
1054 case GC_REQUEST_COMMAND:
1055 FOR_EACH_CLIENT(client)
1057 argc = tokenize_console(strcat("defer_clear ", ftos(num_for_edict(client))));
1058 GameCommand_defer_clear(GC_REQUEST_COMMAND, argc);
1061 if(i) { bprint(strcat("Successfully stuffed defer clear to all clients (", ftos(i), ")\n")); } // should a message be added if no players were found?
1065 case GC_REQUEST_USAGE:
1066 print("\nUsage:^3 sv_cmd defer_clear_all\n");
1067 print(" No arguments required.\n");
1068 print("See also: ^2defer_clear^7\n");
1073 void GameCommand_delrec(float request, float argc) // UNTESTED
1077 case GC_REQUEST_HELP:
1078 print(" ^2delrec^7: Delete race time record for a map\n");
1081 case GC_REQUEST_COMMAND:
1085 race_deleteTime(argv(2), stof(argv(1)));
1087 race_deleteTime(GetMapname(), stof(argv(1)));
1092 print("Incorrect parameters for \"delrec\"\n");
1093 case GC_REQUEST_USAGE:
1094 print("\nUsage:^3 sv_cmd delrec ranking [map]\n");
1095 print(" 'ranking' is which ranking level to clear up to, \n");
1096 print(" it will clear all records up to nth place.\n");
1097 print(" if 'map' is not provided it will use current map.\n");
1102 void GameCommand_effectindexdump(float request)
1109 case GC_REQUEST_HELP:
1110 print(" ^2effectindexdump^7: Dump list of effects from code and effectinfo.txt\n");
1113 case GC_REQUEST_COMMAND:
1115 print("begin of effects list\n");
1116 db_put(d, "TE_GUNSHOT", "1"); print("effect TE_GUNSHOT is ", ftos(particleeffectnum("TE_GUNSHOT")), "\n");
1117 db_put(d, "TE_GUNSHOTQUAD", "1"); print("effect TE_GUNSHOTQUAD is ", ftos(particleeffectnum("TE_GUNSHOTQUAD")), "\n");
1118 db_put(d, "TE_SPIKE", "1"); print("effect TE_SPIKE is ", ftos(particleeffectnum("TE_SPIKE")), "\n");
1119 db_put(d, "TE_SPIKEQUAD", "1"); print("effect TE_SPIKEQUAD is ", ftos(particleeffectnum("TE_SPIKEQUAD")), "\n");
1120 db_put(d, "TE_SUPERSPIKE", "1"); print("effect TE_SUPERSPIKE is ", ftos(particleeffectnum("TE_SUPERSPIKE")), "\n");
1121 db_put(d, "TE_SUPERSPIKEQUAD", "1"); print("effect TE_SUPERSPIKEQUAD is ", ftos(particleeffectnum("TE_SUPERSPIKEQUAD")), "\n");
1122 db_put(d, "TE_WIZSPIKE", "1"); print("effect TE_WIZSPIKE is ", ftos(particleeffectnum("TE_WIZSPIKE")), "\n");
1123 db_put(d, "TE_KNIGHTSPIKE", "1"); print("effect TE_KNIGHTSPIKE is ", ftos(particleeffectnum("TE_KNIGHTSPIKE")), "\n");
1124 db_put(d, "TE_EXPLOSION", "1"); print("effect TE_EXPLOSION is ", ftos(particleeffectnum("TE_EXPLOSION")), "\n");
1125 db_put(d, "TE_EXPLOSIONQUAD", "1"); print("effect TE_EXPLOSIONQUAD is ", ftos(particleeffectnum("TE_EXPLOSIONQUAD")), "\n");
1126 db_put(d, "TE_TAREXPLOSION", "1"); print("effect TE_TAREXPLOSION is ", ftos(particleeffectnum("TE_TAREXPLOSION")), "\n");
1127 db_put(d, "TE_TELEPORT", "1"); print("effect TE_TELEPORT is ", ftos(particleeffectnum("TE_TELEPORT")), "\n");
1128 db_put(d, "TE_LAVASPLASH", "1"); print("effect TE_LAVASPLASH is ", ftos(particleeffectnum("TE_LAVASPLASH")), "\n");
1129 db_put(d, "TE_SMALLFLASH", "1"); print("effect TE_SMALLFLASH is ", ftos(particleeffectnum("TE_SMALLFLASH")), "\n");
1130 db_put(d, "TE_FLAMEJET", "1"); print("effect TE_FLAMEJET is ", ftos(particleeffectnum("TE_FLAMEJET")), "\n");
1131 db_put(d, "EF_FLAME", "1"); print("effect EF_FLAME is ", ftos(particleeffectnum("EF_FLAME")), "\n");
1132 db_put(d, "TE_BLOOD", "1"); print("effect TE_BLOOD is ", ftos(particleeffectnum("TE_BLOOD")), "\n");
1133 db_put(d, "TE_SPARK", "1"); print("effect TE_SPARK is ", ftos(particleeffectnum("TE_SPARK")), "\n");
1134 db_put(d, "TE_PLASMABURN", "1"); print("effect TE_PLASMABURN is ", ftos(particleeffectnum("TE_PLASMABURN")), "\n");
1135 db_put(d, "TE_TEI_G3", "1"); print("effect TE_TEI_G3 is ", ftos(particleeffectnum("TE_TEI_G3")), "\n");
1136 db_put(d, "TE_TEI_SMOKE", "1"); print("effect TE_TEI_SMOKE is ", ftos(particleeffectnum("TE_TEI_SMOKE")), "\n");
1137 db_put(d, "TE_TEI_BIGEXPLOSION", "1"); print("effect TE_TEI_BIGEXPLOSION is ", ftos(particleeffectnum("TE_TEI_BIGEXPLOSION")), "\n");
1138 db_put(d, "TE_TEI_PLASMAHIT", "1"); print("effect TE_TEI_PLASMAHIT is ", ftos(particleeffectnum("TE_TEI_PLASMAHIT")), "\n");
1139 db_put(d, "EF_STARDUST", "1"); print("effect EF_STARDUST is ", ftos(particleeffectnum("EF_STARDUST")), "\n");
1140 db_put(d, "TR_ROCKET", "1"); print("effect TR_ROCKET is ", ftos(particleeffectnum("TR_ROCKET")), "\n");
1141 db_put(d, "TR_GRENADE", "1"); print("effect TR_GRENADE is ", ftos(particleeffectnum("TR_GRENADE")), "\n");
1142 db_put(d, "TR_BLOOD", "1"); print("effect TR_BLOOD is ", ftos(particleeffectnum("TR_BLOOD")), "\n");
1143 db_put(d, "TR_WIZSPIKE", "1"); print("effect TR_WIZSPIKE is ", ftos(particleeffectnum("TR_WIZSPIKE")), "\n");
1144 db_put(d, "TR_SLIGHTBLOOD", "1"); print("effect TR_SLIGHTBLOOD is ", ftos(particleeffectnum("TR_SLIGHTBLOOD")), "\n");
1145 db_put(d, "TR_KNIGHTSPIKE", "1"); print("effect TR_KNIGHTSPIKE is ", ftos(particleeffectnum("TR_KNIGHTSPIKE")), "\n");
1146 db_put(d, "TR_VORESPIKE", "1"); print("effect TR_VORESPIKE is ", ftos(particleeffectnum("TR_VORESPIKE")), "\n");
1147 db_put(d, "TR_NEHAHRASMOKE", "1"); print("effect TR_NEHAHRASMOKE is ", ftos(particleeffectnum("TR_NEHAHRASMOKE")), "\n");
1148 db_put(d, "TR_NEXUIZPLASMA", "1"); print("effect TR_NEXUIZPLASMA is ", ftos(particleeffectnum("TR_NEXUIZPLASMA")), "\n");
1149 db_put(d, "TR_GLOWTRAIL", "1"); print("effect TR_GLOWTRAIL is ", ftos(particleeffectnum("TR_GLOWTRAIL")), "\n");
1150 db_put(d, "TR_SEEKER", "1"); print("effect TR_SEEKER is ", ftos(particleeffectnum("TR_SEEKER")), "\n");
1151 db_put(d, "SVC_PARTICLE", "1"); print("effect SVC_PARTICLE is ", ftos(particleeffectnum("SVC_PARTICLE")), "\n");
1153 fh = fopen("effectinfo.txt", FILE_READ);
1154 while((s = fgets(fh)))
1156 tokenize(s); // tokenize_console would hit the loop counter :(
1157 if(argv(0) == "effect")
1159 if(db_get(d, argv(1)) != "1")
1161 if(particleeffectnum(argv(1)) >= 0)
1162 print("effect ", argv(1), " is ", ftos(particleeffectnum(argv(1))), "\n");
1163 db_put(d, argv(1), "1");
1167 print("end of effects list\n");
1173 case GC_REQUEST_USAGE:
1174 print("\nUsage:^3 sv_cmd effectindexdump\n");
1175 print(" No arguments required.\n");
1180 void GameCommand_extendmatchtime(float request) // todo: Perhaps allows the user to send a specific time to extend it.
1184 case GC_REQUEST_HELP:
1185 print(" ^2extendmatchtime^7: Increase the timelimit value incrementally\n");
1188 case GC_REQUEST_COMMAND:
1189 changematchtime(autocvar_timelimit_increment* 60, autocvar_timelimit_min*60, autocvar_timelimit_max*60);
1193 case GC_REQUEST_USAGE:
1194 print("\nUsage:^3 sv_cmd extendmatchtime\n");
1195 print(" No arguments required.\n");
1196 print("See also: ^2reducematchtime^7\n");
1201 void GameCommand_find(float request, float argc)
1207 case GC_REQUEST_HELP:
1208 print(" ^2find^7: Search through entities for matching classname\n");
1211 case GC_REQUEST_COMMAND:
1212 for(client = world; (client = find(client, classname, argv(1))); )
1213 print(etos(client), "\n");
1217 print("Incorrect parameters for \"find\"\n");
1218 case GC_REQUEST_USAGE:
1219 print("\nUsage:^3 sv_cmd find classname\n");
1220 print(" Where 'classname' is the classname to search for.\n");
1225 void GameCommand_gametype(float request, float argc)
1228 float t = MapInfo_Type_FromString(s), tsave = MapInfo_CurrentGametype();
1232 case GC_REQUEST_HELP:
1233 print(" ^2gametype^7: Simple command to change the active gametype\n");
1236 case GC_REQUEST_COMMAND:
1239 MapInfo_SwitchGameType(t);
1240 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
1241 if(MapInfo_count > 0)
1242 bprint("Game type successfully switched to ", s, "\n");
1245 bprint("Cannot use this game type: no map for it found\n");
1246 MapInfo_SwitchGameType(tsave);
1247 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
1251 bprint("Game type switch to ", s, " failed: this type does not exist!\n");
1255 print("Incorrect parameters for \"gametype\"\n");
1256 case GC_REQUEST_USAGE:
1257 print("\nUsage:^3 sv_cmd gametype mode\n");
1258 print(" Where 'mode' is the gametype mode to switch to.\n");
1259 print("See also: ^2gotomap^7\n");
1264 void GameCommand_gettaginfo(float request, float argc) // UNTESTED // todo: finish usage description for it (but, must first learn this shit)
1272 case GC_REQUEST_HELP:
1273 print(" ^2gettaginfo^7: Get specific information about a weapon model\n");
1276 case GC_REQUEST_COMMAND:
1279 tmp_entity = spawn();
1281 setmodel(tmp_entity, (nextent(world)).weaponentity.model);
1284 precache_model(argv(1));
1285 setmodel(tmp_entity, argv(1));
1287 tmp_entity.frame = stof(argv(2));
1288 if(substring(argv(3), 0, 1) == "#")
1289 i = stof(substring(argv(3), 1, -1));
1291 i = gettagindex(tmp_entity, argv(3));
1294 v = gettaginfo(tmp_entity, i);
1295 print("model ", tmp_entity.model, " frame ", ftos(tmp_entity.frame), " tag ", gettaginfo_name);
1296 print(" index ", ftos(i), " parent ", ftos(gettaginfo_parent), "\n");
1297 print(" vector = ", ftos(v_x), " ", ftos(v_y), " ", ftos(v_z), "\n");
1298 print(" offset = ", ftos(gettaginfo_offset_x), " ", ftos(gettaginfo_offset_y), " ", ftos(gettaginfo_offset_z), "\n");
1299 print(" forward = ", ftos(gettaginfo_forward_x), " ", ftos(gettaginfo_forward_y), " ", ftos(gettaginfo_forward_z), "\n");
1300 print(" right = ", ftos(gettaginfo_right_x), " ", ftos(gettaginfo_right_y), " ", ftos(gettaginfo_right_z), "\n");
1301 print(" up = ", ftos(gettaginfo_up_x), " ", ftos(gettaginfo_up_y), " ", ftos(gettaginfo_up_z), "\n");
1305 localcmd(strcat(argv(4), vtos(v), argv(5), "\n"));
1309 print("bone not found\n");
1316 print("Incorrect parameters for \"gettaginfo\"\n");
1317 case GC_REQUEST_USAGE:
1318 print("\nUsage:^3 sv_cmd gettaginfo\n");
1319 print(" FIXME: Arguments currently unknown\n");
1320 print("See also: ^2bbox^7\n");
1325 void GameCommand_gotomap(float request, float argc)
1329 case GC_REQUEST_HELP:
1330 print(" ^2gotomap^7: Simple command to switch to another map\n");
1333 case GC_REQUEST_COMMAND:
1336 print(GotoMap(argv(1)), "\n");
1341 print("Incorrect parameters for \"gotomap\"\n");
1342 case GC_REQUEST_USAGE:
1343 print("\nUsage:^3 sv_cmd gotomap map\n");
1344 print(" Where 'map' is the *.bsp file to change to.\n");
1345 print("See also: ^2gametype^7\n");
1350 void GameCommand_ladder(float request)
1354 case GC_REQUEST_HELP:
1355 print(" ^2ladder^7: Get information about top players if supported\n");
1358 case GC_REQUEST_COMMAND:
1359 print(ladder_reply);
1363 case GC_REQUEST_USAGE:
1364 print("\nUsage:^3 sv_cmd ladder\n");
1365 print(" No arguments required.\n");
1370 void GameCommand_lockteams(float request)
1374 case GC_REQUEST_HELP:
1375 print(" ^2lockteams^7: Disable the ability for players to switch or enter teams\n");
1378 case GC_REQUEST_COMMAND:
1382 bprint("^1The teams are now locked.\n");
1385 bprint("That command can only be used in a team-based gamemode.\n");
1389 case GC_REQUEST_USAGE:
1390 print("\nUsage:^3 sv_cmd lockteams\n");
1391 print(" No arguments required.\n");
1392 print("See also: ^2unlockteams^7\n");
1397 void GameCommand_make_mapinfo(float request) // UNTESTED
1403 case GC_REQUEST_HELP:
1404 print(" ^2make_mapinfo^7: Automatically rebuild mapinfo files\n");
1407 case GC_REQUEST_COMMAND:
1408 tmp_entity = spawn();
1409 tmp_entity.classname = "make_mapinfo";
1410 tmp_entity.think = make_mapinfo_Think;
1411 tmp_entity.nextthink = time; // this sucks... todo: re-write this -- Use initializeentity later
1412 MapInfo_Enumerate();
1416 case GC_REQUEST_USAGE:
1417 print("\nUsage:^3 sv_cmd make_mapinfo\n");
1418 print(" No arguments required.\n");
1423 void GameCommand_modelbug(float request) // UNTESTED // is this even needed anymore?
1427 case GC_REQUEST_HELP:
1428 print(" ^2modelbug^7: foobar\n");
1431 case GC_REQUEST_COMMAND:
1436 case GC_REQUEST_USAGE:
1437 print("\nUsage:^3 sv_cmd modelbug\n");
1438 print(" No arguments required.\n");
1443 void GameCommand_moveplayer(float request, float argc)
1446 string targets = argv(1);
1447 string destination = argv(2);
1448 string notify = argv(3);
1450 argc = tokenizebyseparator(targets, ","); // re-use argc for the targets
1454 case GC_REQUEST_HELP:
1455 print(" ^2moveplayer^7: Change the team/status of a player\n");
1458 case GC_REQUEST_COMMAND:
1459 // lets see if the target(s) even actually exist.
1460 if((targets) && (destination))
1462 for(i = 0; i < argc; ++i)
1464 // Check to see if the player is a valid target
1465 if((stof(argv(i)) < 1) | (stof(argv(i)) > maxclients)) // player_id is out of range
1467 print(strcat("Player ", argv(i), " doesn't exist", (((i + 1) < argc) ? ", skipping to next player.\n" : ".\n")));
1470 client = edict_num(stof(argv(i)));
1471 if not(client.flags & FL_CLIENT) // player entity is not a client
1473 print(strcat("Player ", argv(i), " doesn't exist", (((i + 1) < argc) ? ", skipping to next player.\n" : ".\n")));
1477 // Where are we putting this player?
1478 if(destination == "spec" || destination == "spectator")
1480 if(client.classname != "spectator" && client.classname != "observer")
1483 PutObserverInServer();
1487 print("Player ", argv(i), " (", client.netname, ") is already spectating.\n");
1493 if(client.classname != "spectator" && client.classname != "observer")
1499 float save = client.team_forced;
1500 client.team_forced = 0;
1502 // find the team to move the player to
1503 team_color = ColourToNumber(destination);
1504 if(team_color == client.team) // already on the destination team
1506 // keep the forcing undone
1507 print("Player ", argv(i), " (", client.netname, ") is already on the ", ColoredTeamName(client.team), ".\n");
1510 else if(team_color == 0) // auto team
1512 team_color = NumberToTeamNumber(FindSmallestTeam(client, FALSE));
1516 CheckAllowedTeams(client);
1518 client.team_forced = save;
1520 // Check to see if the destination team is even available
1525 print("Sorry, can't move player to red team if it doesn't exist.\n");
1532 print("Sorry, can't move player to blue team if it doesn't exist.\n");
1539 print("Sorry, can't move player to yellow team if it doesn't exist.\n");
1546 print("Sorry, can't move player to pink team if it doesn't exist.\n");
1552 print("Sorry, can't move player here if team ", destination, " doesn't exist.\n");
1556 // If so, lets continue and finally move the player
1557 client.team_forced = 0;
1558 MoveToTeam(client, team_color, 6, stof(notify));
1559 print("Player ", argv(i), " (", client.netname, ") has been moved to the ", ColoredTeamName(team_color), ".\n");
1564 print("Can't change teams when currently not playing a team game.\n");
1570 print("Can't change teams if the player isn't in the game.\n"); // well technically we could, but should we allow that? :P
1575 print("No acceptable players given, aborting.\n");
1576 return; // still correct parameters so return to avoid usage print
1580 print("Incorrect parameters for \"moveplayer\"\n");
1581 case GC_REQUEST_USAGE:
1582 print("\nUsage:^3 sv_cmd moveplayer clientnumbers destination [notify]\n");
1583 print(" 'clientnumbers' is a list (separated by commas) of player entity ID's\n");
1584 print(" 'destination' is what to send the player to, be it team or spectating\n");
1585 print(" Full list of destinations here: \"spec, spectator, red, blue, yellow, pink, auto.\"\n");
1586 print(" 'notify' is whether or not to send messages notifying of the move. Detail below.\n");
1587 print(" 0 (00) automove centerprint, admin message; 1 (01) automove centerprint, no admin message\n");
1588 print(" 2 (10) no centerprint, admin message; 3 (11) no centerprint, no admin message\n");
1589 print("Examples: moveplayer 1,3,5 red 3\n");
1590 print(" moveplayer 2 spec \n");
1591 print("See also: ^2allspec^7\n");
1596 void GameCommand_nospectators(float request)
1600 case GC_REQUEST_HELP:
1601 print(" ^2nospectators^7: Automatically remove spectators from a match\n");
1604 case GC_REQUEST_COMMAND:
1605 blockSpectators = 1;
1607 FOR_EACH_CLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
1609 if(plr.classname == "spectator" || plr.classname == "observer")
1611 plr.spectatortime = time;
1612 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"));
1615 bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n"));
1619 case GC_REQUEST_USAGE:
1620 print("\nUsage:^3 sv_cmd nospectators\n");
1621 print(" No arguments required.\n");
1626 void GameCommand_onslaught_updatelinks(float request) // UNTESTED // should this be here? Perhaps some mutatorhook call instead....
1630 case GC_REQUEST_HELP:
1631 print(" ^2onslaught_updatelinks^7: Refresh link status for onslaught\n");
1634 case GC_REQUEST_COMMAND:
1635 onslaught_updatelinks();
1636 print("ONS links updated\n");
1640 case GC_REQUEST_USAGE:
1641 print("\nUsage:^3 sv_cmd onslaught_updatelinks\n");
1642 print(" No arguments required.\n");
1647 void GameCommand_playerdemo(float request, float argc) // UNTESTED
1655 case GC_REQUEST_HELP:
1656 print(" ^2playerdemo^7: Control the ability to save demos of players\n");
1659 case GC_REQUEST_COMMAND:
1660 if(argv(1) == "read")
1662 // TODO: Create a general command for looking this up, save a lot of space everywhere in this file
1663 entno = stof(argv(2));
1664 if((entno < 1) | (entno > maxclients)) {
1665 print("Player ", argv(2), " doesn't exist\n");
1668 client = edict_num(entno);
1669 if(clienttype(client) != CLIENTTYPE_BOT) {
1670 print("Player ", client.netname, " is not a bot\n");
1674 playerdemo_open_read(argv(3));
1677 else if(argv(1) == "write")
1679 entno = stof(argv(2));
1680 if((entno < 1) | (entno > maxclients)) {
1681 print("Player ", argv(2), " doesn't exist\n");
1684 client = edict_num(entno);
1686 playerdemo_open_write(argv(3));
1689 else if(argv(1) == "auto_read_and_write")
1693 cvar_set("bot_number", ftos(n));
1694 localcmd("wait; wait; wait\n");
1695 for(i = 0; i < n; ++i)
1696 localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", s, ftos(i+1), "\n");
1697 localcmd("sv_cmd playerdemo write 1 ", ftos(n+1), "\n");
1700 else if(argv(1) == "auto_read")
1704 cvar_set("bot_number", ftos(n));
1705 localcmd("wait; wait; wait\n");
1706 for(i = 0; i < n; ++i)
1707 localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", s, ftos(i+1), "\n");
1713 case GC_REQUEST_USAGE:
1714 print("\nUsage:^3 sv_cmd \n");
1715 print(" No arguments required.\n");
1716 print(" FIXME: Arguments currently unknown\n");
1721 void GameCommand_printstats(float request)
1725 case GC_REQUEST_HELP:
1726 print(" ^2printstats^7: foobar\n");
1729 case GC_REQUEST_COMMAND:
1731 print("stats dumped.\n");
1735 case GC_REQUEST_USAGE:
1736 print("\nUsage:^3 sv_cmd printstats\n");
1737 print(" No arguments required.\n");
1742 void GameCommand(string command)
1744 // ===== TODO list =====
1746 // Finish adding the rest of the commands
1748 // Add ifdef to stuffto so that is can only be used when the game code is compiled for it
1749 //(this way it's more obscure and harder to abuse on normal servers)
1751 float search_request_type;
1752 float argc = tokenize_console(command);
1754 if(argv(0) == "help")
1758 print("\nUsage:^3 sv_cmd COMMAND...^7, where possible commands are:\n");
1759 GameCommand_adminmsg(GC_REQUEST_HELP, 0);
1760 GameCommand_allready(GC_REQUEST_HELP);
1761 GameCommand_allspec(GC_REQUEST_HELP);
1762 GameCommand_anticheat(GC_REQUEST_HELP, 0);
1763 GameCommand_bbox(GC_REQUEST_HELP);
1764 GameCommand_bot_cmd(GC_REQUEST_HELP, 0);
1765 GameCommand_cointoss(GC_REQUEST_HELP);
1766 GameCommand_cvar_changes(GC_REQUEST_HELP);
1767 GameCommand_cvar_purechanges(GC_REQUEST_HELP);
1768 GameCommand_database(GC_REQUEST_HELP, 0);
1769 GameCommand_defer_clear(GC_REQUEST_HELP, 0);
1770 GameCommand_defer_clear_all(GC_REQUEST_HELP);
1771 GameCommand_delrec(GC_REQUEST_HELP, 0);
1772 GameCommand_effectindexdump(GC_REQUEST_HELP);
1773 GameCommand_extendmatchtime(GC_REQUEST_HELP);
1774 GameCommand_find(GC_REQUEST_HELP, 0);
1775 GameCommand_gametype(GC_REQUEST_HELP, 0);
1776 GameCommand_gettaginfo(GC_REQUEST_HELP, 0);
1777 GameCommand_gotomap(GC_REQUEST_HELP, 0);
1778 GameCommand_ladder(GC_REQUEST_HELP);
1779 GameCommand_lockteams(GC_REQUEST_HELP);
1780 GameCommand_make_mapinfo(GC_REQUEST_HELP);
1781 GameCommand_modelbug(GC_REQUEST_HELP);
1782 GameCommand_moveplayer(GC_REQUEST_HELP, 0);
1783 GameCommand_nospectators(GC_REQUEST_HELP);
1784 GameCommand_onslaught_updatelinks(GC_REQUEST_HELP);
1785 GameCommand_playerdemo(GC_REQUEST_HELP, 0);
1786 GameCommand_printstats(GC_REQUEST_HELP);
1787 GameCommand_Vote("help", world);
1788 GameCommand_Ban("help");
1789 GameCommand_Generic("help");
1790 print("For help about specific commands, type sv_cmd help COMMAND\n");
1794 search_request_type = GC_REQUEST_USAGE; // Instead of trying to call a command, we're going to see detailed information about it
1796 else if(GameCommand_Vote(command, world))
1798 return; // handled by server/vote.qc
1800 else if(GameCommand_Ban(command))
1802 return; // handled by server/ipban.qc
1804 else if(GameCommand_Generic(command))
1806 return; // handled by common/gamecommand.qc
1809 search_request_type = GC_REQUEST_COMMAND; // continue as usual and scan for normal commands
1811 switch( ((argv(0) == "help") ? argv(1) : argv(0)) ) // if first argument is help, then search for the second argument. Else, search for first.
1813 case "adminmsg": GameCommand_adminmsg(search_request_type, argc); break;
1814 case "allready": GameCommand_allready(search_request_type); break;
1815 case "allspec": GameCommand_allspec(search_request_type); break;
1816 case "anticheat": GameCommand_anticheat(search_request_type, argc); break;
1817 case "bbox": GameCommand_bbox(search_request_type); break;
1818 case "bot_cmd": GameCommand_bot_cmd(search_request_type, argc); break;
1819 case "cointoss": GameCommand_cointoss(search_request_type); break;
1820 case "cvar_changes": GameCommand_cvar_changes(search_request_type); break;
1821 case "cvar_purechanges": GameCommand_cvar_purechanges(search_request_type); break;
1822 case "database": GameCommand_database(search_request_type, argc); break;
1823 case "defer_clear": GameCommand_defer_clear(search_request_type, argc); break;
1824 case "defer_clear_all": GameCommand_defer_clear_all(search_request_type); break;
1825 case "delrec": GameCommand_delrec(search_request_type, argc); break;
1826 case "effectindexdump": GameCommand_effectindexdump(search_request_type); break;
1827 case "extendmatchtime": GameCommand_extendmatchtime(search_request_type); break;
1828 case "find": GameCommand_find(search_request_type, argc); break;
1829 case "gametype": GameCommand_gametype(search_request_type, argc); break;
1830 case "gettaginfo": GameCommand_gettaginfo(search_request_type, argc); break;
1831 case "gotomap": GameCommand_gotomap(search_request_type, argc); break;
1832 case "ladder": GameCommand_ladder(search_request_type); break;
1833 case "lockteams": GameCommand_lockteams(search_request_type); break;
1834 case "make_mapinfo": GameCommand_make_mapinfo(search_request_type); break;
1835 case "modelbug": GameCommand_modelbug(search_request_type); break;
1836 case "moveplayer": GameCommand_moveplayer(search_request_type, argc); break;
1837 case "nospectators": GameCommand_nospectators(search_request_type); break;
1838 case "onslaught_updatelinks": GameCommand_onslaught_updatelinks(search_request_type); break;
1839 case "playerdemo": GameCommand_playerdemo(search_request_type, argc); break;
1840 case "printstats": GameCommand_printstats(search_request_type); break;
1841 //case "radarmap": GameCommand_radarmap(search_request_type); break; // TODO: handled in server/radarmap.qc
1844 print("Invalid command. For a list of supported commands, try sv_cmd help.\n");