script to precache SWEPs?

I’ve never written a script before, but I’ve been told that there is a way to precache SWEPs so that they don’t lag when you spawn them the first time. How would you go about doing this?

you precache the models and textures used by the swep.

Well the thing is that I have no idea how to write a script.

Here’s what I use

hook.Add( "Initialize", "rb655_precache", function()
	for id, wep in pairs( weapons.GetList() ) do
		util.PrecacheModel( wep.ViewModel or "" )
		util.PrecacheModel( wep.WorldModel or "" )
end )

This may, or may not help.

I’ll definitely check this out when I get home.