]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamecommand.qc
handle self/oself CORRECTLY this time
[divverent/nexuiz.git] / data / qcsrc / server / gamecommand.qc
1 string GotoMap(string m);
2
3 void make_mapinfo_Think()
4 {
5         if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 1))
6         {
7                 print("Done rebuiling mapinfos.\n");
8                 remove(self);
9         }
10         else
11         {
12                 self.think = make_mapinfo_Think;
13                 self.nextthink = time;
14         }
15 }
16
17 void GameCommand(string command)
18 {
19         float argc;
20         argc = tokenize(command);
21
22         if(argv(0) == "help" || argc == 0)
23         {
24                 print("Usage: sv_cmd COMMAND..., where possible commands are:\n");
25                 print("  adminmsg clientnumber \"message\"\n");
26                 print("  teamstatus\n");
27                 print("  printstats\n");
28                 print("  make_mapinfo\n");
29                 GameCommand_Ban("help");
30                 GameCommand_Generic("help");
31                 return;
32         }
33
34         if(GameCommand_Ban(command))
35                 return;
36
37         if(GameCommand_Generic(command))
38                 return;
39
40         if(argv(0) == "teamstatus")
41         {
42                 PrintScoreboard(world);
43                 return;
44         }
45
46         if(argv(0) == "printstats")
47         {
48                 DumpStats(FALSE);
49                 return;
50         }
51
52         if(argv(0) == "make_mapinfo")
53         {
54                 entity e;
55                 e = spawn();
56                 e.classname = "make_mapinfo";
57                 e.think = make_mapinfo_Think;
58                 e.nextthink = time;
59                 MapInfo_Enumerate();
60                 return;
61         }
62
63         if(argv(0) == "warp") if(argc == 2) if(cvar("g_campaign"))
64         {
65                 CampaignLevelWarp(stof(argv(1)));
66                 return;
67         }
68
69         if(argv(0) == "gotomap") if(argc == 2)
70         {
71                 print(GotoMap(argv(1)), "\n");
72                 return;
73         }
74
75         if(argv(0) == "adminmsg") if(argc == 3)
76         {
77                 entity client;
78                 float entno;
79                 entno = stof(argv(1));
80                 for(client = world; entno > 0; --entno, client = nextent(client))
81                         ;
82                 if(client.flags & FL_CLIENT)
83                 {
84                         centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3SERVER ADMIN:\n\n^7", argv(2)));
85                         sprint(client, strcat("\{1}\{13}^3SERVER ADMIN^7: ", argv(2), "\n"));
86                         print("Message sent to ", client.netname, "\n");
87                 }
88                 else
89                         print("Client not found\n");
90                 return;
91         }
92
93         print("Invalid command. For a list of supported commands, try sv_cmd help.\n");
94 }
95