I've found this script ; it puts a MG on the roof of a vehicle (a HMMWV in my example). Works perfect !
In init.sqs file, put :
[Nameofthevehicle,Nameofthemachinegun,height] exec "MGCarry.sqs"
exit
(You can do this differently, of course)
For a HMMWV, for example, put a height of 0.785 (warning : a "." for a ",").
Here's the script :
_carrier = _this select 0
_cargo = _this select 1
_height = _this select 2
endCargoSession = false
goto debug
#carrier
_x = (getPos _carrier) select 0
_y = (getPos _carrier) select 1
_z = ((getPos _carrier) select 2)+_height
_cargo setPos [_x, _y, _z + 0.9 ]
_cargo setDir (getDir _carrier)
~.01
? (!endCargoSession) : goto "carrier"
@ endcargosession
_cargo setpos [_x,(_y)-1.5,0]
exit