You'll get a thousand answr's to this one.Me?1st,self leveling compound on floorboards,mixed on the thick side and screeded to the worst bits(this will somewhat fill voids)then ply layed across the boards(floor moves,so will ply so this will help to stabalise.)All wood shrinks and expands in reaction to air moisture content,so I wouldn't glue ply down.Nailed,it will still permit floor to move under the ply.Then i'd seal all seams with carpet fitters tape for underlay.This will stop the ply telegraphing the seams through the carpet and becoming visable.Dont forget to leave 10mm of edge/wall gap all the way round to allow for expansion of the ply.if floor that bad then consider fitting 5/8 ply over the whole thing.may solve more problems in long run.
caine
July 2008