Timers or MYSQL cause super lag?
#1

I don't know what to think. I have too many timers with 500 milliseconds and 1000 and maybe a mysql bug?

What can causes super lag like when a player can't connect to the server?

It says Loading server... and freeze the game when the server its online some hours.


What the hell is goin on?

THANKS for all and please help me.
Reply
#2

I can only think of a few things that would cause the server to be inaccessible.

A for/while loop that never stops.
A 0 millisecond timer that repeats.

Nothing else comes to mind.
Reply
#3

Quote:
Originally Posted by Joe Staff
I can only think of a few things that would cause the server to be inaccessible.

A for/while loop that never stops.
A 0 millisecond timer that repeats.

Nothing else comes to mind.
To stop a for/while loop what do you must to do? Thanks.
Reply
#4

Depends on the type of loop
for loops should generally look like this
pawn Код:
for(new variable; variable< NUMBER; variable++)
{
  //Functions
}
Variable is being added by 1 per loop, and it will keep looping and adding to Variable until variable is less than (<) NUMBER, so once Variable equals NUMBER, the loop will stop.

While loops are the same but they don't have the adding of the variable implemented
pawn Код:
new variable;
while(variable<NUMBER)
{
  //Functions
  variable++;
}
Here variable is added to in the loop.

Regardless if you're adding to variable or subtracting from it, the condition of Variable<NUMBER has to be met. So you can have something like this:
pawn Код:
new Variable=random(50);
while(IsNumberUsed[Variable])Variable=random(50);
This loop will keep making 'Variable' a random number between 0 and 49 until 'IsNumberUsed[Variable]' is 0. This method can be used to let you create random things without picking the same number twice.
Reply
#5

Thanks. I have a timer that I make with a for.
pawn Код:
public detectorarmas()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
        new arma = GetPlayerWeapon(i);
        new ammo = GetPlayerAmmo(i);
      if(arma == 23 || arma == 24)
      {
      if(ammo <= 5)
      {
      PlayerInfo[i][pGun2] = 0;
      PlayerInfo[i][pAmmo2] = 0;
      }
      }
      else if(arma == 29 || arma == 25)
      {
      if(ammo <= 5)
      {
      PlayerInfo[i][pGun3] = 0;
      PlayerInfo[i][pAmmo3] = 0;
      }
      }
      else if(arma == 30 || arma == 31 || arma == 33)
      {
      if(ammo <= 5)
      {
      PlayerInfo[i][pGun4] = 0;
      PlayerInfo[i][pAmmo4] = 0;
      }
      }
      }
      }
return 1;
}
For example that 500 millisecond timer will cause mega lag?

Thanks for all help.
Reply
#6

If you you have MySQL code under OnPlayerUpdate you should rename it.
Reply
#7

Quote:
Originally Posted by MadeMan
If you you have MySQL code under OnPlayerUpdate you should rename it.
I don't use OnPlayerUpdate. I use my own OnPlayerUpdate2.

What do you mean to rename it? Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)