Sync

A fast entity based synchronous networking system

Functions

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)

SetLocalSyncVar(varID, value)

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)

  • value

    Value to set

Example Usage

ply:SetLocalSyncVar(SYNC_BANKMONEY, 600)

SetSyncVar(varID, value, instantSync)

View source »

Sets the Sync var on an entity

Parameters

  • varID int

    Sync variable (EG: SYNC_MONEY)

  • value

    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

SyncRemove()

View source »

Removes all SyncVar's from an entity and update all players

SyncRemoveVar(varID)

View source »

Removes a specific SyncVar from an entity and update all players

Parameters

  • varID int

    Sync variable

impulse.Sync.DoType(type, value)

Internal

This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.

View source »

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

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

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