Attack Delay

Hello guys,

I am making game but I just started and learning to make game.

Maybe I made the 5-10% of it.

I want to know if how to code an “Attack Delay”.

Did you get it?

I am planning to loop but I don`t know what to put.

I tried this:


time = 0;

while (time < 10) {
        if (time%2 == 0)
              attack;
        else
              rest;
}

but it is not working.

My game`s timer = 50.

If you know the game DOTA maybe you will get my point if the two creeps meet each other they will attack each other.

Thanks