CPU Help [+Rep for help]
#1

Hello,

I'm currently using VoltHost....Anytime I get around 4-5 people online the server crashes, and the CPU is up to like 100%. Is there any clue or suggestions that would help get this resolved? I'd appreciate if I can get a honest, or respectful response.
Reply
#2

see your "OnPlayerUpdate", or you have alot of settimers, which aren't getting "killed"
Reply
#3

This is all I have under OnPlayerUpdate

pawn Код:
public OnPlayerUpdate(playerid)
{
    // Do not put heavy cpu checks in here. Use the 1 second timer.
    return 1;
}

I use different timers thou, not sure if they're getting killed. Can you help me on how to make sure they are getting killed or to set it to kill.
Reply
#4

SetTimer: https://sampwiki.blast.hk/wiki/SetTimer
KillTimer: https://sampwiki.blast.hk/wiki/KillTimer

Take a look there, just because of the repeating of the timer, and not being killed, will do a high cpu usage.
Reply
#5

Okay,

but how do I know which Timer to kill?

Here are my repeating timers, what do I do to them or add to the script that will help reduce CPU Usage.
pawn Код:
/* Repeating Timers */

// Timer Name: MainMenuUpdate()
// TickRate: 10 Secs.
Timer:MainMenuUpdate[10000]()
{
    foreach(Player, i)
    {
        if(PlayersConnected > 490)
        {
            if(playerTabbedTime[i] > 60 && PlayerInfo[i][pShopTech] < 1 && PlayerInfo[i][pAdmin] < 4)
            {
                Kick(i);
            }
            else if(playerAFK[i] != 0 && playerAFKTime[i] > 300 && PlayerInfo[i][pShopTech] < 1 && PlayerInfo[i][pAdmin] < 4)
            {
                Kick(i);
            }
        }
        new string[768];
        if(InsideMainMenu[i] == 1)
        {
            TextDrawSetString(MainMenuTxtdraw[7], Tooltips[random(sizeof(Tooltips))]);
            format(string, sizeof(string), "Logins: ~y~%d~w~ | Connections: ~y~%d~w~ | Registrations: ~y~%d~w~ | Hackers Autobanned: ~y~%d~w~ | Players Connected: ~y~%d~w~ | Peak Players: ~y~%d (%d/%d/%d)~w~", TotalLogin, TotalConnect, TotalRegister, TotalAutoBan, PlayersConnected, MaxPlayersConnected, MPDay,MPMonth,MPYear);
            TextDrawSetString(MainMenuTxtdraw[8], string);
            format(string, sizeof(string), "~y~MOTD~w~: %s", GlobalMOTD);
            TextDrawSetString(MainMenuTxtdraw[9], string);
            SetPlayerJoinCamera(i);
        }
        else if(InsideTut[i] == 1)
        {
            TextDrawSetString(MainMenuTxtdraw[7], Tooltips[random(sizeof(Tooltips))]);
            format(string, sizeof(string), "Logins: ~y~%d~w~ | Connections: ~y~%d~w~ | Registrations: ~y~%d~w~ | Hackers Autobanned: ~y~%d~w~ | Players Connected: ~y~%d~w~ | Peak Players: ~y~%d (%d/%d/%d)~w~", TotalLogin, TotalConnect, TotalRegister, TotalAutoBan, PlayersConnected, MaxPlayersConnected, MPDay,MPMonth,MPYear);
            TextDrawSetString(MainMenuTxtdraw[8], string);
            format(string, sizeof(string), "~y~MOTD~w~: %s", GlobalMOTD);
            TextDrawSetString(MainMenuTxtdraw[9], string);
        }
    }
}

