SA-MP Forums Archive
[HELP] Something that makes me lag while playing - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: [HELP] Something that makes me lag while playing (/showthread.php?tid=366469)



[HELP] Something that makes me lag while playing - CaRaM3LL - 06.08.2012

First of all i want to show the code that make lag when is saving

Код:
 public SaveTool()
{
    new count;
    new saver[128];
    for(new i = 0;i<MAX_BUY_V;i++)
    {
        if(VehicleSystem[i][cmodel]!=0)
        {
            count++;
            format(saver,sizeof(saver),"veh_model_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][cmodel]);
            format(saver,sizeof(saver),"veh_x_%d",count);
            dini_FloatSet("masinipersonale.cfg",saver,VehicleSystem[i][xc]);
            format(saver,sizeof(saver),"veh_y_%d",count);
            dini_FloatSet("masinipersonale.cfg",saver,VehicleSystem[i][yc]);
            format(saver,sizeof(saver),"veh_z_%d",count);
            dini_FloatSet("masinipersonale.cfg",saver,VehicleSystem[i][zc]);
            format(saver,sizeof(saver),"veh_a_%d",count);
            dini_FloatSet("masinipersonale.cfg",saver,VehicleSystem[i][ac]);
            format(saver,sizeof(saver),"veh_Farbe1_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][Farbe1]);
            format(saver,sizeof(saver),"veh_Farbe2_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][Farbe2]);
            format(saver,sizeof(saver),"veh_owner_%d",count);
            dini_Set("masinipersonale.cfg",saver,VehicleSystem[i][owner]);
            format(saver,sizeof(saver),"veh_preis_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][preis]);
            //
            format(saver,sizeof(saver),"veh_mod1_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod1]);
            format(saver,sizeof(saver),"veh_mod2_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod2]);
            format(saver,sizeof(saver),"veh_mod3_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod3]);
            format(saver,sizeof(saver),"veh_mod4_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod4]);
            format(saver,sizeof(saver),"veh_mod5_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod5]);
            format(saver,sizeof(saver),"veh_mod6_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod6]);
            format(saver,sizeof(saver),"veh_mod7_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod7]);
            format(saver,sizeof(saver),"veh_mod8_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod8]);
            format(saver,sizeof(saver),"veh_mod9_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod9]);
            format(saver,sizeof(saver),"veh_mod10_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod10]);
            format(saver,sizeof(saver),"veh_mod11_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod11]);
            format(saver,sizeof(saver),"veh_mod12_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod12]);
            format(saver,sizeof(saver),"veh_mod13_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod13]);
            format(saver,sizeof(saver),"veh_mod14_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod14]);
            format(saver,sizeof(saver),"veh_mod15_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod15]);
            format(saver,sizeof(saver),"veh_mod16_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod16]);
            format(saver,sizeof(saver),"veh_mod17_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][mod17]);
            format(saver,sizeof(saver),"veh_Lock_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][Lock]);
            format(saver,sizeof(saver),"veh_Exploded_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][Exploded]);
            format(saver,sizeof(saver),"veh_paint_%d",count);
            dini_IntSet("masinipersonale.cfg",saver,VehicleSystem[i][paintjob]);
        }
    }
    return 1;
}
So, i maked a Timer which save every 2,5 min. That's ok but when is saving causes lag over 10 seconds and the game freeze.

I don't know what to do to stop making lag. Can you help me to solve the problem ?

(sorry for my bad english, i'm from romanian)


Re: [HELP] Something that makes me lag while playing - playbox12 - 06.08.2012

Sure, the problem is that you are using dini. Dini is outdated and ineffecient. If you like to save a lot of data multiple times I suggest you either got with an updated file system like y_INI or SQLite. Personally I would go with mySQL, for the threaded functionality.

Also why do you have to save it every 2.5m? I'm not sure what exactly you are saving, but if it's something for players vehicles just save them when they log off.


Re: [HELP] Something that makes me lag while playing - CaRaM3LL - 06.08.2012

If i change dini in Y_ini i need to change everything ?

You can make an example for me please ? Change my code DINI in Y_INI

@Thanks for answer, i will change dini in future