Garry's Mod Wiki

Revision Difference

Entity:SetNWEntity#548214

<function name="SetNWEntity" parent="Entity" type="classfunc"> <description> Sets a networked entity value on the entity. The value can then be accessed with <page>Entity:GetNWEntity</page> both from client and server. ⤶ <note>Running this function clientside will only set it for the client it is called on.</note>⤶ <warning>There's a 4096 slots Network limit. If you need more, consider using the <page>net</page> library or <page>Entity:SetNW2Entity</page>. You should also consider the fact that you have way too many variables. ⤶ This limit is shared among all entities, SetNW* and SetGlobal* functions and <page>util.AddNetworkString</page>. If you exceed the limit, you cannot create new variables, and you will get the following warning. ⤶ ```lua ⤶ Warning: Table networkstring is full, can't add [key]⤶ ```⤶ Existing variables will still get updated without the warning. You can check the limit by counting up until <page>util.NetworkIDToString</page> returns nil</warning> returns nil</warning>⤶ <note>Running this function clientside will only set it for the client it is called on.</note>⤶ </description> <realm>Shared</realm> <args> <arg name="key" type="string">The key to associate the value with</arg> <arg name="value" type="Entity">The value to set</arg> </args> </function> <example> <description>This will set the networked entity 'owner' on all clients to themselves.</description> <code> for i, ply in ipairs( player.GetAll() ) do ply:SetNWEntity( "owner", ply ) end </code> </example>