// Timer Name: SyncUp()
// TickRate: 1 Minute.
Timer:SyncUp[60000]()
{
    new string[128];
    new hour,minuite,second;

    SyncTime();
    SyncMinTime();
    DollahScoreUpdate();

    gettime(hour,minuite,second);
    FixHour(hour);
    hour = shifthour;
    if(minuite < 10)
    {
        format(string, sizeof(string), "%d:0%d", hour, minuite);
    }
    else
    {
        format(string, sizeof(string), "%d:%d", hour, minuite);
    }
    TextDrawSetString(WristWatch, string);

    foreach(Player, i)
    {
        SendBlankAudioTick(i);
        if(PlayerInfo[i][pProbationTime] > 0 && !PlayerInfo[i][pBeingSentenced])
        {
            PlayerInfo[i][pProbationTime]--;
        }
        if(PlayerInfo[i][pBeingSentenced] > 1) PlayerInfo[i][pBeingSentenced]--;
        if(PlayerInfo[i][pBeingSentenced] == 1)
        {
            TogglePlayerControllable(i, true);
            SetPVarInt(i, "IsFrozen", 0);
            //Frozen[i] = 0;
            SetPlayerPos(i, 1415.5137,-1702.2272,13.5395);
            SetPlayerFacingAngle(i, 240.0264);
            SendClientMessageEx(i, COLOR_WHITE, "No Judge has attended your pending trial, you are free!");
            PlayerInfo[i][pBeingSentenced] = 0;
        }
    }
}

// Timer Name: SaveAccountsUpdate()
// TickRate: 5 Minutes.
Timer:SaveAccountsUpdate[300000]()
{
    new playerip[32];
    foreach(Player, i)
    {
            PlayerInfo[i][pInt] = GetPlayerInterior(i);
            PlayerInfo[i][pVW] = GetPlayerVirtualWorld(i);
            PlayerInfo[i][pChar] = PlayerInfo[i][pModel];
            GetPlayerIp(i, playerip, sizeof(playerip));
            format(PlayerInfo[i][pIP], 32, "%s", playerip);
            GetPlayerPos(i, PlayerInfo[i][pPos_x], PlayerInfo[i][pPos_y], PlayerInfo[i][pPos_z]);
            GetPlayerFacingAngle(i, PlayerInfo[i][pPos_r]);
            OnPlayerStatsUpdate(i);
    }
    SaveFamilies();
    SaveFamiliesHQ();
}

// Timer Name: ProductionUpdate()
// TickRate: 5 Minutes.
Timer:ProductionUpdate[300000]()
{
    AdvisorMessage++;
    foreach(Player, i)
    {
            if(AdvisorMessage == 3 && Advisors > 0 && PlayerInfo[i][pLevel] < 4)
            {
                SendClientMessageEx(i, COLOR_LIGHTBLUE, "Need help? The Community Advisors are here to help you. (/cahelp to get help)");
            }

            if(PlayerInfo[i][pGiftTime] > 0) { PlayerInfo[i][pGiftTime] -= 5; }
            if(PlayerInfo[i][pFishes] >= 5) { if(FishCount[i] >= 3) { PlayerInfo[i][pFishes] = 0; } else { FishCount[i] += 1; } }
            if(PlayerDrunk[i] > 0) { PlayerDrunk[i] = 0; PlayerDrunkTime[i] = 0; GameTextForPlayer(i, "~p~Drunk effect~n~~w~Gone", 3500, 1); }
            if(playerTabbed[i] != 1)
            {
                if(PlayerInfo[i][pPayDay] < 6) { PlayerInfo[i][pPayDay] += 1; } //+ 5 min to PayDay anti-abuse
            }
    }
    if(AdvisorMessage == 3) AdvisorMessage = 0;
    SaveFamilies();
    if(VIPGiftsTimeLeft > 0 && VIPGifts == 1)
    {
        VIPGiftsTimeLeft -= 5;
        if(VIPGiftsTimeLeft > 0)
        {
            new string[128];
            format(string, sizeof(string), "%s would like for you to come to Club VIP for free gifts and great times [%d minutes remains]", VIPGiftsName, VIPGiftsTimeLeft);
            SendVIPMessage(COLOR_LIGHTGREEN, string);
        }
    }
    if(VIPGiftsTimeLeft <= 0 && VIPGifts == 1)
    {
        VIPGiftsTimeLeft = 0;
        VIPGifts = 0;
        new string[128];
        format(string, sizeof(string), "Club VIP is no longer giving away free gifts. Thanks for coming!", VIPGiftsName, VIPGiftsTimeLeft);
        SendVIPMessage(COLOR_LIGHTGREEN, string);
    }
}


