We are planning on adding the events to the wiki, but have not gotten around to it yet. For now, to get the events yourself, download the newest version of
GCFScape and use it to open your
../Steam/steamapps/common/Counter-Strike Global Offensive/csgo/pak01_dir.vpk file. Inside there, go into the "resource" folder and look for the following files:
- gameevents.res
- hltvevents.res
- modevents.res
- replayevents.res
- serverevents.res
You more than likely will not need to worry about the hltvevents and replayevents files, as those are specific to HLTV and the replay system. Open the other 3 up, and they will each have events with all of the event variables they return. Any events found in the modevents file will override the ones from the gameevents and serverevents files, as they basically extend the functionality of the given event. For instance, gameevents shows player_death as:
Code: Select all
"player_death" // a game event, name may be 32 charaters long
{
"userid" "short" // user ID who died
"attacker" "short" // user ID who killed
}
So, if the current game (in this instance csgo) does not override this event, it will only return those 2 variables. Instead, in the modevents file, it overrides and adds quite a few event variables:
Code: Select all
"player_death" // a game event, name may be 32 characters long
{
// this extents the original player_death by a new fields
"userid" "short" // user ID who died
"attacker" "short" // user ID who killed
"assister" "short" // user ID who assisted in the kill
"weapon" "string" // weapon name killer used
"headshot" "bool" // singals a headshot
"dominated" "short" // did killer dominate victim with this kill
"revenge" "short" // did killer get revenge on victim with this kill
"penetrated" "short" // number of objects shot penetrated before killing target
}
To use this event in Source.Python to print a HudHint message to the victim telling them the weapon they were killed with, you could use something like:
Syntax: Select all
from Source import Engine
from Source import Shared
from events.decorator import Event
# Get the GameEngine instance
GameEngine = Engine.GetEngine()
@Event
def player_death(GameEvent):
# Get the attacker's weapon
weapon = GameEvent.GetString('weapon')
# Get the victim's userid
victim = GameEvent.GetInt('userid')
# Get the player's index
# In the future, this will be much more simplified, but for now we need to do it this way
# Loop through all player indexes (1 - 64, since 64 is the max allowed and no other entity will ever have any of these indexes)
for index in range(1, 65):
# Get the current player's entity
entity = Engine.PEntityOfEntIndex(index)
# Get the current player's userid
userid = GameEngine.GetPlayerUserId(entity)
# Is this the userid we are looking for?
if userid == victim:
# If so, break the loop here, so that the index is set to the correct value
break
# Create a RecipientFilter
Recipients = Shared.MRecipientFilter()
# Add the player to the RecipientFilter
Recipients.AddRecipient(index)
# Create the HudHint message
# The RecipientFilter is the first argument
# The UserMessage type is the second argument
# The third argument is supposed to be the name of the UserMessage type,
# but that never seems to matter, so I always just give it None
UserMessage = GameEngine.UserMessageBegin(Recipients, 24, None)
# Write the message to the HudHint
UserMessage.WriteString('You were killed by a "%s"' % weapon)
# Send the HudHint
GameEngine.MessageEnd()
Many of the parts in this example will be much easier once development of the Python API gets further along.
Satoon