Creating server scripts

(Redirected from Creating Server Scripts)
Jump to: navigation, search

He beginner.pngHe intermediate.png

This is an easy- to intermediate-level tutorial on how to create a server-side script. For client scripts, see How to write a script, and for an expert quickref, see HSL for programmers.


This tutorial will walk you through the process of creating your own server-side Chat command which can be typed into the Chat Panel. Tasks covered include:

Creating and running a server-side script

Running a server-side script is a bit more complex than running a client-side script. In order to run a server-side script, you need to have a command handler which lets you send the request to the server to run the script. One way to do this, is for each GameMaster to have their own command, /<name>, which is linked to a command script: cmd<name>, and can be typed in to the Chat Window input box. So, for example, Elonka would have a command /elonka which would run the script cmdElonka. Within that script is a function ProcessInput(), and then that function can be tweaked to call any other functions or scripts needed.

This tutorial will walk you through making your own named command.

If not sure how to do this, please first work through the tutorial on Script Writing.

function HelloWorld()
  $CHAT.ChatArea("game" , "[Script] Hello world! Or at least Hello Area!")

The ChatArea method takes two parameters, just like SendChat(), except their order is reversed, with the channel name first before the message. Again, use the "game" channel, which will ensure that the message is only displayed in your current Area.

  • Modify the HE_ProcessCommandInput() function (this was automatically added as part of the script template) to accept a command like "Hello" to run the new function.
    • In the partialMatch section, change a line that says to "" to instead say to "hello" (must be lowercase)
      • Remove the unused "option 2" case.
        • Add a line immediately after that which says HelloWorld().
          • The section should now look like this:

  partialMatch toLower( args[2] )
    to "hello"
      HE_CommandUsage( account, input )
(replace <your name> with your name you used for this command)

  msg as String = "/COMMAND <your name> HELLO$R"
msg += " - Generates a Hello World message$R"
Msg( account, msg )

This will bring up a "comments" box. Enter something into the box that gives a rough summary of what you've done, like "Created new script" or "fixed a typo", etc.

/REGISTER ADD /<your name> script="cmd<yourname>".

Example: /register add /elonka script="cmdElonka"

Example: /chiv hello

You should see a message pop up that looks like: [game] [Script] Hello world! Or at least, Hello Area!

If it didn't work:

Assuming that everything worked though:


For your next trick, try:

A tutorial which creates a meatier script that actually does something: Making an object move when you mouse over it.

See also

Walks you through creating a simple "Hello World" client-side script
Quick-reference for more experienced programmers
Personal tools