// Timer Name: playerTabbedLoop()
// TickRate: 1 secs.
Timer:playerTabbedLoop[1000]()
{
    foreach(Player, x)
    {
        playerConnectedS[x]++;
        if(playerSeconds[x] < gettime()-1 && playerTabbed[x] != 1 && playerConnectedS[x] >= 5 && 1 <= GetPlayerState(x) <= 3)
        {
            playerTabbed[x] = 1;
            SetTimerEx("AFKick",1000,false,"d", x);
        }
        playerLastTyped[x]++;
        GetPlayerPos(x, PlayerPos[x][0], PlayerPos[x][1], PlayerPos[x][2]);
        if(PlayerPos[x][0] == PlayerPos[x][3] && PlayerPos[x][1] == PlayerPos[x][4] && PlayerPos[x][2] == PlayerPos[x][5] && playerTabbed[x] != 1)
        {
            if(playerLastTyped[x] < playerAFKTime[x]) playerAFKTime[x] = playerLastTyped[x];
            if(playerAFK[x] != 0) playerAFKTime[x]++;
            else playerAFK[x] = 1;
            if(playerAFKTime[x] >= 900 && PlayerInfo[x][pAdmin] < 1337)
            {
                SendClientMessageEx(x, COLOR_WHITE, "You have been kicked for being AFK more than 15 minutes.");
                Kick(x);
            }
        }
        else
        {
            if(playerAFK[x] != 0) playerAFK[x] = 0, playerAFKTime[x] = 0;
        }
        PlayerPos[x][3] = PlayerPos[x][0];
        PlayerPos[x][4] = PlayerPos[x][1];
        PlayerPos[x][5] = PlayerPos[x][2];
    }
}

// Timer Name: MoneyUpdate()
// TickRate: 1 secs.
Timer:MoneyUpdate[1000]()
{
    new hour,minuite,second;
    gettime(hour,minuite,second);
    FixHour(hour);
    hour = shifthour;
    new tstring[7];
    if(minuite < 10)
    {
        format(tstring, sizeof(tstring), "%d:0%d", hour, minuite);
    }
    else
    {
        format(tstring, sizeof(tstring), "%d:%d", hour, minuite);
    }
    TextDrawSetString(WristWatch, tstring);


    foreach(Player, i)
    {
        SyncPlayerTime(i);
        if(gPlayerLogged{i})
        {
            if(GetPlayerPing(i) > MAX_PING)
            {
                if(playerTabbed[i] != 1)
                {
                    new
                        string[89 + MAX_PLAYER_NAME];

                    format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s has just been kicked for %d ping (maximum: "#MAX_PING").", GetPlayerNameEx(i), GetPlayerPing(i));
                    ABroadCast(COLOR_YELLOW, string, 2);
                    SendClientMessageEx(i, COLOR_WHITE, "You have been kicked because your ping is higher than the maximum.");
                    Kick(i);
                }
            }

            if(PlayerInfo[i][pTempVIP] >= 1)
            {
                PlayerInfo[i][pTempVIP]--;
            }

            if(PlayerInfo[i][pTempVIP] <= 0 && PlayerInfo[i][pBuddyInvited] == 1)
            {
                PlayerInfo[i][pTempVIP] = 0;
                PlayerInfo[i][pBuddyInvited] = 0;
                PlayerInfo[i][pDonateRank] = 0;
                SendClientMessageEx(i, COLOR_LIGHTBLUE, "Your temporary VIP subscription has expired.");
                SetPlayerToTeamColor(i);
            }
            if(PlayerInfo[i][pTriageTime] != 0)
            {
                PlayerInfo[i][pTriageTime]--;
            }
            if(PlayerInfo[i][pTicketTime] != 0)
            {
                PlayerInfo[i][pTicketTime]--;
            }
            if(PlayerInfo[i][pServiceTime] != 0)
            {
                PlayerInfo[i][pServiceTime]--;
            }
            if(GetPlayerCash(i) != GetPlayerMoney(i))
            {
                ResetMoneyBar(i);
                UpdateMoneyBar(i,GetPVarInt(i, "Cash"));
            }
            if(GetPVarInt(i, "gpsonoff") == 1)
            {
                new zone[28];
                GetPlayer2DZone(i, zone, MAX_ZONE_NAME);
                TextDrawSetString(GPS[i], zone);
            }
            if(GetPVarInt(i, "fuelonoff") == 1)
            {
                if(IsPlayerInAnyVehicle(i))
                {
                    SetProgressBarValue(FuelBar[i], VehicleFuel[GetPlayerVehicleID(i)]);
                    UpdateProgressBar(FuelBar[i], i);
                }
                else
                {
                    DeletePVar(i, "fuelonoff");
                    DestroyProgressBar(FuelBar[i]);
                    textdrawscount--;
                    FuelBar[i] = INVALID_BAR_ID;
                }
            }
        }
    }
}

