Garry's Mod Wiki


  duplicator.RegisterEntityClass( string name, function function, vararg args )


This allows you to specify a specific function to be run when your SENT is pasted with the duplicator, instead of relying on the generic automatic functions.

Automatically calls duplicator.Allow for the entity class.


1 string name
The ClassName of the entity you wish to register a factory for
2 function function
The factory function you want to have called. It should have the arguments (Player, ...) where ... is whatever arguments you request to be passed. It also should return the entity created, otherwise duplicator.Paste result will not include it!
3 vararg args
Strings of the names of arguments you want passed to function the from the EntityCopyData structure. As a special case, "Data" will pass the whole structure.


Prints the datatable and then lets the duplicator do it's job

duplicator.RegisterEntityClass("prop_physics", function(ply, data) PrintTable(data) return duplicator.GenericDuplicatorFunction(ply, data) end, "Data")
Skin = 0 Mins = -14.357550 -14.390250 -25.934851 Flex: ColGroup = 0 Pos = -292.415070 -157.575043 -12262.056641 PhysicsObjects: 0: Frozen = false Pos = 13.750092 0.490356 -4.675781 Angle = 0.057 87.808 -0.031 Class = prop_physics FlexScale = 1 Maxs = 14.438149 14.405550 25.995348 Model = models/props_borealis/bluebarrel001.mdl Angle = 0.057 134.318 -0.031