View Model Events

Where are model events defined?

For example, for the event “Weapon_M82.Boltup” in the view model, where would it define what that event entails, sound wise as well as otherwise?


$cd "H:\Decompiled Models\Barrett - Copy\View"
$modelname "tg\weaponsbetav1\M82\View_Model\v_tg_snip_m82.mdl"
$model "studio" "v_m82_reference.smd"
$cdmaterials "tg\weaponsbetav1\M82\View_Model"
$cdmaterials "models\weapons\v_models\hands\"
$hboxset "default"
$hbox 0 "Body" -1.537  -14.323  -4.043  1.537  35.640  5.074
$hbox 0 "mag" -0.583  -2.503  -2.907  0.583  2.503  2.907
$hbox 0 "handl" -2.609  -2.958  -0.067  0.066  0.811  4.426
$hbox 0 "bolt" -0.725  -4.685  -0.586  0.725  4.685  0.586
$hbox 0 "L_Forearm" -0.340  -1.685  -1.523  8.109  1.675  1.276
$hbox 0 "L_Wrist" 0.000  -1.486  -1.254  3.495  1.746  1.005
$hbox 0 "L_Thumb1" 0.000  -0.507  -0.685  1.979  0.834  0.689
$hbox 0 "R_Forearm" -0.339  -1.713  -1.276  8.109  1.647  1.523
$hbox 0 "R_Wrist" 0.000  -1.766  -1.231  3.495  1.531  1.005
$hbox 0 "R_Thumb1" 0.000  -0.572  -0.699  2.114  0.736  0.673
// Model uses material "m82.vmt"
// Model uses material "v_hands.vmt"
// Model uses material "Main.vmt"
// Model uses material "Scope.vmt"
// Model uses material "scope_ch.vmt"
// Model uses material "scope_rt.vmt"
$attachment "1" "Body" 0.00 36.00 -0.50 rotate -0.00 0.00 0.00
$attachment "2" "bolt" 0.30 -0.00 -0.00 rotate 0.00 -15.00 -0.00
$surfaceprop "default"
$illumposition -21.075 -1.260 -7.338
$sequence idle "idle" ACT_VM_IDLE 1 rotate -90 fps 30.00
$sequence fire "fire" ACT_VM_PRIMARYATTACK 1 rotate -90 fps 35.00 {
  { event 5001 0 "1" }
  { event AE_CLIENT_EFFECT_ATTACH 2 "EjectBrass_338Mag 2 50" }
}

$sequence draw "draw" ACT_VM_DRAW 1 rotate -90 fps 30.00
$sequence reload "reload" ACT_VM_RELOAD 1 rotate -90 fps 31.00 {
  { event 5004 17 "Weapon_M82.Boltup" }
  { event 5004 49 "Weapon_M82.Clipin" }
  { event 5004 74 "Weapon_M82.Clipout" }
  { event 5004 85 "Weapon_M82.Boltdown" }
}

I ask because I changed the sound directory, and I must now change the path in the event to make them work.

Thanks in advance,
ZephyrWarrior

you dont change those from it you change the sound script

Thanks for the very descriptive answer…

Where is the sound script for starters?

normally scripts/weapons or scripts/sound

There was no script folder with the model.

Lua
Materials
Models
Sound

That’s it.

Then you might need to create the scripts folder and the necessary sound script manually.

Is there a template I could follow somewhere?

Also, if the script wasn’t there, how could the sounds work on the original?

It may be for another game, but you can look at Counter-Strike:Source skins on GameBanana to see examples for the sound script.

It’s for Garry’s Mod, to be used in several gamemodes. Is the format the same as CSS?

From what I’ve seen, yes.

Gmod USED to use the same script format as CS:S, now it’s switched to a lua-based system. All soundsctipts (to my knowldege) must be put in lua/autorun and have the .lua extension and must have AddCSLuaFile(“autorun/filename.lua”) as a header. Mostly all the variables like the sound channel have stayed the same though.

Here’s a sample of a simple soundscript I made for the G36C from Arctic Combat:



AddCSLuaFile("autorun/soundscripts.lua")

local st = {}
	st["channel"] =	"CHAN_ITEM"
	st["volume"] =	"1.0"
	st["pitch"] =		"PITCH_NORM"
	st["sound"] =		"weapons/BTB/G36C/weapon_g36c_fire.wav" 
        st["name"] = "BTB.G36C.Single"
	sound.Add(st)

local st = {}
	st["channel"] =	"CHAN_ITEM"
	st["volume"] =	"1.0"
	st["pitch"] =		"PITCH_NORM"
	st["sound"] =		"weapons/BTB/G36C/weapon_g36c_select.wav" 
        st["name"] = "BTB.G36C.Select"
	sound.Add(st)

local st = {}
	st["channel"] =	"CHAN_ITEM"
	st["volume"] =	"1.0"
	st["pitch"] =		"PITCH_NORM"
	st["sound"] =		"weapons/BTB/G36C/weapon_g36c_select_n.wav" 
        st["name"] = "BTB.G36C.Select.New"
	sound.Add(st)

local st = {}
	st["channel"] =	"CHAN_ITEM"
	st["volume"] =	"1.0"
	st["pitch"] =		"PITCH_NORM"
	st["sound"] =		"weapons/BTB/G36C/weapon_g36c_reload.wav" 
        st["name"] = "BTB.G36C.Reload"
	sound.Add(st)

local st = {}
	st["channel"] =	"CHAN_ITEM"
	st["volume"] =	"1.0"
	st["pitch"] =		"PITCH_NORM"
	st["sound"] =		"weapons/BTB/G36C/weapon_g36c_reload_empty.wav" 
        st["name"] = "BTB.G36C.Reload.Empty"
	sound.Add(st)


Don’t think the use of shared tables is needed, but it’s what I know. You can find more info on Gmod soundscripts here.

I know basic lua. Without straying too far into coding territory, can this section of code go into the weapon shared.lua file or does it have to go in autorun?

Fairly certain it’s gotta be in autorun.