// Timer Name: SpecUpdate()
// TickRate: 3 secs.
Timer:SpecUpdate[3000]()
{
    foreach(Player, i)
    {
        if(PlayerInfo[i][pAdmin] >= 2)
        {
            if(Spectating[i] >= 1)
            {
                if(Spectate[i] < 553)
                {
                    new targetid = Spectate[ i ];
                    if( !IsPlayerConnected( targetid ) )
                    {
                        SendClientMessageEx( i, COLOR_WHITE, "The player you were spectating has left the server." );
                        GettingSpectated[Spectate[i]] = 999;
                        Spectating[i] = 0;
                        Spectate[i] = 999;
                        SetPVarInt(i, "SpecState", -1);
                        SetPVarInt(i, "SpecOff", 1 );
                        TogglePlayerSpectating( i, false );
                        SetCameraBehindPlayer(i);
                    }
                }
                if(Spectate[i] == 553)
                {
                    TogglePlayerControllable(i, 1);
                    TogglePlayerSpectating(i, 0);
                    DeletePVar(i, "MedicBill");
                    SpawnPlayer( i );
                    Spectate[i] = 999;
                    Spectating[i] = 0;
                }
                if(Spectate[i] == 554)
                {
                    TogglePlayerControllable(i, 1);
                    SetPlayerInterior(i,Unspec[i][sPint]);
                    PlayerInfo[i][pInt] = Unspec[i][sPint];
                    PlayerInfo[i][pLocal] = Unspec[i][sLocal];
                    SetPlayerPos(i, Unspec[i][Coords][0], Unspec[i][Coords][1], Unspec[i][Coords][2]);
                    Spectate[i] = 999;
                }
                if(Spectate[i] == 556)
                {
                    SetPlayerToTeamColor(i);
                    Spectate[i] = 999;
                }
                if(Spectate[i] == 557)
                {
                    Spectate[i] = 554;
                }
            }
        }
    }
}

// Timer Name: SaveAccountsUpdate()
// TickRate: 5 Minutes.
Timer:SaveAccountsUpdate[300000]()
{
    new playerip[32];
    foreach(Player, i)
    {
            PlayerInfo[i][pInt] = GetPlayerInterior(i);
            PlayerInfo[i][pVW] = GetPlayerVirtualWorld(i);
            PlayerInfo[i][pChar] = PlayerInfo[i][pModel];
            GetPlayerIp(i, playerip, sizeof(playerip));
            format(PlayerInfo[i][pIP], 32, "%s", playerip);
            GetPlayerPos(i, PlayerInfo[i][pPos_x], PlayerInfo[i][pPos_y], PlayerInfo[i][pPos_z]);
            GetPlayerFacingAngle(i, PlayerInfo[i][pPos_r]);
            OnPlayerStatsUpdate(i);
    }
    SaveFamilies();
    SaveFamiliesHQ();
}
Reply
#6

First of all, do a backup to your gamemode / filterscript, whatever where the timers are located.
Second, replace the code with this one:
pawn Код:
/* Repeating Timers */

