I guess that's the only function you can use, you can also try to trigger an event when the weapon switch event is triggered, like:
function WeaponSwitch()
triggerEvent("Weapon.WepFunction", source)
end
addEventHandler("onClientPlayerWeaponSwitch", root, WeaponSwitch)
function WepFunction()
outputChatBox("Weapon Switched")
end
addEvent("Weapon.WepFunction", true)
addEventHandler("Weapon.WepFunction", root, WepFunction)