[INFO] TFC PrecacheEvent/PlaybackEvent Index and Name List

For scripting examples for learning how to use AMXX.
User avatar
Archive-Poster
Posts: 1367
Gender:
United States of America

[INFO] TFC PrecacheEvent/PlaybackEvent Index and Name List

Post by Archive-Poster »

This is a list of event names and indexes used with the PrecacheEvent and PlaybackEvent forwards in Team Fortress Classic. I ultimately didn't end up using any of this in the plugin I was coding, but I figured someone else might find this information helpful.

In theory the event IDs could change, and you should get them programatically in plugin_precache().

Code: Select all

#    Event Name				Comment
 1 = events/wpn/tf_sg.sc		Single-Barrel Shotgun (Scout, Soldier, Pyro, Demoman, Heavy Weapons Guy, Medic)
 2 = events/wpn/tf_sgreload.sc		Both shotguns reload
 3 = events/wpn/tf_sgpump.sc		Both shotguns pump
 4 = events/wpn/tf_axe.sc		Knife (Spy), Medkit (Medic), Umbrella (Civilian)
 5 = events/wpn/tf_axedecal.sc		??
 6 = events/wpn/tf_knife.sc		?? (Spy)
 7 = events/wpn/tf_mednormal.sc		?? (Medic)
 8 = events/wpn/tf_medsuper.sc		?? (Medic)
 9 = events/wpn/tf_medsteam.sc		?? (Medic)
10 = events/wpn/tf_nail.sc		Nailgun (Spy, Sniper, Scout)
11 = events/wpn/tf_snail.sc		Super Nailgun (Medic)
12 = events/wpn/tf_rpg.sc		Rocket Launcher (Soldier)
13 = events/wpn/tf_ic.sc		Incendiary Cannon (Pyro)
14 = events/wpn/tf_flame.sc		Flamethrower (Pyro)
15 = events/wpn/tf_tranq.sc		Tranquilizer Gun (Spy)
16 = events/wpn/tf_sniper.sc		Sniper Rifle laser on (Sniper)
17 = events/wpn/tf_sniperhit.sc		Sniper Rifle laser off/fire (Sniper)
18 = events/wpn/tf_ar.sc		Automatic Rifle (Sniper)
19 = events/wpn/tf_rail.sc		Railgun (Engineer)
20 = events/wpn/tf_acwu.sc		Assault Cannon spin up (Heavy Weapons Guy)
21 = events/wpn/tf_acwd.sc		Assault Cannon spin down (Heavy Weapons Guy)
22 = events/wpn/tf_acfire.sc		Assault Cannon fire 1 round (Heavy Weapons Guy)
23 = events/wpn/tf_acsspin.sc		Assault Cannon out of ammo (Heavy Weapons Guy)
24 = events/wpn/tf_acspin.sc		Assault Cannon spin (no ammo) (Heavy Weapons Guy)
25 = events/wpn/tf_acstart.sc		Assault Cannon start shooting (Heavy Weapons Guy)
26 = events/wpn/tf_gl.sc		Grenade Launcher (Demoman)
27 = events/wpn/tf_pipel.sc		Pipebomb Launcher (Demoman)
28 = events/wpn/tf_ssg.sc		Double-Barrel Shotgun (Soldier, Heavy Weapons Guy, Medic, Engineer, Spy)
29 = events/misc/tf_buildingevent.sc	Build/dismantle/detonate (Engineer)
30 = events/explode/tf_concuss.sc	Concussion Grenade (Scout, Medic)
31 = events/explode/tf_emp.sc		EMP Grenade (Engineer)
32 = events/explode/tf_pipe.sc		Pipebomb Launcher detonation (Demoman)
33 = events/explode/tf_gren.sc		Grenade Launcher detonation (Demoman)
34 = events/explode/tf_engrgren.sc	??
35 = events/explode/tf_normalgren.sc	Hand grenade (All except Scout/Civilian)
36 = events/explode/tf_mirvmain.sc	MIRV grenade initial explosion (Heavy Weapons Guy, Demoman)
37 = events/explode/tf_mirv.sc		MIRV grenade little explosions (Heavy Weapons Guy, Demoman)
38 = events/explode/tf_fire.sc		Napalm Grenade initial explosion (Pyro)
39 = events/explode/tf_burn.sc		Napalm Grenade fire (Pyro)
40 = events/explode/tf_gas.sc		Halucination Grenade (Spy)
41 = events/explode/tf_nailgren.sc	Nail Grenade (Soldier) 1 round of nails
42 = events/explode/tf_ng.sc		Nail Grenade (Soldier) terminating blast
43 = events/misc/gibs.sc		??
44 = events/door/doorgoup.sc		Door/gate/lift opening
45 = events/door/doorgodown.sc		Door/gate/lift closing
46 = events/door/doorhittop.sc		Door/gate/lift fully open
47 = events/door/doorhitbottom.sc	Door/gate/lift fully closed
Here's some sample code for logging the events and blocking a specific one:

Code: Select all

#include <amxmodx>
#include <fakemeta>

public plugin_init() {
    register_forward(FM_PlaybackEvent, "fw_playbackevent_pre", 0);
}

public plugin_precache() {
    register_forward(FM_PrecacheEvent, "fw_precacheevent_post", 1);
}

public fw_playbackevent_pre(flags, invoker, eventindex, delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iparam1, iparam2, bparam1, bparam2) {
    if (eventindex != 35) {    // If it isn't the hand grenade event, ignore it
        return FMRES_IGNORED;
    }

    log_amx("Grenade explosion blocked.");
    return FMRES_SUPERCEDE;    // This blocks the visual/sound effects, but not the actual damage
}

public fw_precacheevent_post(type, const event_name[]) {
    log_amx("fw_precacheevent_post: event_name(%s) eventindex(%d)", event_name, get_orig_retval());
    return FMRES_IGNORED;
} 
See also the following post which demonstrates how to programmatically get the index (event ID) when you know the event/script name.
User avatar
Archive-Poster
Posts: 1367
Gender:
United States of America

Re: [INFO] TFC PrecacheEvent/PlaybackEvent Index and Name List

Post by Archive-Poster »

When dealing with events i noticed that you can't precache them like shown above.
That may desinchronize the server and client and mess for example the weapon sounds, etc.
To avoid that you shouldn't precache the standard events, they will be precached by the game engine anyway, all you have to do is just retrieve the return value.

The most correct example in my opinion would be

Code: Select all

#include <amxmodx>
#include <fakemeta>

new g_fwdid_precacheevent
new g_eventid_decalreset

public plugin_precache() {
    g_fwdid_precacheevent = register_forward(FM_PrecacheEvent, "fwdPrecacheEvent", 1)
}

public fwdPrecacheEvent(type, script[]) {
    if (equal(script, "events/decal_reset.sc")) {
        g_eventid_decalreset = get_orig_retval()
        unregister_forward(FM_PrecacheEvent, g_fwdid_precacheevent, 1)
    }
}
Though there are a workaround for lazy people: execute PrecacheEvent for the given script after its actual precache, for example in plugin_init, and it will return the given event index.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest