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