Here's my (basic) solution for a melee attack :
The player's name is CM.
In his init field I put : this addAction ["Hit with rifle butt","Sg.sqs"]
And here's my script (Sg.sqs) :
CM action ["strokegun"]
if (CM distance Enemy1 <=3) then {Enemy1 setDamage 1}
if (CM distance Enemy2 <=3) then {Enemy2 setDamage 1}
if (CM distance Enemy3 <=3) then {Enemy3 setDamage 1}
if (CM distance Enemy4 <=3) then {Enemy4 setDamage 1}
if (CM distance Enemy5 <=3) then {Enemy5 setDamage 1}
if (CM distance Enemy6 <=3) then {Enemy6 setDamage 1}
if (CM distance Enemy7 <=3) then {Enemy7 setDamage 1}
if (CM distance Enemy8 <=3) then {Enemy8 setDamage 1}
if (CM distance Enemy9 <=3) then {Enemy9 setDamage 1}
if (CM distance Enemy10 <=3) then {Enemy10 setDamage 1}
if (CM distance Enemy11 <=3) then {Enemy11 setDamage 1}
if (CM distance Enemy12 <=3) then {Enemy12 setDamage 1}
if (CM distance Enemy13 <=3) then {Enemy13 setDamage 1}
if (CM distance Enemy14 <=3) then {Enemy14 setDamage 1}
if (CM distance Enemy15 <=3) then {Enemy15 setDamage 1}
if (CM distance Enemy16 <=3) then {Enemy16 setDamage 1}
if (CM distance Enemy17 <=3) then {Enemy17 setDamage 1}
if (CM distance Enemy18 <=3) then {Enemy18 setDamage 1}
if (CM distance Enemy19 <=3) then {Enemy19 setDamage 1}
if (CM distance Enemy20 <=3) then {Enemy20 setDamage 1}
if (CM distance Enemy21 <=3) then {Enemy21 setDamage 1}
if (CM distance Enemy22 <=3) then {Enemy22 setDamage 1}
if (CM distance Enemy23 <=3) then {Enemy23 setDamage 1}
if (CM distance Enemy24 <=3) then {Enemy24 setDamage 1}
if (CM distance Enemy25 <=3) then {Enemy25 setDamage 1}
if (CM distance Enemy26 <=3) then {Enemy26 setDamage 1}
if (CM distance Enemy27 <=3) then {Enemy27 setDamage 1}
exit