Repeating timer gets out of sync
#1

Hi, I have a good question for those of you who have a little more experience with pawn. Namely, in my gamemode I have a looping timer that repeats every 1 second.

The problem is that something causes it to speed up to ridiculous speeds and instead of repeating every second, it repeats every ms. I have not had that problem when the server was hosted on my windows localhost, but now that I moved it to a Debian 6.0 32-bit, the problem appeared. It makes the server lag completely and makes it not functional in any way since the amount of repetitions of the same timer takes up all processing power.

I will be greatful for any kind of guidance on the matter, since I have already spent long hours trying to find out what the problem is.

The timer is:
pawn Код:
PublicFunc::Sekundnik(){
    new Keys, ud, lr;
    printf("global_1_second_timer_value");
    foreach (new i : Player)
    {
        if(PlayerInfo[i][pLogged_In] == 0) continue;
        if(Security_command_timer[i] != 0) Security_command_timer[i]--;
        if(CzasRozmowy[i] > 0)
        {
            if(CzasRozmowy[i] == 30)
            {
                CzasRozmowy[i] = 0;
                DisablePlayerCheckpoint(i);
                PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
                GameTextForPlayer(i, "~r~Marker znikl!", 2500, 1);
            }
            else
            {
                format(string, sizeof(string), "%d", 30 - CzasRozmowy[i]);
                GameTextForPlayer(i, string, 1500, 6);
                CzasRozmowy[i] += 1;
            }
        }
        else if(CellTime[i] > 0)
        {
            if (CellTime[i] == cchargetime)
            {
                CellTime[i] = 1;
                if(Mobile[Mobile[i]] == i)
                {
                    CallCost[i] = CallCost[i]+CallCostGit[i];
                }
            }
            CellTime[i] = CellTime[i] +1;
            if (Mobile[Mobile[i]] == 255 && CellTime[i] == 5)
            {
                if(IsPlayerConnected(Mobile[i]))
                {
                    PlayerPlaySound_Prox(Mobile[i], SOUND_MOBRING);
                    CellTime[i] = 1;
                }
            }
        }
        else if(CellTime[i] == 0 && CallCost[i] > 0)
        {
            format(string, sizeof(string), "~w~Koszt polaczenia:~n~~r~$%d",CallCost[i]);
            ZabierzKase(i, -CallCost[i]);
            GameTextForPlayer(i, string, 5000, 1);
            CallCost[i] = 0;
        }
       
        if(TaxiTime[i] > 0)
        {
            if(TaxiTime[i] >= 16)
            {
                TaxiTime[i] = 1;
                if(TaxiDriver[i] < 999)
                {
                    if(IsPlayerConnected(TaxiDriver[i]))
                    {
                        TaxiCost[i] += TaxiValue[TaxiDriver[i]];
                        TaxiCost[TaxiDriver[i]] = TaxiCost[i];
                    }
                }
            }
            TaxiTime[i] += 1;
            format(string, sizeof(string), "~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~w~%d ~w~: ~y~$%d", TaxiTime[i], TaxiCost[i]);
            GameTextForPlayer(i, string, 15000, 6);
        }
        if(GetPlayerState(i) == PLAYER_STATE_ONFOOT)
        {
            if(PlayerInfo[i][pAfter_Login_Timer] != 0)   PlayerInfo[i][pAfter_Login_Timer]--;
           
            GetPlayerKeys(i, Keys, ud, lr);
            if( (ud == KEY_UP || ud == KEY_DOWN || lr == KEY_RIGHT || lr == KEY_LEFT) && Keys != KEY_WALK)
            {
                new Float:fatigue_increased_by;
                if(Keys != KEY_SPRINT)
                {
                         if(PlayerInfo[i][pSkill_Stamina] < 2000) fatigue_increased_by = -3.0;
                    else if(PlayerInfo[i][pSkill_Stamina] < 4000) fatigue_increased_by = -2.0;
                    else if(PlayerInfo[i][pSkill_Stamina] < 6000) fatigue_increased_by = -1.0;
                   
                         if(PlayerInfo[i][pDrug] == DRUG_CRACK)     fatigue_increased_by = ( fatigue_increased_by / 3.0 );
                    else if(PlayerInfo[i][pDrug] == DRUG_COCAINE)   fatigue_increased_by = ( fatigue_increased_by / 2.0 );
                    else if(PlayerInfo[i][pDrug] == DRUG_AMFA)      fatigue_increased_by = ( fatigue_increased_by / 1.5 );
                         
                    UpdatePlayerFatigueLevel(i, fatigue_increased_by);
                }
                else
                {
                         if(PlayerInfo[i][pSkill_Stamina] < 2000)   fatigue_increased_by = -5.0;
                    else if(PlayerInfo[i][pSkill_Stamina] < 4000)   fatigue_increased_by = -4.0;
                    else if(PlayerInfo[i][pSkill_Stamina] < 6000)   fatigue_increased_by = -3.0;
                    else if(PlayerInfo[i][pSkill_Stamina] < 8000)   fatigue_increased_by = -2.0;
                    else if(PlayerInfo[i][pSkill_Stamina] <= 10000) fatigue_increased_by = -1.0;
                   
                         if(PlayerInfo[i][pDrug] == DRUG_CRACK)     fatigue_increased_by = ( fatigue_increased_by / 2.0 );
                    else if(PlayerInfo[i][pDrug] == DRUG_COCAINE)   fatigue_increased_by = ( fatigue_increased_by / 1.5 );
                    else if(PlayerInfo[i][pDrug] == DRUG_AMFA)      fatigue_increased_by = ( fatigue_increased_by / 1.2 );

                    UpdatePlayerFatigueLevel(i, fatigue_increased_by);
                }
                if(Keys == KEY_JUMP)    UpdatePlayerFatigueLevel(i, -5.0);
                if(GetPlayerProgressBarValue(i, Fatigue_Bar[i]) < 2)
                {
                    UpdatePlayerFatigueLevel(i, 5.0);
                    OnPlayerPlayAnim(i, "ped", "IDLE_TIRED", 3.0, 1, 0, 0, 0, 6000, 1);
                    gPlayerUsingLoopingAnim[i] = 69;
                    SetTimerEx("FatigueFunc", 6000, false, "i", i);
                    Error_Message(i, "Jestes ~y~[ zmeczony ]~w~i nie mozesz dalej biec zanim nie zlapiesz oddechu.");
                }
            }
            else
            {
                if(GetPlayerProgressBarValue(i, Fatigue_Bar[i]) != 100.0)
                {
                    UpdatePlayerFatigueLevel(i, 2.0);
                    if(GetPlayerProgressBarValue(i, Fatigue_Bar[i]) > 98.0) continue;
                }
            }
        }
        else
        {
            if(GetPlayerProgressBarValue(i, Fatigue_Bar[i]) != 100.0)
            {
                UpdatePlayerFatigueLevel(i, 2.0);
                if(GetPlayerProgressBarValue(i, Fatigue_Bar[i]) > 98.0) continue;
            }
        }
    }
    // Zamiana za timery - Manualne sprawdzanie, ale bez obciazania CPU
    global_5_second_timer_value++;
    global_20_second_timer_value++;
    global_60_second_timer_value++;
    global_300_second_timer_value++;
    global_600_second_timer_value++;
    global_900_second_timer_value++;

    if(global_5_second_timer_value > 5)
    {
        global_5_second_timer_value = 0;
        printf("global_5_second_timer_value");
        return Piec_Sekund(), 1;
    }
    else if(global_20_second_timer_value > 20)
    {
        global_20_second_timer_value = 0;
        printf("global_20_second_timer_value");
        return Dwadziescia_Sekund(), 1;
    }
    else if(global_60_second_timer_value > 60)
    {
        global_60_second_timer_value = 0;
        printf("global_60_second_timer_value");
        return Minuta(), 1;
    }
    else if(global_300_second_timer_value > 300)
    {
        global_300_second_timer_value = 0;
        printf("global_300_second_timer_value");
        return Piec_Minut(), 1;
    }
    else if(global_600_second_timer_value > 600)
    {
        global_600_second_timer_value = 0;
        printf("global_600_second_timer_value");
        return Dziesiec_Minut(), 1;
    }
    else if(global_900_second_timer_value > 900)
    {
        global_900_second_timer_value = 0;
        printf("global_900_second_timer_value");
        return Pietnascie_Minut(), 1;
    }
    else return 1;
}
Код:
[11:57:10] global_1_second_timer_value
[11:57:10] global_5_second_timer_value
[11:57:12] global_1_second_timer_value
[11:57:14] global_1_second_timer_value
[11:57:16] global_1_second_timer_value
[11:57:18] global_1_second_timer_value
[11:57:20] global_1_second_timer_value
[11:57:20] global_5_second_timer_value
[11:57:22] global_1_second_timer_value
[11:57:24] global_1_second_timer_value
[11:57:24] global_20_second_timer_value
[11:57:26] global_1_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_5_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_5_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_5_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_1_second_timer_value
[11:57:27] global_1_second_timer_value
Reply
#2

Quote:

Timers are timed by your computer time, meaning. Your VPS may have the wrong time set.

Regards
Reply
#3

Removed ******'s fixes2.so plugin and the problem is solved. Perhaps the version that I had installed was out of date. In any case, the problem is gone.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)