// Timer Name: MainMenuUpdate()
// TickRate: 10 Secs.
Timer:MainMenuUpdate[10000]()
{
    KillTimer(MainMenuUpdate());
    foreach(Player, i)
    {
        if(PlayersConnected > 490)
        {
            if(playerTabbedTime[i] > 60 && PlayerInfo[i][pShopTech] < 1 && PlayerInfo[i][pAdmin] < 4)
            {
                Kick(i);
            }
            else if(playerAFK[i] != 0 && playerAFKTime[i] > 300 && PlayerInfo[i][pShopTech] < 1 && PlayerInfo[i][pAdmin] < 4)
            {
                Kick(i);
            }
        }
        new string[768];
        if(InsideMainMenu[i] == 1)
        {
            TextDrawSetString(MainMenuTxtdraw[7], Tooltips[random(sizeof(Tooltips))]);
            format(string, sizeof(string), "Logins: ~y~%d~w~ | Connections: ~y~%d~w~ | Registrations: ~y~%d~w~ | Hackers Autobanned: ~y~%d~w~ | Players Connected: ~y~%d~w~ | Peak Players: ~y~%d (%d/%d/%d)~w~", TotalLogin, TotalConnect, TotalRegister, TotalAutoBan, PlayersConnected, MaxPlayersConnected, MPDay,MPMonth,MPYear);
            TextDrawSetString(MainMenuTxtdraw[8], string);
            format(string, sizeof(string), "~y~MOTD~w~: %s", GlobalMOTD);
            TextDrawSetString(MainMenuTxtdraw[9], string);
            SetPlayerJoinCamera(i);
        }
        else if(InsideTut[i] == 1)
        {
            TextDrawSetString(MainMenuTxtdraw[7], Tooltips[random(sizeof(Tooltips))]);
            format(string, sizeof(string), "Logins: ~y~%d~w~ | Connections: ~y~%d~w~ | Registrations: ~y~%d~w~ | Hackers Autobanned: ~y~%d~w~ | Players Connected: ~y~%d~w~ | Peak Players: ~y~%d (%d/%d/%d)~w~", TotalLogin, TotalConnect, TotalRegister, TotalAutoBan, PlayersConnected, MaxPlayersConnected, MPDay,MPMonth,MPYear);
            TextDrawSetString(MainMenuTxtdraw[8], string);
            format(string, sizeof(string), "~y~MOTD~w~: %s", GlobalMOTD);
            TextDrawSetString(MainMenuTxtdraw[9], string);
        }
    }
}

// Timer Name: SyncUp()
// TickRate: 1 Minute.
Timer:SyncUp[60000]()
{
    KillTimer(SyncUp());
    new string[128];
    new hour,minuite,second;

    SyncTime();
    SyncMinTime();
    DollahScoreUpdate();

    gettime(hour,minuite,second);
    FixHour(hour);
    hour = shifthour;
    if(minuite < 10)
    {
        format(string, sizeof(string), "%d:0%d", hour, minuite);
    }
    else
    {
        format(string, sizeof(string), "%d:%d", hour, minuite);
    }
    TextDrawSetString(WristWatch, string);

    foreach(Player, i)
    {
        SendBlankAudioTick(i);
        if(PlayerInfo[i][pProbationTime] > 0 && !PlayerInfo[i][pBeingSentenced])
        {
            PlayerInfo[i][pProbationTime]--;
        }
        if(PlayerInfo[i][pBeingSentenced] > 1) PlayerInfo[i][pBeingSentenced]--;
        if(PlayerInfo[i][pBeingSentenced] == 1)
        {
            TogglePlayerControllable(i, true);
            SetPVarInt(i, "IsFrozen", 0);
            //Frozen[i] = 0;
            SetPlayerPos(i, 1415.5137,-1702.2272,13.5395);
            SetPlayerFacingAngle(i, 240.0264);
            SendClientMessageEx(i, COLOR_WHITE, "No Judge has attended your pending trial, you are free!");
            PlayerInfo[i][pBeingSentenced] = 0;
        }
    }
}

