Network.setClientData
Sets a lua object that will automatically be synchronized to clients.
Kind: Function
Environments: Game
Game
network:setClientData( data, channel )
Availability: Server only
Scripts which use this feature needs to implement 'client_onClientDataUpdate'.
'client_onClientDataUpdate' will be called on the client whenever the data has changed,
including setting the data for the first time.
Channel 1 will be received before channel 2 if both are updated.
-- Example:
function MyEngine.server_onCreate( self )
self.network:setClientData( { "gear" = 1 } )
end
function MyEngine.client_onClientDataUpdate( self, data, channel )
if channel == 1 then
self.interactable:setPoseWeight( 0, data.gear / self.maxGears )
end
end
Parameters:
| Name | Type | Description |
|---|---|---|
network |
Network | The network. |
data |
any | Persistent data to be synchronized with existing and new clients. |
channel (optional) |
integer | Client data channel, 1 to 4 (Optional) (Defaults to 1) |