PDA

View Full Version : amx size


iBots
16/04/2015, 09:10 AM
Well,i have made a login and register with mysql and 4 commands using zcmd and a big system with dialogs and saving/loading for objects,and then amx size went to 2500 kb,and .pwn is 59 kb,why did it increase that much and will it effect on the server?

MEW273
16/04/2015, 09:18 AM
Hi iBots,

I am speaking strictly from personal experience only; I don't believe that the file size of your .pwn or .amx should have any effect on the performance of your server. The larger your .pwn becomes the larger your .amx will become as you fill your gamemode with more data and it is important that you optimize your gamemode script especially when you start heading into the thousand's of lines as the more content you have the higher amount of resources you will be using and more work your server will be doing.

To re-iterate, only speaking here from personal experience.

]Rafaellos[
16/04/2015, 09:18 AM
When I used to have Y_INI, my amx file was ~4mb. As I am aware of, it doesn't affect the server.

Edit, a bit late.

iiNzTicTx
16/04/2015, 09:21 AM
When the compiler compiles something, it reorganizes the code, slots things there and there to allow it to work. Basically there's additional data required to run it as an actual gamemode from the server's client. However, 59kb to 2500kb is reasonably large, are you sure you do not have any includes doing this?

The data size does determine on performance however it doesn't take a massive impact. Think of it as a graphical image, high quality vs low quality. High quality requires more file size, however takes longer to load. In terms of SAMP though, compare the gamemode with the size of an image!

iBots
16/04/2015, 09:39 AM
well,i got these includes

a_samp
a_mysql
ZCMD
sscanf2
streamer

NOTE:well i got saving and loading for the system,this system took around 1k lines(i mean the system is like 1k lines),and the gamemode is more than 1500 lines for now.

Ahmad45123
16/04/2015, 11:03 AM
I have more than 6 includes and 5 plugins and 100K lines and the AMX size reaches 10MB+... And as long as its optimized, It doesn't affect performance at all.

ATGOggy
16/04/2015, 11:33 AM
What's the size before you compiled it?

ikey07
16/04/2015, 11:41 AM
Amx size doesn't depends on how many includes/plugins or what not you use.

It depends on how you write your code.


you can open pawno, write in

#include <a_samp>


main()
{
new a[100000000];
}



Compile and it will be a big amx file, always redefine MAX_PLAYERS to your slot amount, because MAX_PLAYERS by default is 500

ATGOggy
16/04/2015, 11:46 AM
Well, you can't create an array having size over 2048.
Also, if you already used MAX_PLAYERS at many places, then just add this code on the top of your script:#undef MAX_PLAYERS
#define MAX_PLAYERS 50 (change 50 to your server slot)

Misiur
16/04/2015, 05:55 PM
Of course you can! The limit is only your heap size, which can be adjusted with #pragma dynamic (not recommended of course). 2048 is limit for dialog main body text.

Denis1
16/04/2015, 06:51 PM
Not sure it would change anything, but a very useful tip I was given when I started scripting: people usually declare arrays with a size of 128 cells (e.g. when they want to send a formatted client message), even though they need less. Help yourself, don't use more data than you need.

Example of how it should be:


public OnPlayerConnect(playerid)
{
new str[48], name[MAX_PLAYER_NAME +1];
GetPlayerName(playerid, name, sizeof(name));
format(str, sizeof(str), "%s has joined the server.", name);
SendClientMessageToAll(-1, str);
return 1;
}


You have to find ways to optimize your code. Also, use ****** to find a cut & paste character count to make your life easier. It may have not been the best answer, but I gave you an idea of what you should do in order to make your script as effective as possible.

Mencent
16/04/2015, 06:56 PM
Hello! ;D

To keep the .amx-file even smaller, you can pack the messages:
SendClientMessage(playerid,-1,"Hello my name is Mencent");
to
SendClientMessage(playerid,-1,!"Hello my name is Mencent");

It will be keep the .amx-file smaller.
In format it don't works.

Mencent :cool:

J4Rr3x
16/04/2015, 07:07 PM
Use packed string
Instead include YSI.inc include directly the inc you need (i.e. YSI\y_ini instead of YSI.inc)
Reorders your code, i.e. use less bracket. Change:

for(new i = 0; i != MAX_PLAYERS; i++)
{
if(IsPlayerConnected(playerid))
{
if(Player_Info[playerid][pHouse] == 1)
{
Player_Info[playerid][pHouse] = 0;
}
}
}

with:

for(new i = 0; i != MAX_PLAYERS; i++)
if(IsPlayerConnected(playerid) && Player_Info[playerid][pHouse] == 1)
Player_Info[playerid][pHouse] = 0;

Read tutorials about improving your code

Azula
16/04/2015, 07:09 PM
public OnPlayerConnect(playerid)
{
new str[48];
GetPlayerName(playerid, name, sizeof(name));
format(str, sizeof(str), "%s has joined the server.", GetName(playerid));
SendClientMessageToAll(-1, str);
return 1;
}

stock GetName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
return name;
}

Mencent
16/04/2015, 07:15 PM
stock GetName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
return name;
}


It's a very bad idea. You should once store the name in OnPlayerConnect then you can use again and again.
So write it so:
new pName[MAX_PLAYERS][MAX_PLAYER_NAME];//global

//On OnPlayerConnect
GetPlayerName(playerid,pName[playerid],MAX_PLAYER_NAME);

//Use
new string[MAX_PLAYER_NAME+15];
format(string,sizeof string,"Your Name is: %s",pName[playerid]);
SendClientMessage(playerid,-1,string);

Mencent :cool: