Message functions

From HEWIKI
Jump to: navigation, search
See also: Chat System

This page documents the HSL exposed functions and methods that deal with messaging and chat.

Note: Chat messages should not be confused with CLI commands, which are typed into a separate window (the Console Window, not the Chat Window). For more information on console commands, please see the section on the CLI.

Caution: This page may contain information which is Hero's Journey-specific!


Contents

Messaging methods

The only scripts that should ever use messaging are _ChatHandlerClassMethods and HJChatHandlerClassMethods. Everything else should use methods on the $CHAT system node.

$CHAT is a shortcut for the SYSTEM.NODES.CHAT syntax. So $CHAT represents a special node of the Chat class. It has methods for sending messages to various targets, found in the ChatClassMethods script. These methods are what you use to send text messages to players in various ways.

Print a message to the screen

Note that Println works on both client and server scripts.

function println(text as string)

On the server, println sends a message to the server channel HSL_Debug (the Chat Panel). It will also show up in the log history of the process in the Master Control.

On the client, the message is sent to the Console Window.

Each println function generates one line of text. There is no way to suppress the line break at the end. If it is desired to build a larger buffer for output, then a variable should be used:


// Example      
 
  s as string
  s = "The first part"
 
 
  s = s + " more stuff"
  println(s)
 
             // would do the same as:
  println( s + " more stuff")

Print Error

PrintError(errorMessage as string)

Client-side function which displays messages on the Error Panel.


Message all players in the current area

$CHAT.ChatArea(channelName as String, chatMessage as String)

If running on an Area Server, this method makes a call to _ChatHandlerClassMethods, and calls the MsgArea() external function, which sends the specified chatMessage to everyone in the Area. If this method is running on the World Server, this command ends up sending the message to all players online.

Licensees can override this method by adding a class with the method HE_ChatArea to the $CHAT node, which would override the default HE_ChatArea method.

Message one player in the area

$CHAT.ChatPlayer(playerToMessage as ID, channelName as String, chatMessage as String)

Sends a message to the specific _PlayerAccount, who must be in the Area. Note that if the player is *not* in the Area, that no particular error message will be generated.

If running on an Area Server, this method makes a call to _ChatHandlerClassMethods, and calls the MsgArea() external function, which sends the specified chatMessage to everyone in the Area. If this method is running on the World Server, this method will find the _PlayerAccount wherever they are, and message them appropriately.

Licensees can override this method by adding a class with the method HE_ChatPlayer to the $CHAT node, which would override the default HE_ChatPlayer method.

Message list of players in the area

$CHAT.ChatList(playersToMessage as List of ID, chatMessage as String, channelName as String)

Note: This was originally accomplished with the MsgList() function, but all scripts need to be converted to the new $CHAT system

If running on an Area Server, this method makes a call to _ChatHandlerClassMethods, and calls the MsgArea() external function, which sends the specified chatMessage to everyone on the designated list in the designated Area. If called on the World Server, it sends the message to all players on the list, regardless of which Area that they are in.

Licensees can override this method by adding a class with the method HE_ChatList to the $CHAT node, which would override the default HE_ChatList method.

Message all players in the area except those on the list

$CHAT.ChatExcludeList(playersToNotMessage as List of ID, chatMessage as String, channelName as String)

If running on an Area Server, this method makes a call to _ChatHandlerClassMethods, and calls the MsgArea() external function, which sends the specified chatMessage to everyone in the Area except those on the list. If this method is running on the World Server, this method will message all players except those on the list.

Licensees can override this method by adding a class with the method HE_ChatExcludeList to the $CHAT node, which would override the default HE_ChatExcludeList method.

Message everyone

$CHAT.ChatWorld(chatMessage as String, channelName as String)

This sends a message to all online players.

If running on an Area Server, this method makes a call to _ChatHandlerClassMethods, and calls the MsgArea() external function, which sends the specified chatMessage to everyone in the Area. If this method is running on the World Server, this method will message all players.

Licensees can override this method by adding a class with the method HE_ChatWorld to the $CHAT node, which would override the default HE_ChatWorld method.

Send Chat

This is a client function which sends a chat message to the Area the client is connected to. The Area receives the message in the method $CHAT._AreaGotChat, and then that method (which can be overridden with HE_AreaGotChat) calls MsgArea() to send the message to all players in that Area.

function SendChat(chatMessage as String, channel as String)

//Example
function HelloWorld()
    SendChat(SYSTEM.EXEC.THISSCRIPT + "Hello World!" , "game")
.

Send Command

This client-side function sends a command to the area the client is connected to. The area receives the command in the method $COMMANDHANDLER._ProcessCommand, which can be overridden by HE_ProcessCommand. This method is essentially used for various slash commands, and forks off to the appropriate script, such as CommandHQ. For more information, see /REGISTER and /UNREGISTER.

function SendCommand(commandMessage as String)

Messaging Examples

$CHAT.ChatPlayer(playerNode, "general", "Hello there!")
 
// This example builds a message into one variable that can be output all at once
 
 
  outputString as string
 
  outputString = "Mary had "
 
  if (sheepQuantity > 1 ) 
    outputString = outputString + " some little lambs."
  else if (sheepQuantity = 1) 
    outputString = outputString + " a little lamb."
  else 
    outputString = outputString + " nada!"
  .
 
  $CHAT.ChatPlayer(playerNode, "", outputString)
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox