PDA

View Full Version : String array sizes


rt-2
01/10/2011, 03:51 AM
Hi,
I just have a simple question:

Why some coder stop their strings size to [256].. i use to stop mine at [300], is that why my script is sometimes unstable?

thanks

grand.Theft.Otto
01/10/2011, 03:59 AM
I recommend string sizes 128 or lower. 300 is way too much and in-efficient for your script.

The string size means how many characters/letters are going to be in your string/message. You can always use at least [50] for small text strings, but remember: if a player's name and id with a message all appear in one string/line, I would recommend a bigger string size, like 128, not 50.

300 is useless, in-efficient and uses up a lot of computer resources.

Dolby
01/10/2011, 04:03 AM
In this case,256 = cells,In Other Words,if you define 256,you can use 256 letters.

You can use this: http://projogos.com.br/GeradoresJFS/GeradorCelula.html to count the you letters,to not wasting cells.

Rachael
01/10/2011, 04:22 AM
Obviously defining smaller string arrays will reduce memory usage. It will not change cpu usage.

To answer the original question, the number 256 is a nice round number in coding terms because it is 2 ^ 8 or
2x2x2x2x2x2x2x2 = 256

This does not make it in any way a better default size for string arrays

DRIFT_HUNTER
01/10/2011, 05:07 AM
http://forum.sa-mp.com/showthread.php?t=55261