Garry's Mod Wiki

Revision Difference

Entity:InitializeAsClientEntity#551305

<function name="InitializeAsClientEntity" parent="Entity" type="classfunc"> <description> <deprecated></deprecated> <warning>⤶ You should **NEVER** use this function! ⤶ This function should be removed! ⤶ ⤶ **These are the reasons why this function should never be used and removed:** ⤶ Calling this on **ANY**(even clientside only) entity will cause random crashes and it will crash the game as soon as the entity is removed! ⤶ ⤶ **Some bugs if you call it on a entity that is not clientside only:** ⤶ All NWVars break clientside for the given player. ⤶ The EntIndex becomes -1. ⤶ The <page text="Entity Table">Entity:GetTable</page> gets cleared every time this function is called. ⤶ ⤶ <note>⤶ As soon as the Entity re-enters the PVS some bugs will fix themself, but it will still crash the game if the entity gets removed!⤶ This is behavior only happens for entities, not for players!⤶ </note>⤶ ⤶ Calling this function on the World creates a permanent warning that will spam your console.⤶ ```lua⤶ ] lua_run_cl Entity(0):InitializeAsClientEntity()⤶ Refusing to render the map on an entity to prevent crashes! (x9330)⤶ ```⤶ Calling this function on an entity that is not **clientside only** causes all networking to break for that specific entity and an Engine Error will occur on a full update ⤶ (a full update can be forced with `cl_fullupdate`): ⤶ <upload src="b04e5/8db8f2ceed2528b.png" size="3320" name="image.png" />⤶ ⤶ Calling this function on a player causes a bunch of unexpected behavior and your game will crash as soon as the player is removed/leaves the server. ⤶ ⤶ **Some bugs if you set it on a player (all Entity bugs apply here):** ⤶ You get some values displayed in the top-left of your screen for some reason. ⤶ If you call this function on the local player, it causes your eye pos to be your position (EyePos == GetPos): ⤶ The Player name becomes `ERRORNAME` ⤶ As soon as the player re-enters the PVS, it crashes the game! ⤶ ```lua⤶ lua_run_cl LocalPlayer():InitializeAsClientEntity()⤶ ] lua_run_cl print(LocalPlayer())⤶ Player [-1][ERRORNAME]⤶ ```⤶ <upload src="b04e5/8db8f305bc00016.png" size="1506807" name="image.png" />⤶ </warning>⤶ Initializes this entity as being clientside only. Only works on entities fully created clientside, and as such it has currently no use due this being automatically called by <page>ents.CreateClientProp</page>, <page>ents.CreateClientside</page>, <page>Global.ClientsideModel</page> and <page>Global.ClientsideScene</page>. Only works on entities fully created clientside, and as such it has currently no use due to this being automatically called by <page>ents.CreateClientProp</page>, <page>ents.CreateClientside</page>, <page>Global.ClientsideModel</page> and <page>Global.ClientsideScene</page>. </description> <realm>Client</realm> </function>⤶ </function>