]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamecommand.qc
added command "sv_cmd effectindexdump" to list the effect indexes of all effects
[divverent/nexuiz.git] / data / qcsrc / server / gamecommand.qc
1 string GotoMap(string m);
2
3 void EffectIndexDump()
4 {
5         float d;
6         float fh;
7         string s;
8
9         d = db_create();
10
11         print("begin of effects list\n");
12         db_put(d, "TE_GUNSHOT", "1"); print("effect TE_GUNSHOT is ", ftos(particleeffectnum("TE_GUNSHOT")), "\n");
13         db_put(d, "TE_GUNSHOTQUAD", "1"); print("effect TE_GUNSHOTQUAD is ", ftos(particleeffectnum("TE_GUNSHOTQUAD")), "\n");
14         db_put(d, "TE_SPIKE", "1"); print("effect TE_SPIKE is ", ftos(particleeffectnum("TE_SPIKE")), "\n");
15         db_put(d, "TE_SPIKEQUAD", "1"); print("effect TE_SPIKEQUAD is ", ftos(particleeffectnum("TE_SPIKEQUAD")), "\n");
16         db_put(d, "TE_SUPERSPIKE", "1"); print("effect TE_SUPERSPIKE is ", ftos(particleeffectnum("TE_SUPERSPIKE")), "\n");
17         db_put(d, "TE_SUPERSPIKEQUAD", "1"); print("effect TE_SUPERSPIKEQUAD is ", ftos(particleeffectnum("TE_SUPERSPIKEQUAD")), "\n");
18         db_put(d, "TE_WIZSPIKE", "1"); print("effect TE_WIZSPIKE is ", ftos(particleeffectnum("TE_WIZSPIKE")), "\n");
19         db_put(d, "TE_KNIGHTSPIKE", "1"); print("effect TE_KNIGHTSPIKE is ", ftos(particleeffectnum("TE_KNIGHTSPIKE")), "\n");
20         db_put(d, "TE_EXPLOSION", "1"); print("effect TE_EXPLOSION is ", ftos(particleeffectnum("TE_EXPLOSION")), "\n");
21         db_put(d, "TE_EXPLOSIONQUAD", "1"); print("effect TE_EXPLOSIONQUAD is ", ftos(particleeffectnum("TE_EXPLOSIONQUAD")), "\n");
22         db_put(d, "TE_TAREXPLOSION", "1"); print("effect TE_TAREXPLOSION is ", ftos(particleeffectnum("TE_TAREXPLOSION")), "\n");
23         db_put(d, "TE_TELEPORT", "1"); print("effect TE_TELEPORT is ", ftos(particleeffectnum("TE_TELEPORT")), "\n");
24         db_put(d, "TE_LAVASPLASH", "1"); print("effect TE_LAVASPLASH is ", ftos(particleeffectnum("TE_LAVASPLASH")), "\n");
25         db_put(d, "TE_SMALLFLASH", "1"); print("effect TE_SMALLFLASH is ", ftos(particleeffectnum("TE_SMALLFLASH")), "\n");
26         db_put(d, "TE_FLAMEJET", "1"); print("effect TE_FLAMEJET is ", ftos(particleeffectnum("TE_FLAMEJET")), "\n");
27         db_put(d, "EF_FLAME", "1"); print("effect EF_FLAME is ", ftos(particleeffectnum("EF_FLAME")), "\n");
28         db_put(d, "TE_BLOOD", "1"); print("effect TE_BLOOD is ", ftos(particleeffectnum("TE_BLOOD")), "\n");
29         db_put(d, "TE_SPARK", "1"); print("effect TE_SPARK is ", ftos(particleeffectnum("TE_SPARK")), "\n");
30         db_put(d, "TE_PLASMABURN", "1"); print("effect TE_PLASMABURN is ", ftos(particleeffectnum("TE_PLASMABURN")), "\n");
31         db_put(d, "TE_TEI_G3", "1"); print("effect TE_TEI_G3 is ", ftos(particleeffectnum("TE_TEI_G3")), "\n");
32         db_put(d, "TE_TEI_SMOKE", "1"); print("effect TE_TEI_SMOKE is ", ftos(particleeffectnum("TE_TEI_SMOKE")), "\n");
33         db_put(d, "TE_TEI_BIGEXPLOSION", "1"); print("effect TE_TEI_BIGEXPLOSION is ", ftos(particleeffectnum("TE_TEI_BIGEXPLOSION")), "\n");
34         db_put(d, "TE_TEI_PLASMAHIT", "1"); print("effect TE_TEI_PLASMAHIT is ", ftos(particleeffectnum("TE_TEI_PLASMAHIT")), "\n");
35         db_put(d, "EF_STARDUST", "1"); print("effect EF_STARDUST is ", ftos(particleeffectnum("EF_STARDUST")), "\n");
36         db_put(d, "TR_ROCKET", "1"); print("effect TR_ROCKET is ", ftos(particleeffectnum("TR_ROCKET")), "\n");
37         db_put(d, "TR_GRENADE", "1"); print("effect TR_GRENADE is ", ftos(particleeffectnum("TR_GRENADE")), "\n");
38         db_put(d, "TR_BLOOD", "1"); print("effect TR_BLOOD is ", ftos(particleeffectnum("TR_BLOOD")), "\n");
39         db_put(d, "TR_WIZSPIKE", "1"); print("effect TR_WIZSPIKE is ", ftos(particleeffectnum("TR_WIZSPIKE")), "\n");
40         db_put(d, "TR_SLIGHTBLOOD", "1"); print("effect TR_SLIGHTBLOOD is ", ftos(particleeffectnum("TR_SLIGHTBLOOD")), "\n");
41         db_put(d, "TR_KNIGHTSPIKE", "1"); print("effect TR_KNIGHTSPIKE is ", ftos(particleeffectnum("TR_KNIGHTSPIKE")), "\n");
42         db_put(d, "TR_VORESPIKE", "1"); print("effect TR_VORESPIKE is ", ftos(particleeffectnum("TR_VORESPIKE")), "\n");
43         db_put(d, "TR_NEHAHRASMOKE", "1"); print("effect TR_NEHAHRASMOKE is ", ftos(particleeffectnum("TR_NEHAHRASMOKE")), "\n");
44         db_put(d, "TR_NEXUIZPLASMA", "1"); print("effect TR_NEXUIZPLASMA is ", ftos(particleeffectnum("TR_NEXUIZPLASMA")), "\n");
45         db_put(d, "TR_GLOWTRAIL", "1"); print("effect TR_GLOWTRAIL is ", ftos(particleeffectnum("TR_GLOWTRAIL")), "\n");
46         db_put(d, "SVC_PARTICLE", "1"); print("effect SVC_PARTICLE is ", ftos(particleeffectnum("SVC_PARTICLE")), "\n");
47
48         fh = fopen("effectinfo.txt", FILE_READ);
49         while((s = fgets(fh)))
50         {
51                 tokenize(s);
52                 if(argv(0) == "effect")
53                 {
54                         if(db_get(d, argv(1)) != "1")
55                         {
56                                 if(particleeffectnum(argv(1)) >= 0)
57                                         print("effect ", argv(1), " is ", ftos(particleeffectnum(argv(1))), "\n");
58                                 db_put(d, argv(1), "1");
59                         }
60                 }
61         }
62         print("end of effects list\n");
63
64         db_close(d);
65 }
66
67 void make_mapinfo_Think()
68 {
69         if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 1))
70         {
71                 print("Done rebuiling mapinfos.\n");
72                 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0);
73                 remove(self);
74         }
75         else
76         {
77                 self.think = make_mapinfo_Think;
78                 self.nextthink = time;
79         }
80 }
81
82 void GameCommand(string command)
83 {
84         float argc;
85         entity client;
86         float entno;
87         argc = tokenize(command);
88
89         if(argv(0) == "help" || argc == 0)
90         {
91                 print("Usage: sv_cmd COMMAND..., where possible commands are:\n");
92                 print("  adminmsg clientnumber \"message\"\n");
93                 print("  teamstatus\n");
94                 print("  printstats\n");
95                 print("  make_mapinfo\n");
96                 print("  gametype dm|ctf|...\n");
97                 print("  savedb filename\n");
98                 print("  dumpdb filename\n");
99                 print("  loaddb filename\n");
100                 print("  allready\n");
101                 print("  effectindexdump\n");
102                 GameCommand_Vote("help", world);
103                 GameCommand_Ban("help");
104                 GameCommand_Generic("help");
105                 return;
106         }
107
108         if(GameCommand_Vote(command, world))
109                 return;
110
111         if(GameCommand_Ban(command))
112                 return;
113
114         if(GameCommand_Generic(command))
115                 return;
116
117         if(argv(0) == "printstats")
118         {
119                 DumpStats(FALSE);
120                 return;
121         }
122
123         if(argv(0) == "make_mapinfo")
124         {
125                 entity e;
126                 e = spawn();
127                 e.classname = "make_mapinfo";
128                 e.think = make_mapinfo_Think;
129                 e.nextthink = time;
130                 MapInfo_Enumerate();
131                 return;
132         }
133
134         if(argv(0) == "warp") if(argc == 2) if(cvar("g_campaign"))
135         {
136                 CampaignLevelWarp(stof(argv(1)));
137                 return;
138         }
139
140         if(argv(0) == "gotomap") if(argc == 2)
141         {
142                 print(GotoMap(argv(1)), "\n");
143                 return;
144         }
145
146         if(argv(0) == "gametype") if(argc == 2)
147         {
148                 float t, tsave;
149                 string s;
150                 s = argv(1);
151                 t = MapInfo_Type_FromString(s);
152                 tsave = MapInfo_CurrentGametype();
153                 if(t)
154                 {
155                         MapInfo_SwitchGameType(t);
156                         MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0);
157                         if(MapInfo_count > 0)
158                         {
159                                 bprint("Game type successfully switched to ", s, "\n");
160                         }
161                         else
162                         {
163                                 bprint("Cannot use this game type: no map for it found\n");
164                                 MapInfo_SwitchGameType(tsave);
165                                 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0);
166                         }
167                 }
168                 else
169                         bprint("Game type switch to ", s, " failed: this type does not exist!\n");
170                 return;
171         }
172
173         if(argv(0) == "adminmsg") if(argc == 3)
174         {
175                 entno = stof(argv(1));
176                 client = world;
177                 if(entno <= maxclients)
178                         client = edict_num(entno);
179                 if(client.flags & FL_CLIENT)
180                 {
181                         centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3SERVER ADMIN:\n\n^7", argv(2)));
182                         sprint(client, strcat("\{1}\{13}^3SERVER ADMIN^7: ", argv(2), "\n"));
183                         print("Message sent to ", client.netname, "\n");
184                 }
185                 else
186                         print("Client not found\n");
187                 return;
188         }
189
190         if(argv(0) == "savedb") if(argc == 2)
191         {
192                 db_save(ServerProgsDB, argv(1));
193                 print("DB saved.\n");
194                 return;
195         }
196
197         if(argv(0) == "dumpdb") if(argc == 2)
198         {
199                 db_dump(ServerProgsDB, argv(1));
200                 print("DB dumped.\n");
201                 return;
202         }
203
204         if(argv(0) == "loaddb") if(argc == 2)
205         {
206                 db_close(ServerProgsDB);
207                 ServerProgsDB = db_load(argv(1));
208                 print("DB loaded.\n");
209                 return;
210         }
211         if (argv(0) == "nospectators")
212         {
213                 blockSpectators = 1;
214                 local entity plr;
215                 FOR_EACH_CLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
216                 {
217                         if(plr.classname == "spectator" || plr.classname == "observer")
218                         {
219                                 plr.spectatortime = time;
220                                 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"));
221                         }
222                 }
223                 bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds!\n"));
224                 return;
225         }
226         if (argv(0) == "lockteams")
227         {
228                 if(teamplay)
229                 {
230                         lockteams = 1;
231                         bprint("^1The teams are now locked.\n");
232                 }
233                 else
234                         bprint("That command can only be used in a team-based gamemode.\n");
235                 return;
236         }
237         if (argv(0) == "unlockteams")
238         {
239                 if(teamplay)
240                 {
241                         lockteams = 0;
242                         bprint("^1The teams are now unlocked.\n");
243                 }
244                 else
245                         bprint("That command can only be used in a team-based gamemode.\n");
246                 return;
247         }
248         if (argv(0) == "movetoteam") if(argc == 3)
249         {
250                 entno = stof(argv(1));
251                 client = world;
252                 if(entno <= maxclients)
253                         client = edict_num(entno);
254                 if(client.flags & FL_CLIENT)
255                 {
256                         float lt;
257                         lt = lockteams;
258                         lockteams = 0;
259
260                         self = client;
261                         SV_ParseClientCommand(strcat("selectteam ", argv(2)));
262
263                         lockteams = lt;
264                 }
265                 else
266                         print("Client not found\n");
267                 return;
268         }
269         if (argv(0) == "teamstatus")
270         {
271                 Score_NicePrint(world);
272                 return;
273         }
274         if (argv(0) == "allready")
275         {
276                 ReadyRestart();
277                 return;
278         }
279         if (argv(0) == "effectindexdump")
280         {
281                 EffectIndexDump();
282                 return;
283         }
284
285         print("Invalid command. For a list of supported commands, try sv_cmd help.\n");
286 }
287