PDA

View Full Version : [HELP] SAMP problems (lagging)


dhelz7
30/04/2016, 06:02 AM
Hello everyone!

Simply.
My friend has just created a new server (Indonesian server).
On the first gamemode, it was no problem. (without SQL)

We decided to change our gamemode. (with SQL)
But the problem is, we always got lag when we join our new gamemode, such as delay when chat, driving, shot fired, lag while running, and delay when we use some commands.

My friend has upgraded RAM, but nothing changed, we still got same problems.
We had to download newly plugins, and already replaced.
Still lag :P

Can someone tell me what is the problem?
Sorry for my bad English, thank you.

Sew_Sumi
30/04/2016, 06:20 AM
So you've switched gamemodes entirely, and have a problem with the new gamemode... You should be chasing up support in its release thread then.

This section is for getting help with code that's giving a scripter issues.

dhelz7
30/04/2016, 08:49 AM
After we changed, we have upgraded our RAM. What's the problem then?


I don't know.

CalvinC
30/04/2016, 08:55 AM
Get another gamemode then?

Logic_
30/04/2016, 09:04 AM
Your gamemode must be having many timers and stuff, that must be causing the lag.

czerwony03
30/04/2016, 09:55 AM
Bad implemented SQL or MySQL cause lags.
Rewrite it, and use MySQL R39 plugin with caching. It resolve most problems with lags.

dhelz7
01/05/2016, 06:50 AM
Bad implemented SQL or MySQL cause lags.
Rewrite it, and use MySQL R39 plugin with caching. It resolve most problems with lags.

I'll try it now. Thanks all for responds

dhelz7
01/05/2016, 06:55 AM
My friend said.
It was on 'OnPlayerUpdate', and made this server lag. Is that true?

CalvinC
01/05/2016, 07:10 AM
If there's a lot of code being executed in OnPlayerUpdate the server will definitely lag, make him put it into timers instead.

dhelz7
02/05/2016, 02:30 AM
If there's a lot of code being executed in OnPlayerUpdate the server will definitely lag, make him put it into timers instead.

Can you give me some example?

colonel-top
02/05/2016, 03:56 AM
When MYSQL is saving its took a little second to communicate with Database so just save when its important part like OnplayerDisconnect and When Set Administrator Level o0r VIP Level its enough if you save every second or every cmds of course you will get lag

dhelz7
02/05/2016, 08:29 AM
When MYSQL is saving its took a little second to communicate with Database so just save when its important part like OnplayerDisconnect and When Set Administrator Level o0r VIP Level its enough if you save every second or every cmds of course you will get lag

Thank you. Our scripter is doing your opinion.

Sew_Sumi
02/05/2016, 09:08 AM
When you save things OnPlayerDisconnect it generally returns nonsense information, as the player has indeed disconnected.

So run a timer that runs every minute or so that saves accounts whilst they are online, or save their account when changes happen.

Such times as /deposit /withdrawl /buylevel, buy a car, or on death.

dhelz7
03/05/2016, 09:58 AM
I found this.
Timer:saveData[1800000]()
{
foreach(Player, x)
{
savePlayerData(x);
}
for(new xh = 0; xh < MAX_HOUSES; xh++) {
saveHouse(xh);
}
for(new xh = 0; xh < MAX_FIELD; xh++) {
saveField(xh);
}

for(new xf = 0; xf < MAX_GROUPS; xf++) {
saveGroup(xf);
}

for(new xf = 0; xf < MAX_BUSINESSES; xf++)
{
saveBusiness(xf);
}
for(new xf = 0; xf < MAX_SPEEDCAMS; xf++)
{
saveSpeedcam(xf);
}
for(new xf = 0; xf < MAX_PLANT; xf++)
{
savePlant(xf);
}
for(new xf = 0; xf < MAX_FURNITURE; xf++)
{
SaveFurniture(xf);
}
for(new xf = 0; xf < MAX_WORKSHOP; xf++)
{
saveWorkshop(xf);
}
for(new xf = 0; xf < MAX_GASSTATION; xf++)
{
saveGasStation(xf);
}
for(new xf = 0; xf < MAX_ASSETS; xf++) {
saveAsset(xf);
}
for(new xf = 0; xf < MAX_DEALERSHIP; xf++)
{
saveDealership(xf);
}
for(new x = 0; x < MAX_VEHICLES; x++)
{
saveVehicle(x);
}
saveMOTD();
SaveProducts();
SaveFurnitures();
SaveMine();
SaveComp();
SaveFuel();
SaveWood();
SaveFish();
SaveStone();
SaveJackpot();
print("- All data saved.");
return 1;
}
Need to be changed or?

