To add (or change) any functionality on your games, first you have to figure out exactly what do you want to change and then figure out a way to do it.
In this case, you need double jump to be active only if the character jumped, not if the character is falling (off a platform, for example). So all we need to do is add the condition:
Player platform is NOT falling [Add it to the double jump code].
I edited refais23 capx with this change.