You can also use bones to attach objects to specific parts of the model.

Code
action attach_gun_to_actor
{
    var anim_percent = 0;
    you = ent_create("gun.mdl", vector(0,0,0), NULL); // create gun entity without animation

    while(1)
    {
        anim_percent += time_step;
        ent_animate(me, "walk", anim_percent, ANM_CYCLE);

        //attach gun to "RightHand" bone
        vec_for_bone(your.x, my, "RightHand"); // move gun entity
        ang_for_bone(your.pan, my, "RightHand"); // rotate entity

        wait(1);
    }
}