I'm assuming you're using bone animation for your main character, yes? Add a "dummy" joint to the skeleton at the point where you want the weapon to be held. When you export the model, each joint will have an index, so make sure you remember which index the dummy joint has.
After that in your code, use this to attach the gun to the joint:
dbGlueObjectToLimb( objectID , TargetObjectID , JointIndex )
Note that dbPositionObject() is relative to the joint position and rotation. If you see that the gun is crooked, then open up your character model again and rotate the dummy joint to compensate.
TheComet