Variable Counting

Make sure you declare all the variables at the top.

if( someVar == 0)
counter++;
else
counter = 0;

Its not rocket science.