[REP++] server LAG, why?
#1

I use: MYSQL R39-6, ZMCD+SSCANF for commands. I have only 2 global timers. (1000ms / 4 seconds). I don't use "OnPlayerUpdate". To restriction command for a time use "gettime()". GM is optimized with various methods posted here on the forum. The server has lag when over 150 players online.
My include:
Код HTML:
#include <a_samp>
#include <a_mysql>
#include <a_zones>
#include <foreach>
#include <strlib>
#include <streamer>
#include <zcmd>
#include <getvcolor>
#include <sscanf2>
#include <mSelection>
The first global timer (1000ms) has 423 lines with "if", exemple:
Код HTML:
foreach(new i : Player)
{
    if(pInfo[i][pTog][6] == 1) -> TextDrawShow ... etc, etc
    if(Iter_Contains(Paintp, i) && PST > gtm) -> ... etc, etc code
    if(pInfo[i][pMute] > 0) -> ... etc, etc code
    if(pInfo[i][pWantedLevel] > 0 && !IsPlayerAttachedObjectSlotUsed(i, 3)) -> ... etc, etc code
    if(pInfo[i][pJailed] >= 1) -> ... etc, etc code
    if(IsPlayerInRangeOfPoint(i, 75.0, 1107.8771,-1794.3970,16.6937) || IsPlayerInRangeOfPoint(i, 85.0, 1217.0133,-1740.3961,13.5955) || IsPlayerInRangeOfPoint(i, 30.0, 1003.8006,-938.4607,42.2797) ||
        IsPlayerInRangeOfPoint(i, 30.0, 647.529,-1357.39,13.5784) || IsPlayerInRangeOfPoint(i, 45.0, -60.6408,-1128.0583,1.1781) ||
        IsPlayerInRangeOfPoint(i, 25.0, 2102.3037,2235.5540,11.0234) || IsPlayerInRangeOfPoint(i, 25.0, 1178.9655,-1323.4093,14.1461) || IsPlayerInRangeOfPoint(i, 25.0, 332.0587,-1516.1661,35.9672) ||
        IsPlayerInRangeOfPoint(i, 25.0, 545.5265,-1283.1184,17.2482) || IsPlayerInRangeOfPoint(i, 25.0, 1034.1200,-1030.5387,32.1489) || IsPlayerInRangeOfPoint(i, 30.0, 1628.1425,584.9908,1.7578) || IsPlayerInRangeOfPoint(i, 28.0, 2131.2944,1403.6899,11.1328) || IsPlayerInRangeOfPoint(i, 50.0, -566.2581,-1600.5735,-41.9882) || IsPlayerInRangeOfPoint(i, 90.0, -1424.7450,1615.7667,1052.5313) || IsPlayerInRangeOfPoint(i, 250.0, -376.1633,-1432.8551,25.7266)) -> ... etc, etc code
    ++++ player if.
}
You greatly help you with some answers. Thank you all.
Reply
#2

Make an array instead of all this;
PHP код:
    if(IsPlayerInRangeOfPoint(i75.01107.8771,-1794.3970,16.6937) || IsPlayerInRangeOfPoint(i85.01217.0133,-1740.3961,13.5955) || IsPlayerInRangeOfPoint(i30.01003.8006,-938.4607,42.2797) ||
        
IsPlayerInRangeOfPoint(i30.0647.529,-1357.39,13.5784) || IsPlayerInRangeOfPoint(i45.0, -60.6408,-1128.0583,1.1781) ||
        
IsPlayerInRangeOfPoint(i25.02102.3037,2235.5540,11.0234) || IsPlayerInRangeOfPoint(i25.01178.9655,-1323.4093,14.1461) || IsPlayerInRangeOfPoint(i25.0332.0587,-1516.1661,35.9672) ||
        
IsPlayerInRangeOfPoint(i25.0545.5265,-1283.1184,17.2482) || IsPlayerInRangeOfPoint(i25.01034.1200,-1030.5387,32.1489) || IsPlayerInRangeOfPoint(i30.01628.1425,584.9908,1.7578) || IsPlayerInRangeOfPoint(i28.02131.2944,1403.6899,11.1328) || IsPlayerInRangeOfPoint(i50.0, -566.2581,-1600.5735,-41.9882) || IsPlayerInRangeOfPoint(i90.0, -1424.7450,1615.7667,1052.5313) || IsPlayerInRangeOfPoint(i250.0, -376.1633,-1432.8551,25.7266)) 
PHP код:
enum rangeData
{
      
range,
      
rX,
      
rY,
      
rZ
};
new 
PlayerInRange[][rangeData] = 
{
       {
75.01107.8771,-1794.3970,16.6937},
       {
30.0647.529,-1357.39,13.5784},
       {
25.02102.3037,2235.5540,11.0234}
// So on ..
};
for(new 
isizeof(PlayerInRange); i++}
{
    if(
IsPlayerInRangeOfPoint(iPlayerInRange[i][range], PlayerInRange[i][rX], PlayerInRange[i][rY], PlayerInRange[i][rZ]))

It's not a fix for your issue, But i'm just saying ..
Reply
#3

Well are you sure problem is in your script??
You can do this

Make sure that you are not being ddosed
Make restriction for spawning more player at same time from 1 IP adress. Bots can really f*** you up sometmes xD

And problem might be timers for players.. You have any timer 500ms or something like that..??
Reply
#4

Quote:
Originally Posted by KessMan
Посмотреть сообщение
I have only 2 global timers.
This means absolutely nothing. It's all about what you do within those functions. As a matter of fact, more timers with fewer code will usually fare better than few timers with lots of code. Timer intervals should be set to prime numbers to minimize the amount of collisions (two or more timers executing at the exact same time).
Reply
#5

This might be a problem..

Quote:
Originally Posted by KessMan
Посмотреть сообщение
The first global timer (1000ms) has 423 lines with "if", exemple:
Why don't you just do what Vince said. Break this timer if possible in few more timers and use them only when needed and kill them when don't. This will significally (i think i spelled it right) help you..
Reply
#6

Thanks all for the reply, thanks. (Sorry for my bad english)

This would mean using "SetTimerEx" for each player with a time of 1 second to shrink the global timer?
But there are some systems that require timers. There is no problem if you are a 150-200 timers (SetTimerEx) per player if 150-200 players I use the same system (Horse Bet, PaintBall System, Job Farmer ...etc)?
And destroy (KillTimer) them when I need them.
Reply
#7

But listen.. Why don't you break that one big timer in few small timers if possible
Reply
#8

Quote:
Originally Posted by Micko123
Посмотреть сообщение
But listen.. Why don't you break that one big timer in few small timers if possible
I did not have such. The only solution is 150-200 SetTimerEx but if players are using the same rules system, that means 150-200 timers. That would not do more lag?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)