pick up a gun to spawn something (scripting)

is it possible to pick a battle rifle up, and script something to spawn as you interact with it?