Timer problem
#1

Hello, I got a problem with some timers. When you enter a specific area where you are not allowed, you start to loose health. You start to loose health, but it wont stop, even if you go away.

Here is the code:

Код:
new bool:IsInArea[MAX_PLAYERS];
new HealthTimer[MAX_PLAYERS];

forward areacheck();
forward health(playerid);

public OnGameModeInit()
{
SetTimer("areacheck", 200, 1);
}

public areacheck()
{
    for (new i=0; i<MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            if (IsPlayerInRangeOfPoint(put things here) && IsInArea[i]==false)
            {
                HealthTimer[i]=SetTimerEx("health", 400, 1, "i", i);
                IsInArea[i]=true;
            }
            else
            {
                if (IsInArea[i]==true)
                {
                    IsInArea[i]=false;
                    KillTimer(HealthTimer[i]);
                }
            }
        }
    }
}

public health(playerid)
{
    new Float:h;
    GetPlayerHealth(playerid, h);
    SetPlayerHealth(playerid, h-5)
}
I cant figure out whats wrong.

Any help would be appreciated
Reply


Messages In This Thread
Timer problem - by RedWolfX - 20.05.2013, 18:03
Re: Timer problem - by Jefff - 20.05.2013, 20:29
Re: Timer problem - by RedWolfX - 20.05.2013, 20:48
Re: Timer problem - by Jefff - 20.05.2013, 21:10
Re: Timer problem - by Pooh7 - 20.05.2013, 21:54

Forum Jump:


Users browsing this thread: 1 Guest(s)