Timer problem
#1

hello, i have a problem with my isplayerinrangeofpoint


when I enter area it works, but when i leave or just join the server it spam me with "You left test"

pawn Код:
forward Test();
public Test()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInRangeOfPoint(i, 2.0, 252.3922,117.3293,1003.2188))
        {
            if(Send[i] == 0)
            {
                SendClientMessage(i,Blue,"Welcome to Test!");
                Send[i] = 1;
            }
        }
        else
        {
            SendClientMessage(i,Yellow, "You left Test");
            Send[i] = 0;
        }
    }
    return 1;
}
pawn Код:
new Send[MAX_PLAYERS] = 0;
pawn Код:
SetTimer("Test", 2000, true);
help please
Reply
#2

pawn Код:
forward Test();
public Test()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInRangeOfPoint(i, 2.0, 252.3922,117.3293,1003.2188))
        {
            if(Send[i] == 0)
            {
                SendClientMessage(i,Blue,"Welcome to Test!");
                Send[i] = 1;
            }
        }
        else
        {
              if(Send[i] == 1)
              {
            SendClientMessage(i,Yellow, "You left Test");
                                       Send[i] = 0;
              }
        }
    }
    return 1;
}
Should work now
Reply
#3

Because, you set a timer to 2 seconds right. Now every 2 seconds it is going to check if you are in the area or not. If your not in the area it is going to say "you have left the test"

Now it repeats the same teste every 2 seconds, thats why its getting spammed.
Hope I was helpfull.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)