X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fsandbox.qc;h=4d2b961153961ddeb8c2b98a16124fc9812e8ad2;hb=73877c69be2a86e6234adacca67a9d3d6c25d2a8;hp=9c32f0ae5e133a3c9457dbffc7ecdd8b03c9b866;hpb=addbeb7e7f4c0ea3c7793937a8c7b9bd5f701b79;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index 9c32f0ae5..4d2b96115 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -1,4 +1,5 @@ .string clipboard_model; +.float clipboard_movetype; entity sandbox_EditObject() { @@ -49,34 +50,14 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand) if(argv(1) == "help") { print_to(self, "You can use the following sandbox commands:"); - print_to(self, "^7\"^2spawn_object ^3models/foo/bar.md3^7\" spawns a new object in front of the player, and gives it the specified model"); print_to(self, "^7\"^2spawn_item ^3item^7\" spawns the specified item in front of the player. Only weapons are currently supported"); + print_to(self, "^7\"^2spawn_object ^3models/foo/bar.md3^7\" spawns a new object in front of the player, and gives it the specified model"); print_to(self, "^7\"^2remove_object^7\" removes the object the player is looking at. Players can only remove their own objects"); + print_to(self, "^7\"^2duplicate_object_copy^7\" copies the object the player is looking at. Players can only copy their own objects"); + print_to(self, "^7\"^2duplicate_object_paste^7\" pastes the copied object in front of the player"); print_to(self, "^7The ^1drag object ^7key can be used to grab and carry objects. Players can only grab their own objects"); return TRUE; } - else if(argv(1) == "spawn_object") - { - // don't allow spawning objects without a model - 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"); - return TRUE; - } - else if not(fexists(argv(2))) - { - print_to(self, "WARNING: Attempted to spawn an object with a non-existent model. Make sure the path to your model file is correct"); - return TRUE; - } - - e = sandbox_SpawnObject(); - setmodel(e, argv(2)); - - if(autocvar_g_sandbox_info) - print(strcat(self.netname, " spawned an object at origin ", vtos(e.origin), "\n")); - - return TRUE; - } else if(argv(1) == "spawn_item") { // only weapons are currently supported @@ -107,6 +88,28 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand) print_to(self, "WARNING: Attempted to spawn an invalid or unsupported item. See 'sandbox help' for allowed items"); return TRUE; } + else if(argv(1) == "spawn_object") + { + // don't allow spawning objects without a model + 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"); + return TRUE; + } + else if not(fexists(argv(2))) + { + print_to(self, "WARNING: Attempted to spawn an object with a non-existent model. Make sure the path to your model file is correct"); + return TRUE; + } + + e = sandbox_SpawnObject(); + setmodel(e, argv(2)); + + if(autocvar_g_sandbox_info) + print(strcat(self.netname, " spawned an object at origin ", vtos(e.origin), "\n")); + + return TRUE; + } else if(argv(1) == "remove_object") { e = sandbox_EditObject(); @@ -122,29 +125,40 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand) print_to(self, "WARNING: Object could not be removed. Make sure you are facing an object that belongs to you"); return TRUE; } - else if(argv(1) == "duplicate_copy") + else if(argv(1) == "duplicate_object_copy") { - // copies the properties of the selected object to the clipboard + // copies customizable properties of the selected object to the clipboard e = sandbox_EditObject(); // you can only copy objects you can edit, so this works if(e != world) { // -------- COPY PROPERTIES -------- self.clipboard_model = e.model; + self.clipboard_movetype = e.movetype; // -------- COPY PROPERTIES -------- print_to(self, "Object copied to clipboard"); + return TRUE; } + + print_to(self, "WARNING: Object could not be copied. Make sure you are facing an object that belongs to you"); return TRUE; } - else if(argv(1) == "duplicate_paste") + else if(argv(1) == "duplicate_object_paste") { - // spawns an object with the properties in the player's clipboard + // spawns a new object using the properties in the player's clipboard + + if(self.clipboard_model == "") // no object in clipboard + { + print_to(self, "WARNING: No object in clipboard. You must copy an object before you can paste it"); + return TRUE; + } e = sandbox_SpawnObject(); // -------- PASTE PROPERTIES -------- setmodel(e, self.clipboard_model); + e.movetype = self.clipboard_movetype; // -------- PASTE PROPERTIES -------- print_to(self, "Object pasted");