Garry's Mod Wiki

Revision Difference

Global.ClientsideModel#529387

<function name="ClientsideModel" parent="Global" type="libraryfunc"> <description> Creates a non physical entity that only exists on the client. See also <page>ents.CreateClientProp</page>. <bug issue="861">Parented clientside models will become detached if the parent entity leaves the PVS.</bug>⤶ <bug issue="1387">Clientside entities are not garbage-collected, thus you must store a reference to the object and call <page>CSEnt:Remove</page> manually.</bug>⤶ <bug issue="861">Parented clientside models will become detached if the parent entity leaves the PVS. **A workaround is available on its github page.**</bug>⤶ <bug issue="1387">Clientside entities are not garbage-collected, thus you must store a reference to the object and call <page>CSEnt:Remove</page> manually. **To workaround this bug, you need to hold a reference (in a variable) to the entity and remove it when necessary.**</bug>⤶ <bug issue="3184">Clientside models will occasionally delete themselves during high server lag.</bug> </description> <realm>Client</realm> <args> <arg name="model" type="string">The file path to the model. <warning>Model must be precached with <page>util.PrecacheModel</page> on the server before usage.</warning></arg> <arg name="renderGroup" type="number" default="RENDERGROUP_OTHER">The render group of the entity for the clientside leaf system, see <page>Enums/RENDERGROUP</page>.</arg> </args> <rets> <ret name="" type="CSEnt">Created client-side model. ( C_BaseFlex )</ret> <ret name="" type="CSEnt">Created client-side model (`C_BaseFlex`).</ret> </rets> </function> ⤶ ⤶ <example>⤶ ⤶ <example>⤶ <description>Creates a clientside entity where the player is looking.</description> <code> concommand.Add( "test_csent", function( ply )⤶ local plyTr = ply:GetEyeTrace() csEnt = ClientsideModel( "models/props_c17/oildrum001_explosive.mdl" ) csEnt:SetPos( plyTr.HitPos + plyTr.HitNormal * 24 ) csEnt:Spawn() end ) local entity⤶ ⤶ concommand.Add( "test_csent", function( ply ) local trace = ply:GetEyeTrace() ⤶ entity = ClientsideModel( "models/props_c17/oildrum001_explosive.mdl" ) entity:SetPos( trace.HitPos + trace.HitNormal * 24 ) entity:Spawn() ⤶ end )⤶ </code> </example>