]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a maximum number of objects each player can place at a time. By default, players...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Thu, 27 Oct 2011 17:00:56 +0000 (20:00 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Thu, 27 Oct 2011 17:00:56 +0000 (20:00 +0300)
defaultXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/mutators/sandbox.qc

index adeb6d31b9838fa20a6cd1e74bca38dc1982a37a..db1766ae0696236818fd218d15af38b3f9826e83 100644 (file)
@@ -543,6 +543,7 @@ seta g_balance_cloaked_alpha 0.25
 
 set g_sandbox 0 "allow players to spawn and edit objects around the map"
 set g_sandbox_info 1 "print non-critical information to the server"
+set g_sandbox_maxplayerobjects 100 "maximum number of objects a player can have at a time"
 set g_sandbox_editor_distance_spawn 200 "distance at which objects spawn in front of the player"
 set g_sandbox_editor_distance_edit 350 "distance at which players can edit or remove objects they are looking at"
 set g_sandbox_object_scale_min 0.1 "minimum scale that objects can be set to"
index f764502b493c25f00e40aeafc11ce46f929d1f44..47a7bac291de8e75dba9d0d471fd3ab106dd10b3 100644 (file)
@@ -1200,6 +1200,7 @@ float autocvar_g_trueaim_minrange;
 float autocvar_g_debug_defaultsounds;
 float autocvar_g_loituma;
 float autocvar_g_sandbox_info;
+float autocvar_g_sandbox_maxplayerobjects;
 float autocvar_g_sandbox_editor_distance_spawn;
 float autocvar_g_sandbox_editor_distance_edit;
 float autocvar_g_sandbox_object_scale_min;
index 557e58f18126bebe38316e9d5643171759672e58..6a9a7ed5869c1774c486a7dbad13467429eb3db3 100644 (file)
@@ -1,5 +1,6 @@
 .string object_clipboard;
 .entity object_attach;
+.float object_count;
 .float material;
 
 const float MATERIAL_NONE = 0;
@@ -136,9 +137,19 @@ entity sandbox_SpawnObject()
        setorigin(e, trace_endpos);
        e.angles_y = self.v_angle_y;
 
+       self.object_count += 1;
+
        return e;
 }
 
+void sandbox_RemoveObject(entity e)
+{
+       remove(e);
+       e = world;
+
+       self.object_count -= 1;
+}
+
 string sandbox_Storage_Save(entity e)
 {
        // save object properties
@@ -250,7 +261,11 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
 
                        // ---------------- COMMAND: SPAWN OBJECT ----------------
                        case "spawn_object":
-                               // don't allow spawning objects without a model
+                               if(self.object_count >= autocvar_g_sandbox_maxplayerobjects)
+                               {
+                                       print_to(self, strcat("WARNING: Cannot spawn any more objects. Each player may have up to ^3", ftos(autocvar_g_sandbox_maxplayerobjects), " ^7objects at a time"));
+                                       return TRUE;
+                               }
                                if(cmd_argc < 3)
                                {
                                        print_to(self, "WARNING: Attempted to spawn an object without specifying a model. Please specify the path to your model file after the 'spawn_object' command");
@@ -277,8 +292,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                                {
                                        if(autocvar_g_sandbox_info)
                                                print(strcat(self.netname, " removed an object at origin ", vtos(e.origin), "\n"));
-                                       remove(e);
-                                       e = world;
+                                       sandbox_RemoveObject(e);
                                        return TRUE;
                                }
 
@@ -312,6 +326,11 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                                        print_to(self, "WARNING: No object in clipboard. You must copy an object before you can paste it");
                                        return TRUE;
                                }
+                               if(self.object_count >= autocvar_g_sandbox_maxplayerobjects)
+                               {
+                                       print_to(self, strcat("WARNING: Cannot spawn any more objects. Each player may have up to ^3", ftos(autocvar_g_sandbox_maxplayerobjects), " ^7objects at a time"));
+                                       return TRUE;
+                               }
 
                                e = sandbox_SpawnObject();
                                sandbox_Storage_Load(e, self.object_clipboard);