Event Reference

From EventScripts Community Encyclopedia

Contents

Event Listings

HL2 Mod Events

Script Events


Event Variable Expansion

If a script is run as an event (e.g. player_death.cfg), EventScripts will provide event information for you to access. To use this variable expansion, simply prefix any typical cfg line with "es " and place event_var(variable) in the places you want it, where variable is the the name used for the field you want. (See modevents.res, serverevents.res, or gameevents.res for a list of common events and fields. For example, some common fields are "userid", "headshot", "weapon", etc.).

  • es <command string>
    • Executes the command string after it expands all variables in it. (e.g. supports "es exec config.cfg" or "es kickid event_var(userid)".)

For example, look at the sample bullet_impact.cfg I provided for download:

// EventScripts v0.2.0 Example
// Only works if you have eventscripts_noisy set to 1
es say Player event_var(userid) hit x:event_var(x), y:event_var(y), and z:event_var(z).

What's the x, y, and z you ask? It's the place the bullet hit. Let's look at the description of "bullet_impact" from cstrike's modevents.res file:

  "bullet_impact"
  {
     "userid"   "short"
     "x"      "float"
     "y"      "float"
     "z"      "float"
  }

Since we used es, EventScripts will look for all the "event_var()" portions and replace those with the appropriate values provided by the game. All those values are listed in the resource files I mentioned at the top of the page. This particular script would cause the console to say things like the following whenever a player shoots a wall:

Console: Player 3 hit x:333.1212, y:445.3321, z:233.223.

In this example we use es and say, but there's no reason we couldn't use the other EventScripts commands that support variable expansion. For example, we could use es_msg to send the text around as such:

// Only works if you have eventscripts_noisy set to 1
es_msg Player event_var(userid) hit x:event_var(x), y:event_var(y), and z:event_var(z).
blog comments powered by Disqus