SA-MP Forums Archive
Question about lag - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question about lag (/showthread.php?tid=499917)



Question about lag - Brooks1 - 10.03.2014

Hello, I need advices.
My script is huge and when many players gather in one place the server starts lagging - I mean the things start to slow down, the commands and messages are delaying for few seconds and also sometimes the players are bugged, because of the lag and they need to relog. Мy script is bursting with a lot of things and I need tips on how to lighten to no lag.

I'm also using a lot ot permanent timers in OnGameModeInit. I'm using foreach in stead of for(new i = 0; i < MAX_PLAYERS; i++)
I tried to split the script into several includes, but did not help.

If you have a good advices for making a huge script without a lag, please tell me.
Sorry for my bad English.


Re: Question about lag - SPA - 10.03.2014

it may be your host problem.


Re: Question about lag - JonathanFeitosa - 10.03.2014

use static, strins, defines, eos...
reduce the number of cells.
Use variables for messages only once.
Streamer updated.
host good.


Re: Question about lag - Brooks1 - 10.03.2014

Quote:
Originally Posted by JonathanFeitosa
Посмотреть сообщение
use static, strins, defines, eos...
reduce the number of cells.
Use variables for messages only once.
Streamer updated.
host good.
Can you explain me about eos?

Use variables for messages only once. - I can't understand that.


Re: Question about lag - JonathanFeitosa - 10.03.2014

Yes:
pawn Код:
// Topo
new string[30]; //  increase
new Nome[24];

public OnPlayerConnect(playerid)
{
     GetPlayerName(playerid,  Nome, sizeof(Nome));
     format(string, sizeof(string), "Nome: %s");
     SendClientMessage(playerid, -1, string);
     return 0x01;
}
public OnPlayerSpawn(playerid)
{
     GetPlayerName(playerid,  Nome, sizeof(Nome));
     format(string, sizeof(string), "Nome: %s", Nome);
     SendClientMessage(playerid, -1, string);
     return 0x01;
}
no:
pawn Код:
public OnPlayerConnect(playerid)
{
     new string[30];
     new Nome[24];
     GetPlayerName(playerid,  Nome, sizeof(Nome));
     format(string, sizeof(sintrg), "Nome: %s");
     SendClientMessage(playerid, -1, string);
     return 0x01;
}
public OnPlayerSpawn(playerid)
{
     new string[30];
     new Nome[24];
     GetPlayerName(playerid,  Nome, sizeof(Nome));
     format(string, sizeof(string), "Nome: %s", Nome);
     SendClientMessage(playerid, -1, string);
     return 0x01;
}



Re: Question about lag - Brooks1 - 10.03.2014

Alright, I get it!

I thought of another idea - A lot of my arrays contains MAX_PLAYERS, if I re-define MAX_PLAYERS with 500 slots would that help for the lag?


Re: Question about lag - Pottus - 10.03.2014

You probably bought a $10 a month server or something I would think or have some really shitty coding or a combination of both.