.string object_clipboard;
.entity object_attach;
+.float object_count;
.float material;
const float MATERIAL_NONE = 0;
{
if(head.owner == e)
{
- head.movetype = e.old_movetype; // revert to previous physics
+ head.movetype = head.old_movetype; // revert to previous physics
head.solid = SOLID_BBOX;
head.takedamage = DAMAGE_AIM;
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
// ---------------- 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");
{
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;
}
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);