ok, i think that this should fix some things
_o = nearestObject[player, _ammotype]
if(player distance _o < 25)then{[] exec "shell_shock.sqs"}
The error seemed to only have to do with how you express your condition.
I've never expressed the condition the way you did, and I don't know if it works, but the above code should fixt the problem