// Timer Name: SaveAccountsUpdate()
// TickRate: 5 Minutes.
Timer:SaveAccountsUpdate[300000]()
{
    KillTimer(SaveAccountsUpdate());
    new playerip[32];
    foreach(Player, i)
    {
            PlayerInfo[i][pInt] = GetPlayerInterior(i);
            PlayerInfo[i][pVW] = GetPlayerVirtualWorld(i);
            PlayerInfo[i][pChar] = PlayerInfo[i][pModel];
            GetPlayerIp(i, playerip, sizeof(playerip));
            format(PlayerInfo[i][pIP], 32, "%s", playerip);
            GetPlayerPos(i, PlayerInfo[i][pPos_x], PlayerInfo[i][pPos_y], PlayerInfo[i][pPos_z]);
            GetPlayerFacingAngle(i, PlayerInfo[i][pPos_r]);
            OnPlayerStatsUpdate(i);
    }
    SaveFamilies();
    SaveFamiliesHQ();
}

// Timer Name: ProductionUpdate()
// TickRate: 5 Minutes.
Timer:ProductionUpdate[300000]()
{
    KillTimer(ProductionUpdate());
    AdvisorMessage++;
    foreach(Player, i)
    {
            if(AdvisorMessage == 3 && Advisors > 0 && PlayerInfo[i][pLevel] < 4)
            {
                SendClientMessageEx(i, COLOR_LIGHTBLUE, "Need help? The Community Advisors are here to help you. (/cahelp to get help)");
            }

            if(PlayerInfo[i][pGiftTime] > 0) { PlayerInfo[i][pGiftTime] -= 5; }
            if(PlayerInfo[i][pFishes] >= 5) { if(FishCount[i] >= 3) { PlayerInfo[i][pFishes] = 0; } else { FishCount[i] += 1; } }
            if(PlayerDrunk[i] > 0) { PlayerDrunk[i] = 0; PlayerDrunkTime[i] = 0; GameTextForPlayer(i, "~p~Drunk effect~n~~w~Gone", 3500, 1); }
            if(playerTabbed[i] != 1)
            {
                if(PlayerInfo[i][pPayDay] < 6) { PlayerInfo[i][pPayDay] += 1; } //+ 5 min to PayDay anti-abuse
            }
    }
    if(AdvisorMessage == 3) AdvisorMessage = 0;
    SaveFamilies();
    if(VIPGiftsTimeLeft > 0 && VIPGifts == 1)
    {
        VIPGiftsTimeLeft -= 5;
        if(VIPGiftsTimeLeft > 0)
        {
            new string[128];
            format(string, sizeof(string), "%s would like for you to come to Club VIP for free gifts and great times [%d minutes remains]", VIPGiftsName, VIPGiftsTimeLeft);
            SendVIPMessage(COLOR_LIGHTGREEN, string);
        }
    }
    if(VIPGiftsTimeLeft <= 0 && VIPGifts == 1)
    {
        VIPGiftsTimeLeft = 0;
        VIPGifts = 0;
        new string[128];
        format(string, sizeof(string), "Club VIP is no longer giving away free gifts. Thanks for coming!", VIPGiftsName, VIPGiftsTimeLeft);
        SendVIPMessage(COLOR_LIGHTGREEN, string);
    }
}


// Timer Name: playerTabbedLoop()
// TickRate: 1 secs.
Timer:playerTabbedLoop[1000]()
{
    KillTimer(playerTabbedLoop());
    foreach(Player, x)
    {
        playerConnectedS[x]++;
        if(playerSeconds[x] < gettime()-1 && playerTabbed[x] != 1 && playerConnectedS[x] >= 5 && 1 <= GetPlayerState(x) <= 3)
        {
            playerTabbed[x] = 1;
            SetTimerEx("AFKick",1000,false,"d", x);
        }
        playerLastTyped[x]++;
        GetPlayerPos(x, PlayerPos[x][0], PlayerPos[x][1], PlayerPos[x][2]);
        if(PlayerPos[x][0] == PlayerPos[x][3] && PlayerPos[x][1] == PlayerPos[x][4] && PlayerPos[x][2] == PlayerPos[x][5] && playerTabbed[x] != 1)
        {
            if(playerLastTyped[x] < playerAFKTime[x]) playerAFKTime[x] = playerLastTyped[x];
            if(playerAFK[x] != 0) playerAFKTime[x]++;
            else playerAFK[x] = 1;
            if(playerAFKTime[x] >= 900 && PlayerInfo[x][pAdmin] < 1337)
            {
                SendClientMessageEx(x, COLOR_WHITE, "You have been kicked for being AFK more than 15 minutes.");
                Kick(x);
            }
        }
        else
        {
            if(playerAFK[x] != 0) playerAFK[x] = 0, playerAFKTime[x] = 0;
        }
        PlayerPos[x][3] = PlayerPos[x][0];
        PlayerPos[x][4] = PlayerPos[x][1];
        PlayerPos[x][5] = PlayerPos[x][2];
    }
}

