How to reduce the data size. It's about 100M [Need Help]
#1

I'm afraid that will take more effect in the future.



Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:          32572 bytes
Code size:          3146256 bytes
Data size:         96218572 bytes
Stack/heap size:      16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements:99413784 bytes
XML File: cs.rar
Reply
#2

It's not much of a problem unless you run out of space.

However, there are some "tricks" to do it anyway.

If you're running for example a 500 slot server, you can cut down the usage by re-defining MAX_PLAYERS at the top of the script (after including a_samp) to 500. So all Arrays with a MAX_PLAYERS dimension will be half as big.

Also not using exorbitant limits (for example, say you have 30 active Factions, but your MAX_FACTIONS define is 1000, define it to 50 or similar - extreme example but you get the idea).

If you just have a lot of data to store and there is no way of cutting that down, you can also redesign some systems to not have all data available at all times. For example, put the actual data, most importantly strings, into a (My)SQL Database and request it when needed. This doesn't make sense for systems that are constantly in use, but I'm sure you will find some Arrays that you could store elsewhere.

Then there are also Data Container Plugins which can be useful. They are always slower than PAWN Arrays/Variables but for some systems this wouldn't be noticable.
Reply
#3

I'm know that case. I put this on top of script !
Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS (100)
Too huge array like 1 house : 400 furniture, 1 furniture : 5 object material, 1 house : 40 weapon Package, but it needed. T^T

Data Container Plugins look like Link list ?
Reply
#4

Here is a way to reduce memory usage:
PHP код:
CMD:commands(playerid) {
    new list[
1500];
    
strcat(list, ...); // you put tons of text into "list"
    
ShowPlayerDialog(playerid, ..., list, ...);
}
/*
Now this is another way of doing things! And this way is faster too!
NOTE: you should use this only for constant texts i.e. strings/arrays that never change.
*/
CMD:commands(playerid) {
    static list[
1500];
    if (list[
0] == EOS) { // now this will only do the strcat part one time: first time when this callback is called
        
strcat(list, ...); // you put tons of text into "list"
    
}
    
ShowPlayerDialog(playerid, ..., list, ...);

In your case, if you have large constant arrays/strings which you use to display, just convert to "static".
Reply
#5

Like this ?

Код:
CMD:colorlist(playerid, params[])
{
	new id = -1;

	if ((PlayerData[playerid][pJob] == JOB_MECHANIC || PlayerData[playerid][pSideJob] == JOB_MECHANIC) || ((id = Biz_Nearest(playerid)) != -1 && BizInfo[id][bType] == 4))
	{
	    new
			string[3344];

	    string = "";

		for(new i = 0; i < 256; i++)
		{
		    if(i > 0 && (i % 16) == 0)
		    {
		        format(string, sizeof(string), "%s\n{%06x}#%03d ", string, g_arrSelectColors[i] >>> 8, i);
			}
		    else
			{
				format(string, sizeof(string), "%s{%06x}#%03d ", string, g_arrSelectColors[i] >>> 8, i);
			}
		}
		Dialog_Show(playerid, ShowOnly, DIALOG_STYLE_MSGBOX, "List of Color ID's:", string, "Close", "");
	}
	else SendClientMessage(playerid, COLOR_GRAD1, "¤ШідБидґйНВЩи·ХиµСЗб·№ЁУЛ№иТВВТ№ѕТЛ№Р");


	return 1;
}
change to

Код:
CMD:colorlist(playerid, params[])
{
	new id = -1;

	if ((PlayerData[playerid][pJob] == JOB_MECHANIC || PlayerData[playerid][pSideJob] == JOB_MECHANIC) || ((id = Biz_Nearest(playerid)) != -1 && BizInfo[id][bType] == 4))
	{
	    static
			string[3344];

                 if (string[0] == EOS) {
		for(new i = 0; i < 256; i++)
		{
		    if(i > 0 && (i % 16) == 0)
		    {
		        format(string, sizeof(string), "%s\n{%06x}#%03d ", string, g_arrSelectColors[i] >>> 8, i);
			}
		        else
			{
				format(string, sizeof(string), "%s{%06x}#%03d ", string, g_arrSelectColors[i] >>> 8, i);
			}
		}
                } 
		Dialog_Show(playerid, ShowOnly, DIALOG_STYLE_MSGBOX, "List of Color ID's:", string, "Close", "");
	}
	else SendClientMessage(playerid, COLOR_GRAD1, "¤ШідБидґйНВЩи·ХиµСЗб·№ЁУЛ№иТВВТ№ѕТЛ№Р");


	return 1;
}
Reply
#6

Yes.
Reply
#7

Quote:
Originally Posted by bigtigerbeee
Посмотреть сообщение
I'm know that case. I put this on top of script !
Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS (100)
Too huge array like 1 house : 400 furniture, 1 furniture : 5 object material, 1 house : 40 weapon Package, but it needed. T^T

Data Container Plugins look like Link list ?
You could save all that data to database and query it to load it then you only need to save object ids for later deletion.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)