User Tools

Site Tools


4rpl:commands:sendmsg

Index
Messaging

SendMsg

SendMsg(<-channel <-data)

Description

Sends a message. A message can contain any 'data' type. Any script registered to receive messages on the specified 'channel' will receive the message. See RegisterForMSG for information on the callbacks.
SendMSG is primarily intended for sending message between different scripts. Prior to the 2.0 release of CW4, any call to SendMSG that ends up calling backing into the same script that SendMSG was called from, will produce errors in some cases. This can happen,for instance, if you destroy some other unit from script A. Script B (on the destroyed unit) has a :Destroyed handler that calls SendMSG on a channel that script A listens on.

Examples

SendMsg("test" "Hello World")
#Connected to the example of RegisterForMsg
#If using this, must be put in a destroy-able unit
:Destroyed
SendMsg("test" "i died")

See also

4rpl/commands/sendmsg.txt · Last modified: 2024/02/17 21:23 by LiteralNoob