LogoLogo
  • Introduction
  • sdks
    • Feature Comparison
    • Unity
    • Godot
    • Defold
    • LÖVE
    • Unreal
  • Quick Start
    • Unity
    • Godot
    • Defold
    • LÖVE
    • Unreal
  • Server Side
    • Entities
    • Chunks
    • Dimensions
    • Events
    • Logging
    • Lua Environment
    • Git Primer
    • Physics
  • HTTP API
    • Authentication
    • Player API
  • Api Reference
    • Entity API
      • Create
      • Message
    • Client API
      • Message
    • Dimension API
      • Create
      • Delete
      • List
    • Events API
      • on_player_join
      • on_player_leave
    • Table API
      • Append
      • Remove
      • Join
    • Util API
      • Time
      • TimeMillis
    • HTTP Request API
      • Get
      • Post
      • Put
      • Delete
    • Physics API
      • NewBody
      • NewBoxShape
      • NewSphereShape
Powered by GitBook
On this page
  1. Api Reference
  2. Client API

Message

api.client.Message(playerid, message)

Sends a message to a player client.

This sends a manual message from the server to the client of a player, via that player's serverside entity.

These messages can be received by the clientside SDK's server-to-client messaging function.

Parameters:

Name
Type
Description

playerid

string

The ID of the player entity, to send the message through.

message

table

The Data being conveyed. Must be a key-value pair table, not an array-style table.

Example:

Send a message back to the client, in response to a move message.

-- player.lua
local function message(self, msg)
    if msg.Client then
        local x, y, z = msg.Data.x, msg.Data.y, msg.Data.z
        self:Move(x, y, z)
	
	local move_message = {
		x = msg.Data.x,
		y = msg.Data.y,
		z = msg.Data.z
	}
	
	api.client.Message(self.ID, move_message)
    end
end

-- Receive a typical move message, sent from the client to the game server.
-- Reconstruct the same move message.
-- Send the move message back, from the server to the client.

PreviousClient APINextDimension API

Last updated 1 day ago