Client Script – Ylands

From Bohemia Interactive Community
Jump to navigation Jump to search

Introduction

Client scripting is new way how to optimize multiplayer games created in Ylands editor. It allows to offload some of the scripting from server and execute it only on the client meaning that these scripts are not subjected to player multiplayer latency (i.e ping). However this advantage is coming with few disadvantages.

Differences

Because the local scripting is not authorized by server, it does not allow to do all the stuff possible with "normal" (server) scripting. Everything done trough Client Scripting stays only on the client, so there are several limitations imposed by this fact.

  • Only handful of Game Logic are supporting Client Scripting
  • Limited script abilities
    • Can only read data from the scene but can't write data to the scene (i.e object color, hit points etc.).
    • Cannot change properties of supported Game Logic.

On the other hand Client Script allows to do many things that are not needed to be authorized by server, because they only matter to the client (player) or stuff which would not be effective in Server script due the latency. It is mostly useful for improving player UI experience.

  • Extensively customize UI on the client.
  • Program simple UI games on the client.
  • Utilize new instructions such as:
    • On Update event, which executes every frame, to create i.e animations.
    • Get Cursor position.
    • Get Screen resolution.
    • And much more.

In order to assure the communication between server and client scripting, there are events that allow to send/listen to messages between those two. For example you can send a final score of 2D UI game to the server to be included in the leaderboard.

Supported Game logic

  • Custom Controls
  • Custom HUD
  • Custom Window
  • Event Listener
  • Global Storage

Client scripting

How to

 
Switch

If client scripting is supported by the Game Logic, it can be toggled by switching the canvas by using the to toggle found in the top bar.

Note

Clients / Server scripts run simultaneously, one does not disable the other.

Variables and Custom Instructions

Variables and instructions in Client Scripting work same way as in Server one, variables and instructions defined in Global Storages are available globally within the script, however only for Client Scripts. Due to the nature of Serve / Client scripts they are separated.

Custom Parameters

Client Script variables can be exposed as Custom Parameters in same way as Server ones and they will appear along them in Object Properties.

Client <-> Server events

 
Client event

Special events can provide to provide data from Client to the Server (and vice versa).

Send Message To Server

  • Object - target object receiving the event
  • Name - event name
  • Argument(s) - data sent with the event

On Client Message Received

  • Player - player (client) sending the event
  • Name - event name
  • Arguments - array of data sent with the event

Send Message To Client

  • Player - player (client) receiving the event
  • Object - target object receiving the event
  • Name - event name
  • Argument(s) - data sent with the event

On Server Message Received

  • Name - event name
  • Arguments - array of data sent with the event

See also

Instructions