I'm fairly certain the userid does return the userid of the victim in both cases, but I will test to verify that in a few.
As for the player_spawned event, I am not sure. I have a script that I always have loaded, to verify which events have been used, and both of the two events have been fired. I will have to do some testing to find out when each one does fire.
Just for reference, and in case anyone else wishes to do this as well, here is the script I use:
Syntax: Select all
import os.path
from events.manager import EventRegistry
all_set = set()
used_set = set()
basepath = os.path.dirname(__file__)
datapath = os.path.join(basepath, 'data')
all_file = os.path.join(datapath, 'all.txt')
used_file = os.path.join(datapath, 'used.txt')
unused_file = os.path.join(datapath, 'unused.txt')
def load():
'''Called when the script loads'''
# Load the all file into the all set
load_set(all_set, all_file)
# Does the used file exist?
if os.path.isfile(used_file):
# Load the used file into the used set
load_set(used_set, used_file)
# Get the difference between the two sets
unused = all_set.difference(used_set)
# Loop through each value in the unused set
for event_name in unused:
# Register the event to the test function
EventRegistry.RegisterForEvent(event_name, test_function)
# Store the difference in the unused file
save_set(unused, unused_file)
def load_set(set_object, file_name):
'''Loads the given filename into the given set object'''
# Open the file
with open(file_name) as open_file:
# Read the used files lines
read_lines = open_file.readlines()
# Loop through each line
for line in read_lines:
# Strip the line of the \n character
stripped_line = line.rstrip()
# Add the line to the used set
set_object.add(stripped_line)
def save_set(set_object, file_name):
'''Saves the given set object to the given file'''
# Get a list object for the given set
list_object = list(set_object)
# Sort the list
list_object.sort()
# Open the file
with open(file_name, 'w') as open_file:
# Write the set to the file
open_file.write('\n'.join(list_object))
def test_function(game_event):
'''Called when an event has been called for the first time'''
# Get the name of the event
name = game_event.GetName()
# Print messages about adding the event
print('=======================')
print('Event Counter Adding:')
print(name)
print('=======================')
# Unregister the event
EventRegistry.UnregisterForEvent(name, test_function)
# Add the event to the used set
used_set.add(name)
# Update the used file with the new event
save_set(used_set, used_file)
# Get the difference between the two sets
unused = all_set.difference(used_set)
# Update the unused file to remove the new event
save_set(unused, unused_file)
I used IDLE to loop through the 5 *events.res files and store all of the events (only 1 instance of each if any are in multiple files) and placed that file in
../addons/source-python/mytest/data/all.txt then put "sp_load mytest" in my autoexec.cfg file. There are 211 total events in the *events.res files and so far I have been able to get 94 to fire.
Satoon