SA-MP Forums Archive
stock/const/static/new array - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: stock/const/static/new array (/showthread.php?tid=285994)



stock/const/static/new array - MP2 - 26.09.2011

Which is best to use?

pawn Код:
new array[][3] = {
{1.0, 2.0, 3.0},
{4.0, 5.0, .0}
};
static?
stock?
const?

Please only reply if you know what you're talking about. I want to know which one is more efficient to use.


Re: stock/const/static/new array - Vince - 26.09.2011

Well in theory you can use all 3 at the same time.
pawn Код:
static const stock gMyArray[3] = {1, ...};
Static declares a variable to that file only, it is invisible for all other files (for an include, maybe). Const declares the variable as constant, this means you cannot modify it (accidentally) with code (useful for arrays of coordinates that never change). Stock tells the compiler to ignore the variable if it is never referred to in the code.

More details, as said, in pawn_lang.pdf


Re: stock/const/static/new array - MP2 - 26.09.2011

What I mean is, which will use less space?