]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamecommand.qc
particles: volume weighting = negative count, absolute weighting = positive count
[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 #ifdef MAPINFO
81         if(argv(0) == "gametype") if(argc == 2)
82         {
83                 float t, tsave;
84                 string s;
85                 s = argv(1);
86                 t = MapInfo_Type_FromString(s);
87                 tsave = MapInfo_CurrentGametype();
88                 if(t)
89                 {
90                         MapInfo_SwitchGameType(t);
91                         MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0);
92                         if(MapInfo_count > 0)
93                         {
94                                 bprint("Game type successfully switched to ", s, "\n");
95                         }
96                         else
97                         {
98                                 bprint("Cannot use this game type: no map for it found\n");
99                                 MapInfo_SwitchGameType(tsave);
100                                 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0);
101                         }
102                 }
103                 else
104                         bprint("Game type switch to ", s, " failed: this type does not exist!\n");
105                 return;
106         }
107 #endif
108
109         if(argv(0) == "adminmsg") if(argc == 3)
110         {
111                 entno = stof(argv(1));
112                 client = world;
113                 if(entno <= maxclients)
114                         client = edict_num(entno);
115                 if(client.flags & FL_CLIENT)
116                 {
117                         centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3SERVER ADMIN:\n\n^7", argv(2)));
118                         sprint(client, strcat("\{1}\{13}^3SERVER ADMIN^7: ", argv(2), "\n"));
119                         print("Message sent to ", client.netname, "\n");
120                 }
121                 else
122                         print("Client not found\n");
123                 return;
124         }
125
126         if(argv(0) == "savedb") if(argc == 2)
127         {
128                 db_save(ServerProgsDB, argv(1));
129                 print("DB saved.\n");
130                 return;
131         }
132
133         if(argv(0) == "dumpdb") if(argc == 2)
134         {
135                 db_dump(ServerProgsDB, argv(1));
136                 print("DB dumped.\n");
137                 return;
138         }
139
140         if(argv(0) == "loaddb") if(argc == 2)
141         {
142                 db_close(ServerProgsDB);
143                 ServerProgsDB = db_load(argv(1));
144                 print("DB loaded.\n");
145                 return;
146         }
147         if (argv(0) == "nospectators")
148         {
149                 blockSpectators = 1;
150                 local entity plr;
151                 FOR_EACH_CLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
152                 {
153                         if(plr.classname == "spectator" || plr.classname == "observer")
154                         {
155                                 plr.spectatortime = time;
156                                 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"));
157                         }
158                 }
159                 bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds!\n"));
160                 return;
161         }
162         if (argv(0) == "lockteams")
163         {
164                 if(teamplay)
165                 {
166                         lockteams = 1;
167                         bprint("^1The teams are now locked.\n");
168                 }
169                 else
170                         bprint("That command can only be used in a team-based gamemode.\n");
171                 return;
172         }
173         if (argv(0) == "unlockteams")
174         {
175                 if(teamplay)
176                 {
177                         lockteams = 0;
178                         bprint("^1The teams are now unlocked.\n");
179                 }
180                 else
181                         bprint("That command can only be used in a team-based gamemode.\n");
182                 return;
183         }
184         if (argv(0) == "movetoteam") if(argc == 3)
185         {
186                 entno = stof(argv(1));
187                 client = world;
188                 if(entno <= maxclients)
189                         client = edict_num(entno);
190                 if(client.flags & FL_CLIENT)
191                 {
192                         float lt;
193                         lt = lockteams;
194                         lockteams = 0;
195
196                         self = client;
197                         SV_ParseClientCommand(strcat("selectteam ", argv(2)));
198
199                         lockteams = lt;
200                 }
201                 else
202                         print("Client not found\n");
203                 return;
204         }
205         if (argv(0) == "teamstatus")
206         {
207                 Score_NicePrint(world);
208                 return;
209         }
210         if (argv(0) == "allready")
211         {
212                 ReadyRestart();
213                 return;
214         }
215
216         print("Invalid command. For a list of supported commands, try sv_cmd help.\n");
217 }
218