Sync
A fast entity based synchronous networking system
Functions
Entity:GetSyncVar(varID, fallback)
View source »Gets the Sync variable on an entity
Parameters
-
varID
int
Sync variable (EG: SYNC_MONEY)
-
fallback
If we don't know the value we will fallback to this value
Returns
-
any
value
Example Usage
local xp = ply:GetSyncVar(SYNC_XP, 0)
Entity:SetSyncVar(varID, newValue, instantSync)
View source »Sets the Sync var on an entity
Parameters
-
varID
int
Sync variable (EG: SYNC_MONEY)
-
newValue
Value to set
-
instantSync
boolean
default: false
If we should network this to all players
Example Usage
ply:SetSyncVar(SYNC_XP, 60, true) -- sets money to 60 and networks the new value to all players
Entity:Sync(target)
View source »Sync will take the player and sync their all SyncVars with all clients or the single target if provided.
Parameters
-
target
Entity
default: true
Sync to a single target, if empty, syncs to all players.
Entity:SyncBudget()
View source »Sync's to only people nearby, use for unimportant data that's not always neccessary to transfer all the time.
Entity:SyncRemove()
View source »Removes all SyncVar's from an entity and update all players
Entity:SyncRemoveVar(varID)
View source »Removes a specific SyncVar from an entity and update all players
Parameters
-
varID
int
Sync variable
Entity:SyncSingle(varID, target)
View source »Syncs a single variable ID. target is optional. SyncSingle will take the player and sync the SyncVar provided with all clients or the single target if provided.
Parameters
-
varID
int
Sync var ID.
-
target
Entity
default: true
Sync to a single target, if empty, syncs to all players.
impulse.Sync.DoType(type, value)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Reads or writes a value based on the SyncType provided
Parameters
-
type
int
SyncType
-
value
impulse.Sync.RegisterVar(type, conditional)
View source »Registers a new Sync variable for usage. Must be called in the shared realm
Parameters
-
type
int
SyncType
-
conditional
boolean
default: false
Is conditional
Example Usage
SYNC_XP = impulse.Sync.RegisterVar(SYNC_INT)
See Also
Player:SetLocalSyncVar(varID, newValue)
View source »Sets the Sync var on an entity but only updates the player who it is being set on
Parameters
-
varID
int
Sync variable (EG: SYNC_MONEY)
-
newValue
Value to set
Example Usage
ply:SetLocalSyncVar(SYNC_BANKMONEY, 600)
Tables
SyncDefaults
View source »Default Sync variables
Fields
-
SYNC_RPNAME
-
SYNC_XP
-
SYNX_MONEY
-
SYNC_BANKMONEY
-
SYNC_WEPRAISED
-
SYNC_CLASS
-
SYNC_RANK
-
SYNC_ARRESTED
-
SYNC_HUNGER
-
SYNC_TYPING
-
SYNC_BROKENLEGS
-
SYNC_PROPCOUNT
-
SYNC_CRAFTLEVEL
-
SYNC_THROPHYPOINTS
-
SYNC_INCOGNITO
-
SYNC_GROUP_NAME
-
SYNC_GROUP_RANK
-
SYNC_COS_FACE
-
SYNC_COS_HEAD
-
SYNC_COS_CHEST
-
SYNC_DOOR_NAME
-
SYNC_DOOR_GROUP
-
SYNC_DOOR_BUYABLE
-
SYNC_DOOR_OWNERS
-
SYNC_TESTER
-
SYNC_EVENT_TEAM
-
SYNC_INFECTION
-
SYNC_INFECTION_STAGE
-
SYNC_BLEEDING
-
SYNC_ZONE
-
SYNC_EFFECT
SyncTypes
View source »Types of Sync variable
Fields
-
SYNC_BOOL
A boolean
-
SYNC_STRING
An ASCII string of any length
-
SYNC_INT
An unsigned 8 bit integer
-
SYNC_BIGINT
An unsigned 16 bit integer
-
SYNC_HUGEINT
An unsigned 32 bit integer
-
SYNC_MINITABLE
(Avoid using) A 32 bit compressed table
-
SYNC_INTSTACK
A collection of up to 255 8 bit unsigned integers