// Timer Name: MoneyUpdate()
// TickRate: 1 secs.
Timer:MoneyUpdate[1000]()
{
    KillTimer(MoneyUpdate());
    new hour,minuite,second;
    gettime(hour,minuite,second);
    FixHour(hour);
    hour = shifthour;
    new tstring[7];
    if(minuite < 10)
    {
        format(tstring, sizeof(tstring), "%d:0%d", hour, minuite);
    }
    else
    {
        format(tstring, sizeof(tstring), "%d:%d", hour, minuite);
    }
    TextDrawSetString(WristWatch, tstring);


    foreach(Player, i)
    {
        SyncPlayerTime(i);
        if(gPlayerLogged{i})
        {
            if(GetPlayerPing(i) > MAX_PING)
            {
                if(playerTabbed[i] != 1)
                {
                    new
                        string[89 + MAX_PLAYER_NAME];

                    format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s has just been kicked for %d ping (maximum: "#MAX_PING").", GetPlayerNameEx(i), GetPlayerPing(i));
                    ABroadCast(COLOR_YELLOW, string, 2);
                    SendClientMessageEx(i, COLOR_WHITE, "You have been kicked because your ping is higher than the maximum.");
                    Kick(i);
                }
            }

            if(PlayerInfo[i][pTempVIP] >= 1)
            {
                PlayerInfo[i][pTempVIP]--;
            }

            if(PlayerInfo[i][pTempVIP] <= 0 && PlayerInfo[i][pBuddyInvited] == 1)
            {
                PlayerInfo[i][pTempVIP] = 0;
                PlayerInfo[i][pBuddyInvited] = 0;
                PlayerInfo[i][pDonateRank] = 0;
                SendClientMessageEx(i, COLOR_LIGHTBLUE, "Your temporary VIP subscription has expired.");
                SetPlayerToTeamColor(i);
            }
            if(PlayerInfo[i][pTriageTime] != 0)
            {
                PlayerInfo[i][pTriageTime]--;
            }
            if(PlayerInfo[i][pTicketTime] != 0)
            {
                PlayerInfo[i][pTicketTime]--;
            }
            if(PlayerInfo[i][pServiceTime] != 0)
            {
                PlayerInfo[i][pServiceTime]--;
            }
            if(GetPlayerCash(i) != GetPlayerMoney(i))
            {
                ResetMoneyBar(i);
                UpdateMoneyBar(i,GetPVarInt(i, "Cash"));
            }
            if(GetPVarInt(i, "gpsonoff") == 1)
            {
                new zone[28];
                GetPlayer2DZone(i, zone, MAX_ZONE_NAME);
                TextDrawSetString(GPS[i], zone);
            }
            if(GetPVarInt(i, "fuelonoff") == 1)
            {
                if(IsPlayerInAnyVehicle(i))
                {
                    SetProgressBarValue(FuelBar[i], VehicleFuel[GetPlayerVehicleID(i)]);
                    UpdateProgressBar(FuelBar[i], i);
                }
                else
                {
                    DeletePVar(i, "fuelonoff");
                    DestroyProgressBar(FuelBar[i]);
                    textdrawscount--;
                    FuelBar[i] = INVALID_BAR_ID;
                }
            }
        }
    }
}

