Having a problem with damage over time on unity 2d

So i wanna make some kind o fire rain, and if it collides with the player, damage over time is applied, but i want it to happen only when the player isnt receiving damage from the previous hit (from the fire rain), in other words, i don’t want the the damage over time stackable.

using UnityEngine;
using System.Collections;

public class fire : MonoBehaviour
{

public int damageToGive = 3;
public int x=0;
public int playerhurt = 0 ;

// Use this for initialization
void Update () 
{

}

void Start () 
{
}
	

void OnTriggerEnter2D(Collider2D other)
{

	if (other.tag == "Player" && playerhurt==0) 
	{
		InvokeRepeating ("dmgOverTime", 0f, 2f);
	}
}

// Update is called once per frame
void dmgOverTime () 
{

	if (x < 3) 
	{
		playerhurt = 1;
		GameObject player = GameObject.FindGameObjectWithTag ("Player");
		HealthManager HM = player.GetComponent<HealthManager> ();
		HM.giveDamage (damageToGive);
		x++;
	}
	else
	{
		playerhurt = 0;
		CancelInvoke ();
		x = 0;
	}

}

}

For some reason, when the playerhurt is set to 1, it gets automaticly to 0, i think it’s thanks to public int playerhurt = 0 ; but i can’t find a way around, what should i do?

@FortisVenaliter Thanks!, the problem was that i had another InvokeRepeating for the fire rain, the easy fix was using the playerhurt in the scrip that calls the rain.