]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamecommand.qc
document weapon impulse order; load weapon priority from client
[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         entity client;
22         float entno;
23         argc = tokenize(command);
24
25         if(argv(0) == "help" || argc == 0)
26         {
27                 print("Usage: sv_cmd COMMAND..., where possible commands are:\n");
28                 print("  adminmsg clientnumber \"message\"\n");
29                 print("  teamstatus\n");
30                 print("  printstats\n");
31                 print("  make_mapinfo\n");
32                 print("  gametype dm|ctf|...\n");
33                 print("  savedb filename\n");
34                 print("  dumpdb filename\n");
35                 print("  loaddb filename\n");
36                 GameCommand_Vote("help", world);
37                 GameCommand_Ban("help");
38                 GameCommand_Generic("help");
39                 return;
40         }
41
42         if(GameCommand_Vote(command, world))
43                 return;
44
45         if(GameCommand_Ban(command))
46                 return;
47
48         if(GameCommand_Generic(command))
49                 return;
50
51         if(argv(0) == "printstats")
52         {
53                 DumpStats(FALSE);
54                 return;
55         }
56
57         if(argv(0) == "make_mapinfo")
58         {
59                 entity e;
60                 e = spawn();
61                 e.classname = "make_mapinfo";
62                 e.think = make_mapinfo_Think;
63                 e.nextthink = time;
64                 MapInfo_Enumerate();
65                 return;
66         }
67
68         if(argv(0) == "warp") if(argc == 2) if(cvar("g_campaign"))
69         {
70                 CampaignLevelWarp(stof(argv(1)));
71                 return;
72         }
73
74         if(argv(0) == "gotomap") if(argc == 2)
75         {
76                 print(GotoMap(argv(1)), "\n");
77                 return;
78         }
79
80         if(argv(0) == "gametype") if(argc == 2)
81         {
82                 float t, tsave;
83                 string s;
84                 s = argv(1);
85                 t = MapInfo_Type_FromString(s);
86                 tsave = MapInfo_CurrentGametype();
87                 if(t)
88                 {
89                         MapInfo_SwitchGameType(t);
90                         MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0);
91                         if(MapInfo_count > 0)
92                         {
93                                 bprint("Game type successfully switched to ", s, "\n");
94                         }
95                         else
96                         {
97                                 bprint("Cannot use this game type: no map for it found\n");
98                                 MapInfo_SwitchGameType(tsave);
99                                 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0);
100                         }
101                 }
102                 else
103                         bprint("Game type switch to ", s, " failed: this type does not exist!\n");
104                 return;
105         }
106
107         if(argv(0) == "adminmsg") if(argc == 3)
108         {
109                 entno = stof(argv(1));
110                 client = world;
111                 if(entno <= maxclients)
112                         client = edict_num(entno);
113                 if(client.flags & FL_CLIENT)
114                 {
115                         centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3SERVER ADMIN:\n\n^7", argv(2)));
116                         sprint(client, strcat("\{1}\{13}^3SERVER ADMIN^7: ", argv(2), "\n"));
117                         print("Message sent to ", client.netname, "\n");
118                 }
119                 else
120                         print("Client not found\n");
121                 return;
122         }
123
124         if(argv(0) == "savedb") if(argc == 2)
125         {
126                 db_save(ServerProgsDB, argv(1));
127                 print("DB saved.\n");
128                 return;
129         }
130
131         if(argv(0) == "dumpdb") if(argc == 2)
132         {
133                 db_dump(ServerProgsDB, argv(1));
134                 print("DB dumped.\n");
135                 return;
136         }
137
138         if(argv(0) == "loaddb") if(argc == 2)
139         {
140                 db_close(ServerProgsDB);
141                 ServerProgsDB = db_load(argv(1));
142                 print("DB loaded.\n");
143                 return;
144         }
145         if (argv(0) == "nospectators")
146         {
147                 blockSpectators = 1;
148                 local entity plr;
149                 FOR_EACH_CLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
150                 {
151                         if(plr.classname == "spectator" || plr.classname == "observer")
152                         {
153                                 plr.spectatortime = time;
154                                 sprint(plr, strcat("^7You have to become a player within the next ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
155                         }
156                 }
157                 bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds!\n"));
158                 return;
159         }
160         if (argv(0) == "lockteams")
161         {
162                 if(teamplay)
163                 {
164                         lockteams = 1;
165                         bprint("^1The teams are now locked.\n");
166                 }
167                 else
168                         bprint("That command can only be used in a team-based gamemode.\n");
169                 return;
170         }
171         if (argv(0) == "unlockteams")
172         {
173                 if(teamplay)
174                 {
175                         lockteams = 0;
176                         bprint("^1The teams are now unlocked.\n");
177                 }
178                 else
179                         bprint("That command can only be used in a team-based gamemode.\n");
180                 return;
181         }
182         if (argv(0) == "movetoteam") if(argc == 3)
183         {
184                 entno = stof(argv(1));
185                 client = world;
186                 if(entno <= maxclients)
187                         client = edict_num(entno);
188                 if(client.flags & FL_CLIENT)
189                 {
190                         float lt;
191                         lt = lockteams;
192                         lockteams = 0;
193
194                         self = client;
195                         SV_ParseClientCommand(strcat("selectteam ", argv(2)));
196
197                         lockteams = lt;
198                 }
199                 else
200                         print("Client not found\n");
201                 return;
202         }
203         if (argv(0) == "teamstatus")
204         {
205                 Score_NicePrint(world);
206                 return;
207         }
208         if (argv(0) == "allready")
209         {
210                 ReadyRestart();
211                 return;
212         }
213
214         print("Invalid command. For a list of supported commands, try sv_cmd help.\n");
215 }
216