Script Size -
vassilis - 08.09.2016
I have a script around 9k+ lines. However, my script size is around 9MB and i recognize that it has pretty bad optimization. How to reduce size? Generally how could i fix the optimization of my script? I don't have anything used onPlayerUpdate. Should i search for not killed Timers? What else could help for a more neat script? Cheers.
Re: Script Size -
Vince - 08.09.2016
AMX size is largely influenced by large arrays. Runtime stuff like timers have NOTHING to do with it.
Re: Script Size -
OneDay - 08.09.2016
make arrays small to make script small. for optimising
https://sampforum.blast.hk/showthread.php?tid=271129
Re: Script Size -
vassilis - 08.09.2016
Quote:
Originally Posted by Vince
AMX size is largely influenced by large arrays. Runtime stuff like timers have NOTHING to do with it.
|
First of all, thank you Vince for your response. Do you think that multi-dimensional arrays that are used for enumerators could affect AMX size?
Quote:
Originally Posted by OneDay
|
I found it just 2 minutes ago but i can't really understand how it gets installed or it is installed as most plugins used for SA-MP?
Re: Script Size -
Stinged - 08.09.2016
Re-format strings instead of creating multiple ones for messages, for example:
Код:
new string[145];
GetPlayerName(targetid, string, 25);
format(string, sizeof (string), "[PM] To %s (%i): %s", string, targetid, params);
SendClientMessage(playerid, -1, string);
GetPlayerName(playerid, string, 25);
format(string, sizeof (string), "[PM] From %s (%i): %s", string, playerid, params);
SendClientMessage(targetid, -1, string);
// Do that instead of doing this:
new player_name[25], target_name[25], string1[145], string2[145];
GetPlayerName(playerid, player_name, 25);
GetPlayerName(targetid, target_name, 25);
format(string1, sizeof (string1), "[PM] To %s (%i): %s", target_name, targetid, params);
SendClientMessage(playerid, -1, string1);
format(string2, sizeof (string2), "[PM] From %s (%i): %s", player_name, playerid, params);
SendClientMessage(playerid, -1, string2);
Calculate how much cells you need for a string, instead of using a large size for no reason:
Код:
/*
String is:
%s (%i) has logged in.
To calculate how much cells (max.) it needs, replace the specifiers (%*) with their values:
%s = player name, which has a max length of 24
%i = playerid, which has a max length of 3 (because 999 is the limit)
() has logged in. = 18 characters
24 + 3 + 18 = 45
Add 1 to it for the NULL = 46
*/
new string[46];
Re: Script Size -
Gammix - 08.09.2016
Well i won't care about the AMX size if you have space for large files, after all your game works fine...
Anyways, use the following ways to decrease the size:
- Use static where you generally use format for strings.
pawn Код:
// Instead of this
new string[150];
format(string, sizeof string, ...);
// This saves alot
static string[150];
format(string, sizeof string, ...);
- Packed strings.
Re: Script Size -
vassilis - 08.09.2016
Thanks everyone for your responses I will take into consideration. One last question if I reduce size will the compiler timer be faster
Re: Script Size -
Nero_3D - 08.09.2016
Quote:
Originally Posted by Gammix
Anyways, use the following ways to decrease the size:
- Use static where you generally use format for strings.
pawn Код:
// Instead of this new string[150]; format(string, sizeof string, ...);
// This saves alot static string[150]; format(string, sizeof string, ...);
|
You actually increase the AMX size with using static instead of new for local variables
Quote:
Originally Posted by vassilis
Thanks everyone for your responses I will take into consideration. One last question if I reduce size will the compiler timer be faster
|
The compile times yes, like Vince already said only large global arrays matter
Re: Script Size -
Gammix - 08.09.2016
Quote:
Originally Posted by Nero_3D
You actually increase the AMX size with using static instead of new for local variables
|
I experienced short compile time with static so my assumption was low size but guess i was wrong here.