]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/sandbox.qc
0e8303e1e197bed1cc5f03aff1e46412c38b899b
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / sandbox.qc
1 MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
2 {
3         if(MUTATOR_RETURNVALUE) // command was already handled?
4                 return 0;
5         if(cmd_name == "g_sandbox")
6         {
7                 if(cmd_argc < 2)
8                 {
9                         print_to(self, "Sandbox mode is active. For more information, use 'g_sandbox help'");
10                         return 1;
11                 }
12
13                 if(argv(1) == "help")
14                 {
15                         print_to(self, "You can use the following sandbox commands:");
16                         print_to(self, "^7\"^2spawn ^3models/foo/bar.md3^7\" spawns a new object in front of the player, and gives it the specified model");
17                         return 1;
18                 }
19                 else if(argv(1) == "spawn")
20                 {
21                         // spawn a new object with the default settings
22
23                         entity e;
24                         e = spawn();
25                         makevectors(self.v_angle);
26                         traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 250, MOVE_NOMONSTERS, self);
27                         setorigin(e, trace_endpos);
28                         setmodel(e, "models/vehicles-static/raptor.md3");
29
30                         if(autocvar_g_sandbox_info)
31                                 print(strcat(self.netname, " spawned an object at origin ", vtos(e.origin), "\n"));
32
33                         return 1;
34                 }
35         }
36         return 0;
37 }
38
39 MUTATOR_DEFINITION(sandbox)
40 {
41         MUTATOR_HOOK(SV_ParseClientCommand, sandbox_PlayerCommand, CBC_ORDER_ANY);
42
43         return 0;
44 }