// Timer Name: SpecUpdate()
// TickRate: 3 secs.
Timer:SpecUpdate[3000]()
{
    KillTimer(SpecUpdate());
    foreach(Player, i)
    {
        if(PlayerInfo[i][pAdmin] >= 2)
        {
            if(Spectating[i] >= 1)
            {
                if(Spectate[i] < 553)
                {
                    new targetid = Spectate[ i ];
                    if( !IsPlayerConnected( targetid ) )
                    {
                        SendClientMessageEx( i, COLOR_WHITE, "The player you were spectating has left the server." );
                        GettingSpectated[Spectate[i]] = 999;
                        Spectating[i] = 0;
                        Spectate[i] = 999;
                        SetPVarInt(i, "SpecState", -1);
                        SetPVarInt(i, "SpecOff", 1 );
                        TogglePlayerSpectating( i, false );
                        SetCameraBehindPlayer(i);
                    }
                }
                if(Spectate[i] == 553)
                {
                    TogglePlayerControllable(i, 1);
                    TogglePlayerSpectating(i, 0);
                    DeletePVar(i, "MedicBill");
                    SpawnPlayer( i );
                    Spectate[i] = 999;
                    Spectating[i] = 0;
                }
                if(Spectate[i] == 554)
                {
                    TogglePlayerControllable(i, 1);
                    SetPlayerInterior(i,Unspec[i][sPint]);
                    PlayerInfo[i][pInt] = Unspec[i][sPint];
                    PlayerInfo[i][pLocal] = Unspec[i][sLocal];
                    SetPlayerPos(i, Unspec[i][Coords][0], Unspec[i][Coords][1], Unspec[i][Coords][2]);
                    Spectate[i] = 999;
                }
                if(Spectate[i] == 556)
                {
                    SetPlayerToTeamColor(i);
                    Spectate[i] = 999;
                }
                if(Spectate[i] == 557)
                {
                    Spectate[i] = 554;
                }
            }
        }
    }
}

// Timer Name: SaveAccountsUpdate()
// TickRate: 5 Minutes.
Timer:SaveAccountsUpdate[300000]()
{
    KillTimer(SaveAccountsUpdate());
    new playerip[32];
    foreach(Player, i)
    {
            PlayerInfo[i][pInt] = GetPlayerInterior(i);
            PlayerInfo[i][pVW] = GetPlayerVirtualWorld(i);
            PlayerInfo[i][pChar] = PlayerInfo[i][pModel];
            GetPlayerIp(i, playerip, sizeof(playerip));
            format(PlayerInfo[i][pIP], 32, "%s", playerip);
            GetPlayerPos(i, PlayerInfo[i][pPos_x], PlayerInfo[i][pPos_y], PlayerInfo[i][pPos_z]);
            GetPlayerFacingAngle(i, PlayerInfo[i][pPos_r]);
            OnPlayerStatsUpdate(i);
    }
    SaveFamilies();
    SaveFamiliesHQ();
}
Idk if this works or not, since i don't have the all defines for the script and others.
If this gives any error , post here the errors.
but first, if it gives errors, try to remove the () from KillTimer, like:
pawn Код:
KillTimer(MainMenuUpdate());
to
pawn Код:
KillTimer(MainMenuUpdate);
Reply
#7

I got no errors, Thanks! I'll try this and tell you if it works fine!
Reply
#8

It's higher (with 0 on) then it was before...



and before i use to be between 2% and 4%
Reply
#9

Quote:
Originally Posted by Jhero
Посмотреть сообщение
It's higher (with 0 on) then it was before...



and before i use to be between 2% and 4%
Test with the users online first, the main usage(7%) isn't a big problem(for now), it counts later, with the players online.
I have a small gamemode(tdm), with no timers or things on the "OnPlayerUpdate", it uses more than 8%.
Reply
#10

Quote:
Originally Posted by kikito
Посмотреть сообщение
Test with the users online first, the main usage(7%) isn't a big problem(for now), it counts later, with the players online.
I have a small gamemode(tdm), with no timers or things on the "OnPlayerUpdate", it uses more than 8%.
This is with users online, at least 1 user.



This is when the user type's a command thou...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)