ENTITY/SetupDataTables

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m
m (Warning called after OnEntityCreated & NetworkEntityCreated)
Line 3: Line 3:
  
 
This is a much better option than using Set/Get Networked Values.
 
This is a much better option than using Set/Get Networked Values.
 +
 +
{{Warning|This hook is called after {{HookFunction|GM|OnEntityCreated}} and {{HookFunction|GM|NetworkEntityCreated}}.}}
 
|Realm=Shared
 
|Realm=Shared
 
|Predicted=No
 
|Predicted=No

Revision as of 18:29, 2 September 2019

 ENTITY:SetupDataTables( )

Description

Called when the entity should set up its Data Tables.

This is a much better option than using Set/Get Networked Values.

WARNING

This hook is called after GM:OnEntityCreated and GM:NetworkEntityCreated.

Examples

Example

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.

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


Personal tools
Navigation