What can cause lags in server?
#1

Hello. My server currently is massive lagging. Tried 2 hosts, also a VPS an it still lags as hell. Hosting company even sent me a message saying my server is going on 100 percent CPU usage, for me to fix my scripts...

What can cause lag? I saw all.. Timers are not that much, some 5. I killed them all.. They are all about vehicle stuff, and all are killed under OnPlayerExit vehicle.

After restart, lag is gone, but thenn after some time, it starts to increase and increase,and it takes like one or two minutes to see the messages what we've wrote in chat.

Anyway i could put something in the script to see where lag comes from?

Thank you for any help.
Reply
#2

Does the lag continues all the time if you don't restart or are like strikes?

Btw, when you say your hosting company sent you a message, they say it is good? Or it is running at 100%? They usualy only send that message when something is wrong. If it's the case, it's for sure your script.
Reply
#3

Your script needs to be more efficient with optomizations.

I recommend you to read the following tutorial made by ***** it might help you making your code even better then the previous laggy script.

https://sampforum.blast.hk/showthread.php?tid=57018

Hope this helps a bit
-FalconX
Reply
#4

Server is using a unique script(made from scratch) with ZCMD,sscanf.I really can't figure out what the heck is causing those lags.After a restart everything runs in their norms,after some twenty-thirty minutes there starts the hell,massive lags.
Reply
#5

Quote:
Originally Posted by markuss99
Посмотреть сообщение
Dear,FalconX.
Server is using a unique script(made from scratch) with ZCMD,sscanf.I really can't figure out what the heck is causing those lags.After a restart everything runs in their norms,after some twenty-thirty minutes there starts the hell,massive lags.
Hmm, well I think it's the only problem but yes you could check other hosting company like KingJ or Volt ? It's kind of stranger if the script is very efficient and unique and the server is lagging. There are 2 possibilities as far as I've observed:-

1) Bad Script

OR

2) Bad Hosting Services

Not sure which one so you could send a ticket to your host and asking them if the problem is rising from the back. You must check OnPlayerUpdate btw

-FalconX
Reply
#6

It couldn't be bad script or bad hosting services,script is quite advanced.It's some few days when server is running.I've changed more times host,actually this is the 3nd one which I'm using for this unique game-mode, and hosting services still are saying that server runs fine.It couldn't be bad script,probably somewhere is a fault in script which causes the lag.Once server was lagging pretty hard when players were using vehicles,it caused the lag,but it's solved and it doesn't anymore(same for walking in one place,where's more people)

As well server was pretty bad lagging when we reached more players..
Reply
#7

What do you have under OnPlayerUpdate?
Reply
#8

pawn Код:
f_InPlayerUpdate(playerid); is only called when we create fire, and the lags come from before.

Other timers are only called every 30 seconds for vehicle ones, and there is one every half second, for speedo..
public OnPlayerUpdate(playerid)
{
   f_OnPlayerUpdate(playerid);
   return 1;
}
Reply
#9

Show the function"f_OnPlayerUpdate(playerid)" if there's a lot of (inefficient) code or large loops inside it, that's your problem.

Also check your code for large loops and see if you can think of a way to replace them.
Reply
#10

This code is in a .inc include. It's about fire script.
pawn Код:
public f_OnPlayerUpdate(playerid)
{
   new newkeys,l,u;
   GetPlayerKeys(playerid, newkeys, l, u);
   new i;
   if(Holding(KEY_FIRE))
   {
        if(GetPlayerWeapon(playerid) == 42)
        {
            for(i = 0; i<MaxFire; i++)
            {
                 if(IsValidFire(i))
                 {
                  if(PlayerFaces(playerid, FirePos[0],  FirePos[1],  FirePos[2], 1) && IsPlayerInRangeOfPoint(playerid, 4, FirePos[0],  FirePos[1],  FirePos[2]))
                   {
                       FireHealth-=2;
                    #if defined Labels
                     new string[128];
                     format(string, sizeof(string), "%d/%d", FireHealth, FireHealthMax);
                     Update3DTextLabelText(FireText, 0xFFFFFFFF, string);
                     Delete3DTextLabel(FireText);
                     FireText = Create3DTextLabel(string, 0xFFFFFFFF, FirePos[0],  FirePos[1],  FirePos[2], 20, 0);
                     #endif
                     if(FireHealth <= 0)
                     {
                        DeleteFire(i);
                        CallRemoteFunction("OnFireDeath", "dd", i, playerid);
                     }
               }
            }
         }
      }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)