Does Defining MAX_PLAYERS low lag?
#1

Well while testing the GM i am making, i see the chat and all lags a bit. Might it be caused becayse i have many functions searching on MAX_PLAYERS and i don't have it defined to a max?

Or could it be the timers?

Every timers i have are:

pawn Код:
new TIMER_pOnlineTime[MAX_PLAYERS];
new TIMER_Fuel[MAX_PLAYERS];
new TIMER_KM[MAX_PLAYERS];
new TIMER_Oil[MAX_PLAYERS];
new TIMER_Pneus[MAX_PLAYERS];
new TIMER_UpdateCar[MAX_PLAYERS];
new TIMER_UnJail[MAX_PLAYERS];

Under OnPlayerStateChange i have this, after checking if player is inside a vehicle..

TIMER_Fuel[playerid] = SetTimerEx("CFuel", 60000, true, "i", playerid);
TIMER_KM[playerid] = SetTimerEx("CKM", 30000, true, "i", playerid);
TIMER_Oil[playerid] = SetTimerEx("COil", 30000, true, "i", playerid);
TIMER_Pneus[playerid] = SetTimerEx("CPneus", 30000, true, "i", playerid);
TIMER_UpdateCar[playerid] = SetTimerEx("UpdateCar", 500, true, "i", playerid);
Than i have some 15 or 20 functions searching on MAX_PLAYERS but are rarely called.. It's like /ask to send messages to admins, and these things.

If it was an hosted server with lot of players it would be a reason to lag, but, test server where the max that join is me and my friend when i need to test things with 2 people, it turns weird for me.
Reply
#2

I don't know if it's still the case but one reason for the lag could be that you do things with not connected players. I did that mistake once, don't remember exactly what I did but I forgot to check if the player is connected which made my server lag heavily. Not sure if that's the case anymore though. Just a suggestion.

I have my doubts that your couple commands and your timers would really lag your server that much. Maybe you have a while loop that lasts for a pretty long while? Or even a for loop?

Just ideas though.

EDIT: I just realized you have three timers supposely working on the same milisecond. I think you should have a look at YSI from ****** and a deeper look at y_iterate. Since all of these timers execute on the same milisecond I can actually imagine the collision of these causing the server to hang for a moment awaiting for all three functions to finish. I don't know if this lag would be significant I am afraid but it could be a cause.

EDIT2: Infact, lets just test it? Try and add about a 100 miliseconds to one of the timers and remove a 100 miliseconds from another. So that none of the timers are on the same milisecond. 100 is probably a little much but its worth it to be sure. See if it lags or if it has stopped, if it did stop then you should have a look at y_iterate.
Reply
#3

I never check if player is connected... It was bugging together with sscanf.
Reply
#4

Oh right, if you use sscanf you don't actually have to check if the player is connected.

Though what I was saying is not commands like:

Код:
/kick PlayerID
but rather code that for example sets the positions of players even if they are not connected and such. I did that once a long time ago and it lagged my server a lot. Probably by now is fixed though.
Reply
#5

Quote:
Originally Posted by ricardo178
Посмотреть сообщение
Or could it be the timers?

Every timers i have are:

pawn Код:
Under OnPlayerStateChange i have this, after checking if player is inside a vehicle..

TIMER_Fuel[playerid] = SetTimerEx("CFuel", 60000, true, "i", playerid);
TIMER_KM[playerid] = SetTimerEx("CKM", 30000, true, "i", playerid);
TIMER_Oil[playerid] = SetTimerEx("COil", 30000, true, "i", playerid);
TIMER_Pneus[playerid] = SetTimerEx("CPneus", 30000, true, "i", playerid);
TIMER_UpdateCar[playerid] = SetTimerEx("UpdateCar", 500, true, "i", playerid);
When do you kill the timers? (KillTimer)
Reply
#6

I kill them on player exit vehicle...

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    KillTimer(TIMER_Fuel[playerid]);
    KillTimer(TIMER_KM[playerid]);
    KillTimer(TIMER_Oil[playerid]);
    KillTimer(TIMER_Pneus[playerid]);
    return 1;
}
All them are vehicle related..
Reply
#7

You're never killing this one

pawn Код:
TIMER_UpdateCar[playerid] = SetTimerEx("UpdateCar", 500, true, "i", playerid);
Reply
#8

Shit, that's probably it... Thank you man.
Reply
#9

It does not bug with sscanf,
Your just using it BEFORE you define id in sscanf.


use IsPlayerConnected AFTER sscanf
Reply
#10

i would also combine these 3 timers as they run at the same interval

pawn Код:
TIMER_KM[playerid] = SetTimerEx("CKM", 30000, true, "i", playerid);
TIMER_Oil[playerid] = SetTimerEx("COil", 30000, true, "i", playerid);
TIMER_Pneus[playerid] = SetTimerEx("CPneus", 30000, true, "i", playerid);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)