Crazy Function with a loop
#1

hi, there
Which possibilities are there to stop/Kill a Timer? (I dont mean this: https://sampwiki.blast.hk/wiki/KillTimer)
I'm asking because my created Timer calls a function within a loop to save the team who conquered the base But the timer just get killed after 20 sec. but why?
It's not good because the client mesages will send again and again after the 20sec. are down.
here the code:
pawn Код:
public Conquersystem()
{
for(new i; i<GetMaxPlayers(); i++)
{
        if(CONQUERED_BASE_PD==0)
        {
            if(gTeam[i] == TEAM_BLUE)
            {
                CONQUERED_BASE_PD= 1;
                SendClientMessageToAll(COLOR_BLUE,"TEAM BLUE CONQUERED");
                RemovePlayerMapIcon(i, 2);
                SetPlayerMapIcon(i, 1,326.3,-35.2,3.3, 30, 0);
            }
            else if(gTeam[i] == TEAM_RED)
            {
                CONQUERED_BASE_PD= 2;
                SendClientMessageToAll(COLOR_RED,"TEAM RED CONQUERED");
                RemovePlayerMapIcon(i, 2);
                SetPlayerMapIcon(i, 1,326.3,-35.2,3.3, 20, 0);
            }
        }
        else if(CONQUERED_BASE_PD==1)
        {
            if(gTeam[i] == TEAM_BLUE)
            {
                SendClientMessageToAll(COLOR_WHITE,"TEAM BLUE");
            }
            else if(gTeam[i] == TEAM_RED)
            {
                CONQUERED_BASE_PD= 2;
                SendClientMessageToAll(COLOR_RED,"TEAM RED CONQUERED");
                RemovePlayerMapIcon(i, 2);
                SetPlayerMapIcon(i, 1,326.3,-35.2,3.3, 20, 0);
            }
        }
        else if(CONQUERED_BASE_PD==2)
        {
            if(gTeam[i] == TEAM_BLUE)
            {
                CONQUERED_BASE_PD= 1;
                SendClientMessageToAll(COLOR_BLUE,"TEAM BLUE CONQUERED");
                RemovePlayerMapIcon(i, 2);
                SetPlayerMapIcon(i, 1,326.3,-35.2,3.3, 30, 0);
            }
            else if(gTeam[i] == TEAM_RED)
            {
                SendClientMessageToAll(COLOR_WHITE,"TEAM RED");
            }
        }
        PercentConquered[i] = 0;
        KillTimer(TIMER_PERCENT[i]);
}
}
pawn Код:
TIMER_PERCENT[i]=SetTimer("Conquersystem",50000,false);// this timer will set when a player is at a certain point!
Reply
#2

You have your timer setup for 50 seconds. And once it executes, it will stop.

If you want a repeating timer you need to use:
pawn Код:
TIMER_PERCENT[i]=SetTimer("Conquersystem",50000,true);// this timer will set when a player is at a certain point!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)