]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamecommand.qc
allow server admins to stop a running vote with 'sv_cmd vstop'.. not sure if it will...
[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                 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0);
9                 remove(self);
10         }
11         else
12         {
13                 self.think = make_mapinfo_Think;
14                 self.nextthink = time;
15         }
16 }
17
18 void GameCommand(string command)
19 {
20         float argc;
21         argc = tokenize(command);
22
23         if(argv(0) == "help" || argc == 0)
24         {
25                 print("Usage: sv_cmd COMMAND..., where possible commands are:\n");
26                 print("  adminmsg clientnumber \"message\"\n");
27                 print("  teamstatus\n");
28                 print("  printstats\n");
29                 print("  make_mapinfo\n");
30                 print("  gametype dm|ctf|...\n");
31                 print("  savedb filename\n");
32                 print("  dumpdb filename\n");
33                 print("  loaddb filename\n");
34                 print("  vstop\n");
35                 GameCommand_Ban("help");
36                 GameCommand_Generic("help");
37                 return;
38         }
39
40         if(GameCommand_Ban(command))
41                 return;
42
43         if(GameCommand_Generic(command))
44                 return;
45
46         if(argv(0) == "teamstatus")
47         {
48                 PrintScoreboard(world);
49                 return;
50         }
51
52         if(argv(0) == "printstats")
53         {
54                 DumpStats(FALSE);
55                 return;
56         }
57
58         if(argv(0) == "make_mapinfo")
59         {
60                 entity e;
61                 e = spawn();
62                 e.classname = "make_mapinfo";
63                 e.think = make_mapinfo_Think;
64                 e.nextthink = time;
65                 MapInfo_Enumerate();
66                 return;
67         }
68
69         if(argv(0) == "warp") if(argc == 2) if(cvar("g_campaign"))
70         {
71                 CampaignLevelWarp(stof(argv(1)));
72                 return;
73         }
74
75         if(argv(0) == "gotomap") if(argc == 2)
76         {
77                 print(GotoMap(argv(1)), "\n");
78                 return;
79         }
80
81 #ifdef MAPINFO
82         if(argv(0) == "gametype") if(argc == 2)
83         {
84                 float t, tsave;
85                 string s;
86                 s = argv(1);
87                 t = MapInfo_Type_FromString(s);
88                 tsave = MapInfo_CurrentGametype();
89                 if(t)
90                 {
91                         MapInfo_SwitchGameType(t);
92                         MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0);
93                         if(MapInfo_count > 0)
94                         {
95                                 bprint("Game type successfully switched to ", s, "\n");
96                         }
97                         else
98                         {
99                                 bprint("Cannot use this game type: no map for it found\n");
100                                 MapInfo_SwitchGameType(tsave);
101                                 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0);
102                         }
103                 }
104                 else
105                         bprint("Game type switch to ", s, " failed: this type does not exist!\n");
106                 return;
107         }
108 #endif
109
110         if(argv(0) == "adminmsg") if(argc == 3)
111         {
112                 entity client;
113                 float entno;
114                 entno = stof(argv(1));
115                 client = world;
116                 if(entno <= maxclients)
117                         client = edict_num(entno);
118                 if(client.flags & FL_CLIENT)
119                 {
120                         centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3SERVER ADMIN:\n\n^7", argv(2)));
121                         sprint(client, strcat("\{1}\{13}^3SERVER ADMIN^7: ", argv(2), "\n"));
122                         print("Message sent to ", client.netname, "\n");
123                 }
124                 else
125                         print("Client not found\n");
126                 return;
127         }
128
129         if(argv(0) == "savedb") if(argc == 2)
130         {
131                 db_save(ServerProgsDB, argv(1));
132                 print("DB saved.\n");
133                 return;
134         }
135
136         if(argv(0) == "dumpdb") if(argc == 2)
137         {
138                 db_dump(ServerProgsDB, argv(1));
139                 print("DB dumped.\n");
140                 return;
141         }
142
143         if(argv(0) == "loaddb") if(argc == 2)
144         {
145                 db_close(ServerProgsDB);
146                 ServerProgsDB = db_load(argv(1));
147                 print("DB loaded.\n");
148                 return;
149         }
150
151         if(argv(0) == "vstop")
152         {
153                 local entity temp;
154                 temp = spawn();
155                 temp.netname = (cvar_string("sv_adminnick") == "") ? cvar_string("hostname") : cvar_string("sv_adminnick");
156                 VoteStop(temp);
157                 remove(temp);
158                 return;
159         }
160
161         print("Invalid command. For a list of supported commands, try sv_cmd help.\n");
162 }
163