Lag help
#1

Heey guys,

I made a server and I get huge lag when I am near another player. Everyone has the same problem. I think it's something causing in my script...

I tried on different hosts and all got the problem.

Please help!
Reply
#2

Maybe your gamemode is un-optimized ?
Reply
#3

Run profiler plugin. Also check for large chunks of code in OnPlayerUpdate.
Reply
#4

Thanks guys:

Here my onplayerupdate:
PHP код:
public OnPlayerUpdate(playerid)
{
    new 
str[256];
    
format(str,sizeof(str),"~r~Kills: ~w~%d ~g~Deaths: ~w~%d",User[playerid][kills],User[playerid][deaths], User[playerid][score]);
    
TextDrawSetString(Text:Stats[playerid],str);
    new 
string[256];
    
format(string,sizeof(string),"~g~Score: ~w~%d ~g~Class: ~w~%d",User[playerid][score],gPlayerClass[playerid]);
    
TextDrawSetString(Text:Stats2[playerid],string);
    new 
st[256];
    new 
Float:ratio;
    if(
User[playerid][deaths] <= 0ratio 0.0;
    else 
ratio floatdiv(User[playerid][kills], User[playerid][deaths]);
    
format(st,sizeof(st),"~g~K/D: ~w~%0.2f",ratio);
    
TextDrawSetString(Text:Stats3[playerid],st);
    
GetPlayerRank(playerid);
    return 
1;

Reply
#5

Well first thing is, optimize your code. Especially your arrays.
3 different arrays with 256 cells? Couldn't you reformat the same one?

And why do you do that under OnPlayerUpdate?
Just update the textdraw whenever something needs updating.
(For example, use OnPlayerDeath to update your kills and deaths etc..)
OnPlayerUpdate runs multiple times a second.
Reply
#6

Nothing too extensive, but still completely unnecessary considering that all these things are controlled by the server. OnPlayerUpdate is meant to capture events that are controlled by the client and for which no specific callback exists. It is not a general purpose timer.

Kills/Deaths related textdraw should be moved to OnPlayerDeath. Score textdraw should be moved to wherever the score is updated.
Reply
#7

Thanks guys!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)