SendSharedMsg ( type,data$[,entity][,reliable] )

Parameters

type - your message type, from 1 to 65535

data$ - the message text, up to 4096 bytes of UTF-8

entity (optional) - your own shared entity that the message is about, such as your character; 0 for none (default)

reliable (optional) - True to make sure it arrives, in order (default); False to send it once, for frequent messages that soon go out of date

Description

Sends a game message to the other players.

Use messages for game actions: a client asks the host to open a door, push a crate or score a goal. A client's message goes to the host, which passes it on to the other clients; a host's message goes to every client. You never receive your own message.

The host decides. When a request arrives, check who sent it and whether it is allowed, then make the change on the host's entities, and every player sees the result. The entity you attach must be one you own, so a client attaches its character ("I push"), not the host's crate.

Returns True when the message is sent, or False with the reason in SharedWorldError(). The session must be ready (SHARED_READY).

In a server room the server keeps players' messages to itself, so a hundred players don't flood each other: send what the others should know from the server. For moving and jumping, input actions do better: see DefineSharedStick.

For the full story - services, hosting, sharing and host migration - see the Shared World guide and its complete Shared_World_Playground.bb sample.


See also: RecvSharedMsg, SharedMsgType, SharedMsgData, SharedMsgPlayer, SharedMsgEntity.

Index