EventScripts

From Wikipedia, the free encyclopedia
Jump to: navigation, search

EventScripts is a free game scripting plugin for Valve Corporation's Source engine. Aimed at first-time scripters, EventScripts has grown to be one of the most popular Source scripting engines, running on more than 5,000 dedicated game servers worldwide as of December 2010. [1]

Overview[edit]

EventScripts is a plugin for Valve's Source engine that allow custom scripts to execute on the server. The engine is heavily event-driven, as the name implies, allowing a scripter or game server administrator to take action whenever an event occurs in the game. It also allows scripts to register server console commands themselves [2] and interact heavily with the Source engine to create effects [3] and interact with players/entities.

Over time the goals of the project have evolved into maintain backwards compatibility, providing a simple interface for non-experts, and delivering active support and help via forums. In this way, EventScripts continues to be an important factor in the Source gaming community, particularly for Counter-Strike: Source.

The scripting engine of EventScripts supports two different scripting styles.

EventScripts Classic[edit]

EventScripts Classic is not unlike a command-line shell (like bash) built on top of the Source engine's console. It was designed to be simple to use for administrators since experienced coders have access to creating Source plugins via Valve's Source SDK in C++.

EventScripts Python[edit]

As of EventScripts 2.0, the plugin includes full Python scripting support as an alternative language to EventScripts Classic. The focus again is on providing libraries and wrappers that make it easy to script against, while still providing access to all the power of the existing Python language and standard library.

How it works[edit]

At its core, EventScripts is just a Valve Source Plugin which passes information it receives from the Source engine to loaded scripts. When an administrator loads a script (typically through a configuration file via "es_load <script>"), EventScripts parses out the block structures in the file and stores them in memory. When an event fires, EventScripts passes the registered parts of the script to the Valve command console and stores the event-specific information if a script later needs it.

Almost all interaction between scripts and the Source engine happens through special console commands that EventScripts or other plugins register. This allows the scripts to interact with any other plugin (e.g. an admin plugin) that also register console commands for admins.

A simple example script for EventScripts Classic would look like this:

event player_hurt
{
  // tell the victim who hit them
  es_tell event_var(userid) You were attacked by event_var(es_attackername)
}

In the example above, "es_tell" is simply an EventScripts console command registered with the game engine. When the game console executes it, EventScripts is given control and expands all of the variables on the line before executing the line's logic.

In EventScripts 2.0, support for the Python programming language was added. An example script would look like this:

import es
 
def player_hurt(event_var):
    es.tell(event_var['userid'], "You were attacked by " + event_var['es_attackername'])

History[edit]

The EventScripts plugin was initially released in December 2004 by Mattie Casper. Originally the design was to allow administrators to automatically invoke configuration (*.cfg) files whenever important game events happened. In this way, administrators could do things like change the gravity upon round start, or invoke commands for popular administrator addons like Mani Admin Plugin. [4]. The cross-interaction with other plugins really drove a lot of EventScripts initial popularity.

In 2005, by community request, EventScripts was updated to become more powerful, adding console commands for logic operations (if/then, while, etc.) and the notion of "script packs" [5] which allowed for grouping of event-based configuration files. The popularity of the plugin grew rapidly in this timeframe as the community released dozens and dozens of scripts to the public, like the popular MugMod (originally a plugin) and GunGame scripts.

In 2006, EventScripts 1.0 was released. This introduced a new script structure that allowed authors to create stand-alone script files without relying on packs of multiple .cfg files. This structure also provided block-based language constructs that allowed for loops, advanced conditions (via if/else), and custom console, say, and client commands. [6] Important feature releases improved performance in 2006 and early 2007 via the 1.2 [7] and 1.3 [8] releases. During 2006, the popular support plugin ES_Tools was released to provide access to deeper things within the Source engine which EventScripts could not or did not yet offer.

EventScripts community mascot, with python friend from ES 2.0

In May 2007, EventScripts 1.5 was released and provided support for SQLite databases, regular expressions, and a variety of other modern language features. In this release, EventScripts changed its server variable expansion dramatically to improve performance. During this time, the project took on the Evie zebra mascot.

In October 2007, EventScripts 2.0 was released to public beta. This version allows for full-fledged Python scripting on Windows and Linux game servers. Scripts are loaded a lot like Python modules, but they support a simplified syntax that automatically registers events and code blocks. Python offers a huge library of existing functionality and tutorials, so this gives a Source server a lot more access to just about anything supported by normal Python applications. Thus giving Python a huge leap over the original scripting language ES.

Script Addons[edit]

There are over a thousand addons written for EventScripts. For a growing list, see Script Addons in the external links below.

Some of the most popular scripts are featured on hundreds or thousands of servers:

  • GunGame, written by cagemonkey, is a modification that changes the dynamic of Counter-Strike: Source to become a race to get at least one kill with every gun. A challenging ending calls for someone to kill another player with only a knife and then only a single hand grenade. This has become popular enough to be backported to the original Counter-Strike.
  • MugMod is a simple addon that gives player's the ability to steal the money of their victims when they kill them with a knife.
  • ba_bank allows players to store and withdraw money from a virtual bank each round.

External links[edit]