Sew_Sumi
03/05/2016, 01:40 PM
That there, should be run every 5 mins or so. If you have a lot of businesses and all the bits down, such as vehicles and all that it will cause lag when those are encountered.

Like, there are a LOT of things on that timer and if each of those loops are submitting queries to the SQL, then it will start having issues.

What you could try is put a print statement between each one on it to show you how long that whole sequence is actually taking.

The timestamp in the logs will show you roughly how long it is taking to do that.

like print("Save complete on Houses"); and print("Save complete on Businesses");


You could work on breaking them up, and have half of them on one part of a timer, and the rest on another. Or break them up to multiple sections to cut back on that lag, if it is what is causing it.

dhelz7
04/05/2016, 04:36 AM
What is the solution? Give me some example please. Thank you

Sew_Sumi
04/05/2016, 05:51 AM
What is the solution? Give me some example please. Thank you

Breaking the saves up into 2 groups could be an option. Another is to ensure the saves are done further apart (5 mins) to make it not as often, and less noticeable.

dhelz7
04/05/2016, 06:16 AM
Like this?

Timer:saveData[1800000]()
{
foreach(Player, x)
{
savePlayerData(x);
}
for(new xh = 0; xh < MAX_HOUSES; xh++) {
saveHouse(xh);
}
for(new xh = 0; xh < MAX_FIELD; xh++) {
saveField(xh);
}

for(new xf = 0; xf < MAX_GROUPS; xf++) {
saveGroup(xf);
}

for(new xf = 0; xf < MAX_BUSINESSES; xf++)
{
saveBusiness(xf);
}
for(new xf = 0; xf < MAX_SPEEDCAMS; xf++)
{
saveSpeedcam(xf);
}
for(new xf = 0; xf < MAX_PLANT; xf++)
{
savePlant(xf);
}
for(new xf = 0; xf < MAX_FURNITURE; xf++)
{
SaveFurniture(xf);
}
for(new xf = 0; xf < MAX_WORKSHOP; xf++)
{
saveWorkshop(xf);
}
for(new xf = 0; xf < MAX_GASSTATION; xf++)
{
saveGasStation(xf);
}
for(new xf = 0; xf < MAX_ASSETS; xf++) {
saveAsset(xf);
}
for(new xf = 0; xf < MAX_DEALERSHIP; xf++)
{
saveDealership(xf);
}
for(new x = 0; x < MAX_VEHICLES; x++)
{
saveVehicle(x);
}
print("- All data saved.");
return 1;
}

Timer:saveDataTwo[1800000]()
{
saveMOTD();
SaveProducts();
SaveFurnitures();
SaveMine();
SaveComp();
SaveFuel();
SaveWood();
SaveFish();
SaveStone();
SaveJackpot();
print("- Data II Saved.");
}


What should I set the '1800000'? Should be changed or?

dhelz7
04/05/2016, 06:36 AM
FIXED full! Thank you!!!

Sew_Sumi
04/05/2016, 10:38 AM
You'll just want to keep an eye on what is being saved. See like, on the first save you have the gasstations being saved, but then on the second has fuel (Unless this fuel, is for the cars). But yea, just keep an eye on them, and remember in the future to avoid overloading timers. :)