Sound Effects Timer

I have a sound effect that is supposed to only work when the i key is pressed and only once until the character hits the ground. For some reason it always plays when you hit the i key even in the air. Here are my codes.
on collision with the ground.
on collision finish of the ground.
(repeats only once.)
On "Jump" timer.
On keydown for jump key.
If anyone can tell me what is wrong please do.
on collision with the ground.
- Code: Select all
in_air=0;
on collision finish of the ground.
- Code: Select all
CreateTimer("Jump", 100);
(repeats only once.)
On "Jump" timer.
- Code: Select all
in_air=1;
On keydown for jump key.
- Code: Select all
if(in_air==1)
{
PlaySound2("/data/Mario Jump.wav" 0, 0, 1);
}
If anyone can tell me what is wrong please do.