Garry's Mod Wiki

Revision Difference

Entity:InitializeAsClientEntity#551385

<function name="InitializeAsClientEntity" parent="Entity" type="classfunc"> <description> <deprecated> This function got disabled and will always throw an error if it's used. This is the error: ```lua⤶ ```⤶ [ERROR] InitializeAsClientEntity is deprecated and should no longer be used. ``` </deprecated> ⤶ <warning> ⤶ **These are the reasons why this function was disabled:** ⤶ 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 an 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 to 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 currently has 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>