Hello World

From EventScripts Community Encyclopedia

Create your first script for EventScripts. This will show you how to create a simple script addon.

Tutorial

In this tutorial, we'll create a simple "Hello World" script to test that you've installed EventScripts properly. This tutorial assumes that you've installed EventScripts on your dedicated server. (See the EventScriptsGuide for installation instructions.)

Steps

  • Navigate/explore to cstrike/addons/eventscripts.
    --> Note: If the directory doesn't exist, you need to create it. cstrike is the proper directory for Counter-Strike: Source, but replace that with the proper directory for your game.
  • Create a directory there called hello
  • Navigate/explore into that hello directory.
  • Create an empty text file called es_hello.txt
  • Open this es_hello.txt file in a text editor (e.g. notepad, or your server's web control panel)
  • Copy in the following text into es_hello.txt
// My first script!
block load
{
  es_msg My hello script has been loaded.
}
 
block unload
{
  es_msg My hello script has been unloaded.
}
 
event player_spawn
{
  es_msg Hello World! event_var(es_username) has spawned!
}
  • Save es_hello.txt (or upload it to your server to the corresponding folder).
  • Connect to your server from your game machine (on Windows)
  • log into rcon as normal with rcon_password yourpasswordhere (this step not necessary if you are doing a listen server)
  • in the console, type rcon es_load hello (if doing a listen server, don't put the rcon in front)
  • Choose a team and try dying and respawning.
  • Whenever a player spawns, you should see a message like this in the bottom left of your screen:
Hello World! xxxx has spawned.
  • Once you prove that it's working, type rcon es_unload hello so that you don't see it all the time. (Once again, the rcon prefix is not necessary if you are doing a listen server)

Did it work?

  • If you see the Hello World message, your installation was successful. Congratulations! You should try the next section of the EventScriptsGuide.
  • If you do not see the message when you jump, something is wrong with your installation. Visit the Install Troubleshooting section or provide a detailed question in our forums. There's also an IRC channel for help, too.
blog comments powered by Disqus