Revision Difference
ENTITY:SetupDataTables#514457
<function name="SetupDataTables" parent="ENTITY" type="hook">⤶
<ishook>yes</ishook>⤶
<description>⤶
Called when the entity should set up its [ Data Tables](/gmod/Networking_Entities).⤶
⤶
This is a much better option than using Set/Get Networked Values.⤶
⤶
This hook is called after <page>GM:OnEntityCreated</page> and <page>GM:NetworkEntityCreated</page>.⤶
</description>⤶
<realm>Shared</realm>⤶
<predicted>No</predicted>⤶
</function>⤶
⤶
<example>⤶
<description>⤶
Sets up networked variables, adds functions SetAmount, GetAmount, GetBloodPos, SetBloodPos, GetUrinePos, SetUrinePos.⤶
⤶
This function only supports 64 data tables per type (#0-63), except for strings which only supports 4.⤶
</description>⤶
<code>⤶
function ENT:SetupDataTables()⤶
⤶
self:NetworkVar( "Float", 0, "Amount" )⤶
self:NetworkVar( "Vector", 0, "BloodPos" )⤶
self:NetworkVar( "Vector", 1, "UrinePos" )⤶
⤶
if SERVER then⤶
self:SetAmount( 3 )⤶
self:SetBloodPos( Vector( 0, -32, 0 ) )⤶
self:SetUrinePos( Vector( 0, 0, -16 ) )⤶
end⤶
⤶
end⤶
</code>⤶
⤶
</example>