Server lag
#1

My server is lagged and I saw somewhere that using ONPLAYERUPDATE script cause lag on a server. I don't use any line there but i made a 1000ms timer where i put almost 2,400 script lines. Could it be the cause of the lag?


Example:

ongamemoedinit:
Код HTML:
SetTimer("timer", 1000, 1);
and
Код HTML:
forward timer();
public timer()
{
  almost 2,400 script lines
  return 1;
}
Reply
#2

It really depends on what you are doing there. You can go in-game and see. Also OnPlayerUpdate doesn't lag the server unless you have a lot of code there. A few things won't do anything bad.
Reply
#3

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
You can just go in-game and see..
I told you already that my server is lagged. What can I see in game? I asked something else.

i use more than 2000 lines in a timer who's repeating every second. It could be the reason for that lag?
Reply
#4

Quote:
Originally Posted by Nin9r
Посмотреть сообщение
I told you already that my server is lagged. What can I see in game? I asked something else.

i use more than 2000 lines in a timer who's repeating every second. It could be the reason for that lag?
You never said your server was lagging. You only asked if it could cause lag. As I said it depends on what you are doing there. If you want an answer, then yes, it could be the reason of lag.
Reply
#5

Can I split it in 2 different timers?

For example, some scripts is absolutely necesary to increase or decrease a value per second ( it remains in timer ). I will create another timer who's repeating every 10 seconds. ( there i will put the rest of the scripts who's checking other things (without increase/decrease value)).

It could reduce that lag? It is more efficient?
Reply
#6

Quote:
Originally Posted by Nin9r
Посмотреть сообщение
Can I split it in 2 different timers?

For example, some scripts is absolutely necesary to increase or decrease a value per second ( it remains in timer ). I will create another timer who's repeating every 10 seconds. ( there i will put the rest of the scripts who's checking other things (without increase/decrease value)).

It could reduce that lag? It is more efficient?
That would be better, yes.
Reply
#7

I checked again some scripts from that timer and I saw that i'm using a lot of queries in that timer, like:
Код HTML:
new str[256];
						format(str,128,"UPDATE `players` SET `Warns`='0' WHERE `playerID`='%d'",PlayerData[x][pSQLID]);
						mysql_tquery(handle,str);
It is a big problem because there are executed a lot of queries for all the connected players every second, isn't it?

But it is executed just in case. Like :
Код HTML:
if(PlayerData[playerid][pWarns] > 3)
{
 ban
 query
}
so, i guess that isn't the real problem from that lag.
Reply
#8

Comment the queries out and see if that fixes it... Chances are it will if you have so many queries on that timer...
Reply
#9

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Comment the queries out and see if that fixes it... Chances are it will if you have so many queries on that timer...
Yes, I have some queries. But there aren't always executed. Just after checking a 3/3 warns, 8/8 RP etc.
Reply
#10

Damn, don't use timers or OnPlayerUpdate for things that you yourself control. Variables don't change by themselves! Whenever you do "warns++" you should check the limit there and then. Do not really on a timer to do the work for you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)