open.mp forum
[Pawn] Set the size of an array based on another - Printable Version

+- open.mp forum (https://forum.open.mp)
+-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
+--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
+--- Thread: [Pawn] Set the size of an array based on another (/showthread.php?tid=2776)



Set the size of an array based on another - JR_Junior - 2024-06-07

Hello, I know that the size of an array must be defined by a constant, but is there any way to define the size based on a parameter or another array?

PHP Code:
stock GetStringPreview(string[],maxlength=25) { new preview[maxlength+3],len; format(preview,maxlength,"%s",string); if(strlen(string) > maxlength) { len = strlen(preview); strins(preview, "...",((preview[len-1] == ' ') ? len-1 : len)); } return preview; }



RE: Set the size of an array based on another - Virsenas - 2024-07-03

// Setting
#DEFINE ARRAY_SIZE 40

// Another array size
new another_array[40];
new array[sizeof(another_array)];