Timers making lag.. Rep+ 1
#1

I'm using 3 Timers in Server .

Under OnPlayerConnect
SetTimerEx("Anticheat", 1000, true, "i", playerid); // for checking the cheats..

Under OnGameModeInt
SetTimer("RandomMessage", 40000, 1);

This is Timer to Update Players Textdraws Stats ..
SetTimerEx("StatsInfromation", 1000, true, "u", playerid);


I see Players in Server Stop after some sec and then move..
Like AFk and after some sec move..

What should i do now to remove the Lag I'm not using
Код:
public OnPlayerUpdate(playerid)
{
    #if PauseDetectSystem == true
    pTick[playerid] = GetTickCount();
    #endif
    #if MoveSystem == true
    if(pInfo[playerid][Move] == 1)
    GetPlayerHoldingKey(playerid);
    #endif

    SaveStatus(playerid);
    return 1;
}
What should i do now ?
Reply
#2

I would always recommend to use timers instead of having code in your OnPlayerUpdate.

But the lag depends on how much code you're trying to process, and how often, in OnPlayerUpdate, it will process all the code each time the player sends an update packet. Etc. 30 ms or something like that, maybe even more if they have a high framerate.

The same goes for timers, processing too much code each second might also lag.

It could also depend on your machine specs, how much it can handle.
Reply
#3

Код:
what if I remove this Code from the OnPlayerUpdate
And put this in Timer?

#if PauseDetectSystem == true
    pTick[playerid] = GetTickCount();
    #endif
    #if MoveSystem == true
    if(pInfo[playerid][Move] == 1)
    GetPlayerHoldingKey(playerid);
    #endif

    SaveStatus(playerid); 

? it will Fix lag?
Reply
#4

The SaveStatus Make you lagg
Reply
#5

No need to use a timer to save stats every second use it to save it every 4 to 5 minutes or at least 2 minutes.
Also use OnPlayerUpdate callback for neccessary things like anti-cheat
Reply
#6

Yes it might fix your lag, depending on how quickly the timer repeats. As i said.
Quote:

The same goes for timers, processing too much code each second might also lag.

Setting it to a timer of about 10 seconds should be fine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)