]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamecommand.qc
new command "gametype" to switch gametype, and notify server QC of it... for changing...
[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                 GameCommand_Ban("help");
35                 GameCommand_Generic("help");
36                 return;
37         }
38
39         if(GameCommand_Ban(command))
40                 return;
41
42         if(GameCommand_Generic(command))
43                 return;
44
45         if(argv(0) == "teamstatus")
46         {
47                 PrintScoreboard(world);
48                 return;
49         }
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;
84                 string s;
85                 s = argv(1);
86                 t = MapInfo_Type_FromString(s);
87                 if(t)
88                 {
89                         MapInfo_SwitchGameType(t);
90                         MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0);
91                         bprint("Game type successfully switched to ", s, "\n");
92                 }
93                 else
94                         bprint("Game type switch to ", s, " failed: this type does not exist!\n");
95                 return;
96         }
97 #endif
98
99         if(argv(0) == "adminmsg") if(argc == 3)
100         {
101                 entity client;
102                 float entno;
103                 entno = stof(argv(1));
104                 for(client = world; entno > 0; --entno, client = nextent(client))
105                         ;
106                 if(client.flags & FL_CLIENT)
107                 {
108                         centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3SERVER ADMIN:\n\n^7", argv(2)));
109                         sprint(client, strcat("\{1}\{13}^3SERVER ADMIN^7: ", argv(2), "\n"));
110                         print("Message sent to ", client.netname, "\n");
111                 }
112                 else
113                         print("Client not found\n");
114                 return;
115         }
116
117         if(argv(0) == "savedb") if(argc == 2)
118         {
119                 db_save(ServerProgsDB, argv(1));
120                 print("DB saved.\n");
121                 return;
122         }
123
124         if(argv(0) == "dumpdb") if(argc == 2)
125         {
126                 db_dump(ServerProgsDB, argv(1));
127                 print("DB dumped.\n");
128                 return;
129         }
130
131         if(argv(0) == "loaddb") if(argc == 2)
132         {
133                 db_close(ServerProgsDB);
134                 ServerProgsDB = db_load(argv(1));
135                 print("DB loaded.\n");
136                 return;
137         }
138
139         print("Invalid command. For a list of supported commands, try sv_cmd help.\n");
140 }
141