]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamecommand.qc
new command "dumpdb", makes a simpler format (easier to process) that can still be...
[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                 print("  savedb filename\n");
30                 print("  dumpdb filename\n");
31                 print("  loaddb filename\n");
32                 GameCommand_Ban("help");
33                 GameCommand_Generic("help");
34                 return;
35         }
36
37         if(GameCommand_Ban(command))
38                 return;
39
40         if(GameCommand_Generic(command))
41                 return;
42
43         if(argv(0) == "teamstatus")
44         {
45                 PrintScoreboard(world);
46                 return;
47         }
48
49         if(argv(0) == "printstats")
50         {
51                 DumpStats(FALSE);
52                 return;
53         }
54
55         if(argv(0) == "make_mapinfo")
56         {
57                 entity e;
58                 e = spawn();
59                 e.classname = "make_mapinfo";
60                 e.think = make_mapinfo_Think;
61                 e.nextthink = time;
62                 MapInfo_Enumerate();
63                 return;
64         }
65
66         if(argv(0) == "warp") if(argc == 2) if(cvar("g_campaign"))
67         {
68                 CampaignLevelWarp(stof(argv(1)));
69                 return;
70         }
71
72         if(argv(0) == "gotomap") if(argc == 2)
73         {
74                 print(GotoMap(argv(1)), "\n");
75                 return;
76         }
77
78         if(argv(0) == "adminmsg") if(argc == 3)
79         {
80                 entity client;
81                 float entno;
82                 entno = stof(argv(1));
83                 for(client = world; entno > 0; --entno, client = nextent(client))
84                         ;
85                 if(client.flags & FL_CLIENT)
86                 {
87                         centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3SERVER ADMIN:\n\n^7", argv(2)));
88                         sprint(client, strcat("\{1}\{13}^3SERVER ADMIN^7: ", argv(2), "\n"));
89                         print("Message sent to ", client.netname, "\n");
90                 }
91                 else
92                         print("Client not found\n");
93                 return;
94         }
95
96         if(argv(0) == "savedb") if(argc == 2)
97         {
98                 db_save(ServerProgsDB, argv(1));
99                 print("DB saved.\n");
100                 return;
101         }
102
103         if(argv(0) == "dumpdb") if(argc == 2)
104         {
105                 db_dump(ServerProgsDB, argv(1));
106                 print("DB dumped.\n");
107                 return;
108         }
109
110         if(argv(0) == "loaddb") if(argc == 2)
111         {
112                 db_close(ServerProgsDB);
113                 ServerProgsDB = db_load(argv(1));
114                 print("DB loaded.\n");
115                 return;
116         }
117
118         print("Invalid command. For a list of supported commands, try sv_cmd help.\n");
119 }
120